3  * SPDX-License-Identifier: GPL-2.0-only
 
   5  * This file is part of Nominatim. (https://nominatim.org)
 
   7  * Copyright (C) 2022 by the Nominatim developer community.
 
   8  * For a full list of authors see the git log.
 
  14  * Segment of a query string.
 
  16  * The parts of a query strings are usually separated by commas.
 
  20     // Complete phrase as a string (guaranteed to have no leading or trailing
 
  23     // Element type for structured searches.
 
  25     // Possible segmentations of the phrase.
 
  28     public function __construct($sPhrase, $sPhraseType)
 
  30         $this->sPhrase = trim($sPhrase);
 
  31         $this->sPhraseType = $sPhraseType;
 
  35      * Get the original phrase of the string.
 
  37     public function getPhrase()
 
  39         return $this->sPhrase;
 
  43      * Return the element type of the phrase.
 
  45      * @return string Pharse type if the phrase comes from a structured query
 
  46      *                or empty string otherwise.
 
  48     public function getPhraseType()
 
  50         return $this->sPhraseType;
 
  53     public function setWordSets($aWordSets)
 
  55         $this->aWordSets = $aWordSets;
 
  59      * Return the array of possible segmentations of the phrase.
 
  61      * @return string[][] Array of segmentations, each consisting of an
 
  64     public function getWordSets()
 
  66         return $this->aWordSets;
 
  70      * Invert the set of possible segmentations.
 
  74     public function invertWordSets()
 
  76         foreach ($this->aWordSets as $i => $aSet) {
 
  77             $this->aWordSets[$i] = array_reverse($aSet);
 
  81     public function debugInfo()
 
  84                 'Type' => $this->sPhraseType,
 
  85                 'Phrase' => $this->sPhrase,
 
  86                 'WordSets' => $this->aWordSets