|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.unimi.dsi.mg4j.query.parser.SimpleParser
public class SimpleParser
A simple parser that transform a query string into a query.
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.dsi.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.
Field Summary | |
---|---|
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
|
Fields inherited from interface it.unimi.dsi.mg4j.query.parser.SimpleParserConstants |
---|
ALIGN, AND, CLOSE_ENLARGE, CLOSE_PAREN, CLOSE_RANGE, COLON, DEFAULT, EOF, HOLE, INTERVAL_SEPARATOR, MINUS, NOT, OAND, OPEN_ENLARGE, OPEN_PAREN, OPEN_RANGE, OR, PLUS, PREFIX, QUOTE, SHARP, TILDA, tokenImage, WORD |
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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()
|
void |
disable_tracing()
|
void |
enable_tracing()
|
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(String text)
Parses the given query, returning the corresponding query result. |
Query |
query(String indexAlias)
Starting rule for a difference query. |
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)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public Set<String> indices
public String defaultIndex
public Map<String,? extends TermProcessor> termProcessors
public SimpleParserTokenManager token_source
public Token token
public Token jj_nt
public boolean lookingAhead
Constructor Detail |
---|
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)
Method Detail |
---|
public SimpleParser copy()
copy
in interface FlyweightPrototype<QueryParser>
copy
in interface QueryParser
public Query parse(String text) throws QueryParserException
parse
in interface QueryParser
text
- the query to be parsed.
query
.
QueryParserException
- if a parse exception has taken place during query parsing.
TokenMgrError
- if a tokenization exception has taken place during query parsing.public final Query query(String indexAlias) throws ParseException
indexAlias
- the index alias for the default index to be used for the query that is going to be parsed.
ParseException
public 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.
ParseException
public 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.
ParseException
public 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.
ParseException
public 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.
ParseException
public 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.
ParseException
public 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.
ParseException
public 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.
ParseException
public 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.
ParseException
public 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()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |