6 * Description of the position of a token within a query.
19 public function __construct($sPhraseType, $iPhrase, $iNumPhrases)
21 $this->sPhraseType = $sPhraseType;
22 $this->iPhrase = $iPhrase;
23 $this->iNumPhrases = $iNumPhrases;
26 public function setTokenPosition($iToken, $iNumTokens)
28 $this->iToken = $iToken;
29 $this->iNumTokens = $iNumTokens;
33 * Check if the phrase can be of the given type.
35 * @param string $sType Type of phrse requested.
37 * @return True if the phrase is untyped or of the given type.
39 public function maybePhrase($sType)
41 return $this->sPhraseType == '' || $this->sPhraseType == $sType;
45 * Check if the phrase is exactly of the given type.
47 * @param string $sType Type of phrse requested.
49 * @return True if the phrase of the given type.
51 public function isPhrase($sType)
53 return $this->sPhraseType == $sType;
57 * Return true if the token is the very first in the query.
59 public function isFirstToken()
61 return $this->iPhrase == 0 && $this->iToken == 0;
65 * Check if the token is the final one in the query.
67 public function isLastToken()
69 return $this->iToken + 1 == $this->iNumTokens && $this->iPhrase + 1 == $this->iNumPhrases;
73 * Check if the current token is part of the first phrase in the query.
75 public function isFirstPhrase()
77 return $this->iPhrase == 0;
81 * Get the phrase position in the query.
83 public function getPhrase()
85 return $this->iPhrase;