sPhraseType = $sPhraseType; $this->iPhrase = $iPhrase; $this->iNumPhrases = $iNumPhrases; } public function setTokenPosition($iToken, $iNumTokens) { $this->iToken = $iToken; $this->iNumTokens = $iNumTokens; } /** * Check if the phrase can be of the given type. * * @param string $sType Type of phrse requested. * * @return True if the phrase is untyped or of the given type. */ public function maybePhrase($sType) { return $this->sPhraseType == '' || $this->sPhraseType == $sType; } /** * Check if the phrase is exactly of the given type. * * @param string $sType Type of phrse requested. * * @return True if the phrase of the given type. */ public function isPhrase($sType) { return $this->sPhraseType == $sType; } /** * Return true if the token is the very first in the query. */ public function isFirstToken() { return $this->iPhrase == 0 && $this->iToken == 0; } /** * Check if the token is the final one in the query. */ public function isLastToken() { return $this->iToken + 1 == $this->iNumTokens && $this->iPhrase + 1 == $this->iNumPhrases; } /** * Check if the current token is part of the first phrase in the query. */ public function isFirstPhrase() { return $this->iPhrase == 0; } /** * Get the phrase position in the query. */ public function getPhrase() { return $this->iPhrase; } }