001 /*
002 * Searcher.java
003 *
004 * Niraj Aswani, 19/March/07
005 *
006 * $Id: Searcher.html,v 1.0 2007/03/19 16:22:01 niraj Exp $
007 */
008 package gate.creole.annic;
009
010 import java.io.File;
011 import java.util.List;
012 import java.util.Map;
013
014 /**
015 * Searcher interface.
016 * @author niraj
017 *
018 */
019 public interface Searcher {
020
021 /**
022 * Search method that allows searching
023 *
024 * @param query
025 * @param numberOfPatterns
026 * @param patternWindow
027 * @return
028 * @throws SearchException
029 */
030 public boolean search(String query, Map<String, Object> parameters) throws SearchException;
031
032 /**
033 * Query to search
034 *
035 * @return
036 */
037 public String getQuery();
038
039 /**
040 * Return the next numberOfHits -1 indicates all
041 *
042 * @return
043 */
044 public Hit[] next(int numberOfHits) throws SearchException;
045
046
047 /**
048 * Returns the Map containing all possible values of AnnotationTypes
049 * and Feature Values for each of this annotationType. This call must only be invoked
050 * after a call to the getIndexedAnnotationSetNames(String indexLocation) method.
051 * Otherwise this method doesn't guranttee the correct results.
052 * The results obtained has the following format.
053 * Key: CorpusName;AnnotationSetName;AnnotationType
054 * Value: respective features
055 * @return
056 */
057 public Map<String, List<String>> getAnnotationTypesMap();
058
059
060 /**
061 * Returns an containing names of the indexed annotation sets
062 * * Each entry has the following format:
063 * <p>corpusName;annotationSetName</p>
064 * where, the corpusName is the name of the corpus the annotationSetName belongs to.
065 * @param indexLocation
066 * @return
067 * @throws SearchException
068 */
069 public String[] getIndexedAnnotationSetNames() throws SearchException;
070
071 /**
072 * Returns the recently set parameters
073 *
074 * @return
075 */
076 public Map<String, Object> getParameters();
077
078 /**
079 * This method can be used for exporting results
080 *
081 * @param outputFile
082 */
083 public void exportResults(File outputFile);
084
085 /**
086 * return the last seen hits once again
087 *
088 * @return
089 */
090 public Hit[] getHits();
091
092 /**
093 * @see StatsCalculator#freq(String, String, String, String, String)
094 */
095 public int freq(String corpusToSearchIn,
096 String annotationSetToSearchIn, String annotationType,
097 String featureName, String value) throws SearchException;
098
099 /**
100 * @see StatsCalculator#freq(String, String, String, String, String)
101 */
102 public int freq(String corpusToSearchIn,
103 String annotationSetToSearchIn, String annotationType)
104 throws SearchException;
105
106 /**
107 * @see StatsCalculator#freq(String, String, String, String, String)
108 */
109 public int freq(String corpusToSearchIn,
110 String annotationSetToSearchIn, String annotationType,
111 String featureName) throws SearchException;
112
113 /**
114 * @see StatsCalculator#freq(List<Hit>, String, String, String, boolean, boolean)
115 */
116 public int freq(List<Hit> patternsToSearchIn,
117 String annotationType, String feature, String value,
118 boolean inMatchedSpan, boolean inContext) throws SearchException;
119
120 /**
121 * @see StatsCalculator#freq(List<Hit>, String, String, String, boolean, boolean)
122 */
123 public int freq(List<Hit> patternsToSearchIn,
124 String annotationType, boolean inMatchedSpan, boolean inContext) throws SearchException;
125
126 /**
127 * @see StatsCalculator#freq(List<Hit>, String, String, boolean, boolean)
128 */
129 public Map<String, Integer> freqForAllValues(
130 List<Hit> patternsToSearchIn, String annotationType,
131 String feature, boolean inMatchedSpan, boolean inContext)
132 throws SearchException;
133
134 }
|