public abstract class AbstractParser extends Object implements CustomParser
Modifier and Type | Class and Description |
---|---|
(package private) class |
AbstractParser.Submodes
An enumeration of the parser index-controlled submodes.
|
Modifier and Type | Field and Description |
---|---|
protected int |
braceLevelURL
The counter for braces in URLs, braces in URLs are accepted so long as
they are balanced.
|
protected ParserEnvironment |
environment |
protected IndexFacts.Session |
indexFacts
The IndexFacts.Session of this query
|
protected com.yahoo.language.Language |
language
The current language of this parser.
|
protected AbstractParser.Submodes |
submodes
The current submodes of this parser
|
protected TokenPosition |
tokens |
Modifier | Constructor and Description |
---|---|
protected |
AbstractParser(ParserEnvironment environment)
Creates a new instance of this class, storing the given
ParserEnvironment for parse-time access to the
environment. |
Modifier and Type | Method and Description |
---|---|
private static void |
assignDefaultIndex(String defaultIndex,
Item item)
Assigns the default index to query terms having no default index The
parser _should_ have done this, for some reason it doesn't
|
private static Item |
collapsePhrase(PhraseItem phrase) |
private String |
generateLanguageDetectionTextFrom(TokenPosition tokens,
IndexFacts.Session indexFacts,
String defaultIndex)
Do a best-effort attempt at creating a single string for language detection from only the relevant
subset of tokens.
|
private boolean |
is(Token.Kind kind,
Token tokenOrNull) |
protected String |
normalize(String input)
Unicode normalizes some piece of natural language text.
|
QueryTree |
parse(Parsable query)
|
Item |
parse(String queryToParse,
String filterToParse,
com.yahoo.language.Language parsingLanguage,
IndexFacts.Session indexFacts,
String defaultIndexName) |
private Item |
parse(String queryToParse,
String filterToParse,
com.yahoo.language.Language parsingLanguage,
IndexFacts.Session indexFacts,
String defaultIndexName,
Parsable parsable) |
protected abstract Item |
parseItems() |
protected Item |
segment(Token token) |
protected void |
setState(com.yahoo.language.Language queryLanguage,
IndexFacts.Session indexFacts) |
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
parse
protected AbstractParser.Submodes submodes
protected com.yahoo.language.Language language
protected IndexFacts.Session indexFacts
protected int braceLevelURL
protected final ParserEnvironment environment
protected final TokenPosition tokens
protected AbstractParser(ParserEnvironment environment)
Creates a new instance of this class, storing the given ParserEnvironment
for parse-time access to the
environment.
environment
- The environment settings to attach to the Parser.public final Item parse(String queryToParse, String filterToParse, com.yahoo.language.Language parsingLanguage, IndexFacts.Session indexFacts, String defaultIndexName)
parse
in interface CustomParser
private Item parse(String queryToParse, String filterToParse, com.yahoo.language.Language parsingLanguage, IndexFacts.Session indexFacts, String defaultIndexName, Parsable parsable)
private String generateLanguageDetectionTextFrom(TokenPosition tokens, IndexFacts.Session indexFacts, String defaultIndex)
private boolean is(Token.Kind kind, Token tokenOrNull)
protected abstract Item parseItems()
private static void assignDefaultIndex(String defaultIndex, Item item)
defaultIndex
- The default index to assign.item
- The item to check.protected String normalize(String input)
input
- The string to normalize.protected void setState(com.yahoo.language.Language queryLanguage, IndexFacts.Session indexFacts)
protected void tokenize(String query, String defaultIndexName, IndexFacts.Session indexFacts, com.yahoo.language.Language language)
query
- the string to tokenize.defaultIndexName
- the name of the index to use as default.indexFacts
- resolved information about the index we are searchinglanguage
- the language set for this query, or null if nonepublic static Item simplifyPhrases(Item unwashed)
unwashed
- The item whose phrases to simplify.private static Item collapsePhrase(PhraseItem phrase)
Copyright © 2018. All rights reserved.