gate.creole.annic.lucene
Class SubQueryParser

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

public class SubQueryParser
extends Object

This class behaves as a helper class to the QueryParser and provides various methods which are called from various methods of QueryParser.

Author:
niraj

Constructor Summary
SubQueryParser()
           
 
Method Summary
private static ArrayList<String> duplicate(ArrayList<String> queries, String s, int dupliSize, int no)
          This is a helper method that helps in duplicating the provided tokens.
private static String extractWildcards(String query)
          This method, interprets the wild cards and convert query accordingly.
private static int findBracketClosingPosition(int startFrom, String query)
          Returns the position of a closing bracket.
static ArrayList<String> findOrTokens(String query)
          This method given a query identifies the OR Tokens for eg.
private static String findWildCardString(int brClPos, String query)
          Method retrieves wild card characters after the closing bracket.
private static boolean isClosingBracket(char ch, char pre)
          Returns if the character is bracket used to mark boundary of a token or an escape character.
private static boolean isOpenBracket(char ch, char pre)
          Returns if the character is bracket used to mark boundary of a token or an escape character.
private static boolean isOrSym(char ch, char pre)
          Returns if the character is an OR symbol used as a logical operator or an escape character.
static void main(String[] args)
           
static ArrayList<String> parseQuery(String q1)
          this method parses the query and returns the different queries converted into the OR normalized form for e.g.
static boolean scanQueryForOrOrBracket(String query)
          This method checks if query has either | or ( in it.
private static ArrayList<String> writeCharInAll(char c, int no, ArrayList<String> queries)
          Helps in duplicating a character in the provided queries
private static ArrayList<String> writeStringInAll(String c, int no, ArrayList<String> queries)
          Helps in duplicating a string in the provided queries
private static ArrayList<String> writeTokens(ArrayList<String> tokens, ArrayList<String> queries, int dupliSize)
          This is a helper method that helps in duplicating the provided tokens.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubQueryParser

public SubQueryParser()
Method Detail

main

public static void main(String[] args)

findWildCardString

private static String findWildCardString(int brClPos,
                                         String query)
Method retrieves wild card characters after the closing bracket.

Parameters:
brClPos -
query -
Returns:

extractWildcards

private static String extractWildcards(String query)
                                throws SearchException
This method, interprets the wild cards and convert query accordingly. For example: (A)+3 is converted into ((A) | ((A)(A)) | ((A)(A)(A)))

Parameters:
query -
Returns:
Throws:
SearchException

parseQuery

public static ArrayList<String> parseQuery(String q1)
                                    throws SearchException
this method parses the query and returns the different queries converted into the OR normalized form for e.g. ({A}|{B}){C} this will be converted into ({A}{C}) | ({B}{C}) and the arrayList consists of 1. {A}{C} 2. {B}{C}

Parameters:
q1 -
Returns:
Throws:
SearchException

scanQueryForOrOrBracket

public static boolean scanQueryForOrOrBracket(String query)
This method checks if query has either | or ( in it.

Parameters:
query -
Returns:

writeTokens

private static ArrayList<String> writeTokens(ArrayList<String> tokens,
                                             ArrayList<String> queries,
                                             int dupliSize)
This is a helper method that helps in duplicating the provided tokens.

Parameters:
tokens -
queries -
dupliSize -
Returns:

duplicate

private static ArrayList<String> duplicate(ArrayList<String> queries,
                                           String s,
                                           int dupliSize,
                                           int no)
This is a helper method that helps in duplicating the provided tokens.


findOrTokens

public static ArrayList<String> findOrTokens(String query)
This method given a query identifies the OR Tokens for eg. {A} | ({B}{C}) then {A} and ({B}{C}) so basically findOrTokens find out all the tokens around | operator

Parameters:
query -
Returns:

findBracketClosingPosition

private static int findBracketClosingPosition(int startFrom,
                                              String query)
Returns the position of a closing bracket.

Parameters:
startFrom -
query -
Returns:

writeCharInAll

private static ArrayList<String> writeCharInAll(char c,
                                                int no,
                                                ArrayList<String> queries)
Helps in duplicating a character in the provided queries

Parameters:
c -
no -
queries -
Returns:

writeStringInAll

private static ArrayList<String> writeStringInAll(String c,
                                                  int no,
                                                  ArrayList<String> queries)
Helps in duplicating a string in the provided queries

Parameters:
c -
no -
queries -
Returns:

isOpenBracket

private static boolean isOpenBracket(char ch,
                                     char pre)
Returns if the character is bracket used to mark boundary of a token or an escape character.

Parameters:
ch -
pre -
Returns:

isClosingBracket

private static boolean isClosingBracket(char ch,
                                        char pre)
Returns if the character is bracket used to mark boundary of a token or an escape character.

Parameters:
ch -
pre -
Returns:

isOrSym

private static boolean isOrSym(char ch,
                               char pre)
Returns if the character is an OR symbol used as a logical operator or an escape character.

Parameters:
ch -
pre -
Returns: