gate.creole.annic.lucene
Class PatternValidator

java.lang.Object
  extended by gate.creole.annic.lucene.PatternValidator

public class PatternValidator
extends Object

Pattern Validator that given a position of first term, retrieves the entire pattern from the token stream. If it is not able to retrieve the entire pattern, the class reports it as an invalid pattern.

Author:
niraj

Field Summary
private  int AND
          AND operator
private  int index
           
private  int NOT
          Negation operator
private  int OR
          OR operator
private  int patLen
           
 
Constructor Summary
PatternValidator()
           
 
Method Summary
 int getPatternLength()
          Gets the length of the pattern.
private  boolean isEqual(Token tk, Term term)
          Checks whether two terms are equal.
 int validate(List<String> queryTokens, List<Token> annotations, int from, QueryParser queryParser)
          This method takes two parameters the actual query issued and annotations in which it checks if the annotations exist that are validating for the given query
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AND

private final int AND
AND operator

See Also:
Constant Field Values

OR

private final int OR
OR operator

See Also:
Constant Field Values

NOT

private final int NOT
Negation operator

See Also:
Constant Field Values

index

private int index

patLen

private int patLen
Constructor Detail

PatternValidator

public PatternValidator()
Method Detail

getPatternLength

public int getPatternLength()
Gets the length of the pattern.

Returns:

validate

public int validate(List<String> queryTokens,
                    List<Token> annotations,
                    int from,
                    QueryParser queryParser)
             throws SearchException
This method takes two parameters the actual query issued and annotations in which it checks if the annotations exist that are validating for the given query

Parameters:
query - String
annotations - ArrayList
Returns:
int positive number indicates the offset of the last annotation of the pattern. -1 indicates invalid pattern.
Throws:
SearchException

isEqual

private boolean isEqual(Token tk,
                        Term term)
Checks whether two terms are equal.

Parameters:
tk -
term -
Returns: