gate.creole.annic.lucene
Class LuceneSearcher

java.lang.Object
  extended by gate.creole.annic.lucene.LuceneSearcher
All Implemented Interfaces:
Searcher

public class LuceneSearcher
extends Object
implements Searcher

This class provides the Searching functionality for annic.

Author:
niraj

Field Summary
 Map<String,List<String>> annotationTypesMap
          Found annotation types in the annic patterns.
 
Constructor Summary
LuceneSearcher()
           
 
Method Summary
 void addQueryTokens(String query, List<String> queryTokens)
          Adds the query tokens for the given query.
 void exportResults(File outputFile)
          This method allow exporting results in to the provided file.
 int freq(List<Hit> patternsToSearchIn, String annotationType, boolean inMatchedSpan, boolean inContext)
           
 int freq(List<Hit> patternsToSearchIn, String annotationType, String feature, String value, boolean inMatchedSpan, boolean inContext)
           
 int freq(String corpusToSearchIn, String annotationSetToSearchIn, String annotationType)
           
 int freq(String corpusToSearchIn, String annotationSetToSearchIn, String annotationType, String featureName)
           
 int freq(String corpusToSearchIn, String annotationSetToSearchIn, String annotationType, String featureName, String value)
           
 Map<String,Integer> freqForAllValues(List<Hit> patternsToSearchIn, String annotationType, String feature, boolean inMatchedSpan, boolean inContext)
           
 Map<String,List<String>> getAnnotationTypesMap()
          Gets the map of found annotation types and annotation features.
 Integer getContextWindow()
          Gets the number of base token annotations to show in the context.
 Hit[] getHits()
          Gets the found hits (annic patterns).
 String[] getIndexedAnnotationSetNames()
          This method returns a set of annotation set names that are indexed.
 Map<String,Object> getParameters()
          Gets the search parameters set by user.
 String getQuery()
          Gets the submitted query.
 List<String> getQueryTokens(String query)
          Gets the query tokens for the given query.
 Hit[] next(int numberOfHits)
          Return the next numberOfHits -1 indicates all
 boolean search(String query, Map<String,Object> parameters)
          Method retunrs true/false indicating whether results were found or not.
 void setLuceneDatastore(LuceneDataStoreImpl datastore)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

annotationTypesMap

public Map<String,List<String>> annotationTypesMap
Found annotation types in the annic patterns. The maps keeps record of found annotation types and features for each of them.

Constructor Detail

LuceneSearcher

public LuceneSearcher()
Method Detail

next

public Hit[] next(int numberOfHits)
           throws SearchException
Return the next numberOfHits -1 indicates all

Specified by:
next in interface Searcher
Throws:
SearchException

search

public boolean search(String query,
                      Map<String,Object> parameters)
               throws SearchException
Method retunrs true/false indicating whether results were found or not.

Specified by:
search in interface Searcher
Throws:
SearchException

getQuery

public String getQuery()
Gets the submitted query.

Specified by:
getQuery in interface Searcher

getContextWindow

public Integer getContextWindow()
Gets the number of base token annotations to show in the context.


getHits

public Hit[] getHits()
Gets the found hits (annic patterns).

Specified by:
getHits in interface Searcher

getAnnotationTypesMap

public Map<String,List<String>> getAnnotationTypesMap()
Gets the map of found annotation types and annotation features. This call must be invoked only after a call to the getIndexedAnnotationSetNames(String indexLocation) method. Otherwise this method doesn't guranttee the correct results. The results obtained has the following format. Key: CorpusName;AnnotationSetName;AnnotationType Value: respective features

Specified by:
getAnnotationTypesMap in interface Searcher

getIndexedAnnotationSetNames

public String[] getIndexedAnnotationSetNames()
                                      throws SearchException
This method returns a set of annotation set names that are indexed. Each entry has the following format:

corpusName;annotationSetName

where, the corpusName is the name of the corpus the annotationSetName belongs to.

Specified by:
getIndexedAnnotationSetNames in interface Searcher
Throws:
SearchException

getParameters

public Map<String,Object> getParameters()
Gets the search parameters set by user.

Specified by:
getParameters in interface Searcher

getQueryTokens

public List<String> getQueryTokens(String query)
Gets the query tokens for the given query.


addQueryTokens

public void addQueryTokens(String query,
                           List<String> queryTokens)
Adds the query tokens for the given query.


exportResults

public void exportResults(File outputFile)
This method allow exporting results in to the provided file. This method has not been implemented yet.

Specified by:
exportResults in interface Searcher

freq

public int freq(String corpusToSearchIn,
                String annotationSetToSearchIn,
                String annotationType,
                String featureName,
                String value)
         throws SearchException
Specified by:
freq in interface Searcher
Throws:
SearchException

freq

public int freq(String corpusToSearchIn,
                String annotationSetToSearchIn,
                String annotationType)
         throws SearchException
Specified by:
freq in interface Searcher
Throws:
SearchException

freq

public int freq(String corpusToSearchIn,
                String annotationSetToSearchIn,
                String annotationType,
                String featureName)
         throws SearchException
Specified by:
freq in interface Searcher
Throws:
SearchException

freq

public int freq(List<Hit> patternsToSearchIn,
                String annotationType,
                String feature,
                String value,
                boolean inMatchedSpan,
                boolean inContext)
         throws SearchException
Specified by:
freq in interface Searcher
Throws:
SearchException

freq

public int freq(List<Hit> patternsToSearchIn,
                String annotationType,
                boolean inMatchedSpan,
                boolean inContext)
         throws SearchException
Specified by:
freq in interface Searcher
Throws:
SearchException

freqForAllValues

public Map<String,Integer> freqForAllValues(List<Hit> patternsToSearchIn,
                                            String annotationType,
                                            String feature,
                                            boolean inMatchedSpan,
                                            boolean inContext)
                                     throws SearchException
Specified by:
freqForAllValues in interface Searcher
Throws:
SearchException

setLuceneDatastore

public void setLuceneDatastore(LuceneDataStoreImpl datastore)