public class SimpleParser extends Object implements QueryParser, SimpleParserConstants
The parser supports multiple indices. You must provide a set of
index aliases that the user will use to select indices, and the name of the default index
alias to be used. After that, you parse a query by using the parse(String) method.
The parser generated by JavaCC for this class will break terms using operators and
nonspace-to-space transitions. Operators can be included in terms, if needed, using
the backslash, which acts as an escape character, and makes the next character
(usually an operator) a standard character. The syntax of the parser can be seen in action
in the documentation of the package it.unimi.di.big.mg4j.search.
The parser returns a Query—an abstract
representation of the query string that can be turned later into a
DocumentIterator.
If a TermProcessor is specified, it will be applied to the terms found in the
query string. This can lead to transformations (e.g., downcasing) or generate an exception
if the query string contains terms filtered by the term processor.
| Modifier and Type | Field and Description |
|---|---|
String |
defaultIndex
The default index alias.
|
Set<String> |
indices
The set of index aliases.
|
Token |
jj_nt |
boolean |
lookingAhead |
Map<String,? extends TermProcessor> |
termProcessors
The term processor for each index.
|
Token |
token |
SimpleParserTokenManager |
token_source |
ALIGN, AND, ANNO, CLOSE_ENLARGE, CLOSE_PAREN, CLOSE_RANGE, CLOSE_REMAP, CLOSE_WEIGHT, COLON, DEFAULT, EOF, FALSE, HOLE, INTERVAL_SEPARATOR, MINUS, NOT, OAND, OPEN_ENLARGE, OPEN_PAREN, OPEN_RANGE, OPEN_REMAP, OPEN_WEIGHT, OR, PLUS, PREFIX, QUOTE, REMAP, SEMICOLON, SHARP, TILDA, tokenImage, TRUE, WORD| Constructor and Description |
|---|
SimpleParser()
Creates a parser for a single nameless index with no term processing.
|
SimpleParser(InputStream stream) |
SimpleParser(InputStream stream,
String encoding) |
SimpleParser(Reader stream) |
SimpleParser(Set<String> indices,
String defaultIndex)
Creates a parser with no term processing.
|
SimpleParser(Set<String> indices,
String defaultIndex,
Map<String,? extends TermProcessor> termProcessors)
Creates a parser.
|
SimpleParser(SimpleParserTokenManager tm) |
SimpleParser(TermProcessor termProcessor)
Creates a parser for a single nameless index with a given term processor.
|
| Modifier and Type | Method and Description |
|---|---|
Query |
alignQuery(String indexAlias)
Starting rule for an alignment query.
|
Query |
andQuery(String indexAlias)
Starting rule for an AND-query (the AND token is optional).
|
Query |
atomicQuery(String indexAlias)
Starting rule for an atomic query.
|
Query |
atomicSimpleQuery(String indexAlias)
Starting rule for an atomic simple query.
|
SimpleParser |
copy() |
Query |
differenceQuery(String indexAlias)
Starting rule for a difference query.
|
void |
disable_tracing() |
void |
enable_tracing() |
MutableString |
escape(MutableString token)
Escapes the provided mutable string, making it into a text token.
|
String |
escape(String token)
Escapes the provided string, making it into a text token.
|
ParseException |
generateParseException() |
Token |
getNextToken() |
Token |
getToken(int index) |
Query |
multiTermQuery(String indexAlias)
Starting rule for a multiterm query.
|
Query |
orderedAndQuery(String indexAlias)
Starting rule for an AND<-query.
|
Query |
orQuery(String indexAlias)
Starting rule for a OR-query.
|
Query |
parse(MutableString text)
Turns the given query mutable string into a composite
Query object. |
Query |
parse(String text)
Turns the given query string into a composite
Query object. |
Query |
query(String indexAlias)
Parser.
|
Query |
quotedQuery(String indexAlias)
Starting rule for a quoted query.
|
void |
ReInit(InputStream stream) |
void |
ReInit(InputStream stream,
String encoding) |
void |
ReInit(Reader stream) |
void |
ReInit(SimpleParserTokenManager tm) |
Query |
remappedQuery(String indexAlias)
Starting rule for a remapped query.
|
public String defaultIndex
public Map<String,? extends TermProcessor> termProcessors
public SimpleParserTokenManager token_source
public Token token
public Token jj_nt
public boolean lookingAhead
public SimpleParser(Set<String> indices, String defaultIndex, Map<String,? extends TermProcessor> termProcessors)
indices - the set of index aliases.defaultIndex - the default index alias to be used when parsing the query.termProcessors - a map from index aliases to the corresponding term processor, or null
for no term processing.public SimpleParser(Set<String> indices, String defaultIndex)
indices - the set of index aliases.defaultIndex - the default index alias to be used when parsing the query.public SimpleParser()
Parsers created by this constructor allow only nameless access, both in the query and in the interval-iterator methods.
public SimpleParser(TermProcessor termProcessor)
Parsers created by this constructor allow only nameless access, both in the query and in the interval-iterator methods.
public SimpleParser(InputStream stream)
public SimpleParser(InputStream stream, String encoding)
public SimpleParser(Reader stream)
public SimpleParser(SimpleParserTokenManager tm)
public SimpleParser copy()
copy in interface FlyweightPrototype<QueryParser>public String escape(String token)
QueryParserescape in interface QueryParsertoken - a wannabe text token (maybe containing special characters, but no character below code 32).token that will be interpreted
as a text token by this parser.public MutableString escape(MutableString token)
QueryParserescape in interface QueryParsertoken - a wannabe text token (maybe containing special characters, but no character below code 32).token, escaped so that it will be interpreted
as a text token by this parser.public Query parse(String text) throws QueryParserException
QueryParserQuery object.parse in interface QueryParsertext - a string representing a query.QueryParserExceptionpublic Query parse(MutableString text) throws QueryParserException
QueryParserQuery object.parse in interface QueryParsertext - a mutable string representing a query.QueryParserExceptionpublic final Query query(String indexAlias) throws ParseException
ParseExceptionpublic final Query remappedQuery(String indexAlias) throws ParseException
indexAlias - the index alias for the default index to be used for the query that is going to be parsed.ParseExceptionpublic final Query differenceQuery(String indexAlias) throws ParseException
indexAlias - the index alias for the default index to be used for the query that is going to be parsed.ParseExceptionpublic final Query orQuery(String indexAlias) throws ParseException
indexAlias - the index alias for the default index to be used for the query that is going to be parsed.ParseExceptionpublic final Query andQuery(String indexAlias) throws ParseException
indexAlias - the index alias for the default index to be used for the query that is going to be parsed.ParseExceptionpublic final Query orderedAndQuery(String indexAlias) throws ParseException
indexAlias - the index alias for the default index to be used for the query that is going to be parsed.ParseExceptionpublic final Query alignQuery(String indexAlias) throws ParseException
indexAlias - the index alias for the default index to be used for the query that is going to be parsed.ParseExceptionpublic final Query multiTermQuery(String indexAlias) throws ParseException
indexAlias - the index alias for the default index to be used for the query that is going to be parsed.ParseExceptionpublic final Query quotedQuery(String indexAlias) throws ParseException
indexAlias - the index alias for the default index to be used for the query that is going to be parsed.ParseExceptionpublic final Query atomicQuery(String indexAlias) throws ParseException
indexAlias - the index alias for the default index to be used for the query that is going to be parsed.ParseExceptionpublic final Query atomicSimpleQuery(String indexAlias) throws ParseException
indexAlias - the index alias for the default index to be used for the query that is going to be parsed.ParseExceptionpublic void ReInit(InputStream stream)
public void ReInit(InputStream stream, String encoding)
public void ReInit(Reader stream)
public void ReInit(SimpleParserTokenManager tm)
public final Token getNextToken()
public final Token getToken(int index)
public ParseException generateParseException()
public final void enable_tracing()
public final void disable_tracing()