6 * Segment of a query string.
8 * The parts of a query strings are usually separated by commas.
12 // Complete phrase as a string (guaranteed to have no leading or trailing
15 // Element type for structured searches.
17 // Possible segmentations of the phrase.
20 public function __construct($sPhrase, $sPhraseType)
22 $this->sPhrase = trim($sPhrase);
23 $this->sPhraseType = $sPhraseType;
27 * Get the orginal phrase of the string.
29 public function getPhrase()
31 return $this->sPhrase;
35 * Return the element type of the phrase.
37 * @return string Pharse type if the phrase comes from a structured query
38 * or empty string otherwise.
40 public function getPhraseType()
42 return $this->sPhraseType;
45 public function setWordSets($aWordSets)
47 $this->aWordSets = $aWordSets;
51 * Return the array of possible segmentations of the phrase.
53 * @return string[][] Array of segmentations, each consisting of an
56 public function getWordSets()
58 return $this->aWordSets;
62 * Invert the set of possible segmentations.
66 public function invertWordSets()
68 foreach ($this->aWordSets as $i => $aSet) {
69 $this->aWordSets[$i] = array_reverse($aSet);
73 public function debugInfo()
76 'Type' => $this->sPhraseType,
77 'Phrase' => $this->sPhrase,
78 'WordSets' => $this->aWordSets