Package com.yahoo.prelude.query.parser
Class AbstractParser
java.lang.Object
com.yahoo.prelude.query.parser.AbstractParser
- All Implemented Interfaces:
CustomParser
,Parser
- Direct Known Subclasses:
AdvancedParser
,AllParser
,AnyParser
,PhraseParser
,TokenizeParser
The Vespa query parser.
- Author:
- bratseth, Steinar Knutsen
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
The counter for braces in URLs, braces in URLs are accepted so long as they are balanced.protected String
protected final ParserEnvironment
protected IndexFacts.Session
The IndexFacts.Session of this queryprotected com.yahoo.language.Language
The current language of this parser.protected com.yahoo.prelude.query.parser.AbstractParser.Submodes
The current submodes of this parserprotected final com.yahoo.prelude.query.parser.TokenPosition
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractParser
(ParserEnvironment environment) Creates a new instance of this class, storing the givenParserEnvironment
for parse-time access to the environment. -
Method Summary
Modifier and TypeMethodDescriptionprotected String
Unicode normalizes some piece of natural language text.final QueryTree
final Item
parse
(String queryToParse, String filterToParse, com.yahoo.language.Language parsingLanguage, IndexFacts.Session indexFacts, String defaultIndex) protected abstract Item
protected Item
Segments a tokenprotected void
setState
(com.yahoo.language.Language queryLanguage, IndexFacts.Session indexFacts, String defaultIndex) static Item
simplifyPhrases
(Item unwashed) Collapses single item phrases in the tree to the contained item.protected void
tokenize
(String query, String defaultIndexName, IndexFacts.Session indexFacts, com.yahoo.language.Language language) Tokenizes the given string and initializes tokens with the found tokens.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.yahoo.prelude.query.parser.CustomParser
parse
-
Field Details
-
submodes
protected com.yahoo.prelude.query.parser.AbstractParser.Submodes submodesThe current submodes of this parser -
language
protected com.yahoo.language.Language languageThe current language of this parser. Used to decide whether and how to use the CJKSegmenter -
indexFacts
The IndexFacts.Session of this query -
defaultIndex
-
braceLevelURL
protected int braceLevelURLThe counter for braces in URLs, braces in URLs are accepted so long as they are balanced. -
environment
-
tokens
protected final com.yahoo.prelude.query.parser.TokenPosition tokens
-
-
Constructor Details
-
AbstractParser
Creates a new instance of this class, storing the givenParserEnvironment
for parse-time access to the environment.- Parameters:
environment
- the environment settings to attach to the Parser
-
-
Method Details
-
parse
Description copied from interface:Parser
-
parse
public final Item parse(String queryToParse, String filterToParse, com.yahoo.language.Language parsingLanguage, IndexFacts.Session indexFacts, String defaultIndex) - Specified by:
parse
in interfaceCustomParser
-
parseItems
-
normalize
Unicode normalizes some piece of natural language text. The chosen form is compatibility decomposition, canonical composition (NFKC). -
setState
protected void setState(com.yahoo.language.Language queryLanguage, IndexFacts.Session indexFacts, String defaultIndex) -
tokenize
protected void tokenize(String query, String defaultIndexName, IndexFacts.Session indexFacts, com.yahoo.language.Language language) Tokenizes the given string and initializes tokens with the found tokens.- Parameters:
query
- the string to tokenizedefaultIndexName
- the name of the index to use as defaultindexFacts
- resolved information about the index we are searchinglanguage
- the language set for this query, or null if none
-
simplifyPhrases
Collapses single item phrases in the tree to the contained item.- Parameters:
unwashed
- The item whose phrases to simplify.- Returns:
- The simplified item.
-
segment
Segments a token- Parameters:
indexName
- the index name which preceeded this token, or null if nonetoken
- the token to segmentquoted
- whether this segment is within quoted text- Returns:
- the resulting item
-