001 /*
002 * LuceneQueryResult.java
003 *
004 * Niraj Aswani, 19/March/07
005 *
006 * $Id: LuceneQueryResult.html,v 1.0 2007/03/19 16:22:01 niraj Exp $
007 */
008 package gate.creole.annic.lucene;
009
010 import gate.creole.annic.PatternAnnotation;
011
012 import java.util.ArrayList;
013 import java.util.List;
014
015 /**
016 * This class
017 *
018 * @author niraj
019 */
020 public class LuceneQueryResult {
021
022 /** Persistance document ID. */
023 private Object docID;
024
025 private String annotationSetName;
026
027 private List firstTermPositions;
028
029 private List<Integer> patternLength;
030
031 private int queryType;
032
033 private List<List<PatternAnnotation>> gateAnnotations;
034
035 private String query;
036
037 /**
038 * Constructor
039 *
040 * @param docID - ID of the document
041 * @param firstTermPositions - Position of the first terms
042 * @param patternLength
043 * @param queryType
044 * @param gateAnnotations
045 * @param query
046 */
047 public LuceneQueryResult(Object docID, String annotationSetName, List firstTermPositions,
048 List<Integer> patternLength, int queryType, List<List<PatternAnnotation>> gateAnnotations,
049 String query) {
050 this.docID = docID;
051 this.annotationSetName = annotationSetName;
052 this.firstTermPositions = firstTermPositions;
053 this.patternLength = patternLength;
054 this.queryType = queryType;
055 this.gateAnnotations = gateAnnotations;
056 this.query = query;
057 }
058
059 /**
060 * @return the type of query used for this result 1 - Phrase Query 0 -
061 * Term Query For the termQueries firstTermPositions instead
062 * of holding positions, has an ArrayList with two values Term
063 * Text (1st value = anntotation Text) and Term Type (2nd
064 * Value = Annotation Type)
065 */
066 public int getQueryType() {
067 return queryType;
068 }
069
070 /** @return persistance document ID. */
071 public Object getDocumentID() {
072 return docID;
073 }
074
075 /**
076 * @return if the query type is 0, firstTermPositions, instead of
077 * holding positions, contain the string values. element at
078 * position 0: Term Text (annotation text), element at
079 * position 1: Term Type (annotation type), position 2:
080 * annotation text, position 3: annotation type and so on. If
081 * the query type is anything other than 0, it contains
082 * Integer values indicating positions of first annotations of
083 * found patterns in the token stream.
084 */
085 public List getFirstTermPositions() {
086 return firstTermPositions;
087 }
088
089 /**
090 * Returns an arraylist which for each pattern contains a number of
091 * annotation in it.
092 *
093 * @return
094 */
095 public List<Integer> patternLength() {
096 return patternLength;
097 }
098
099 /**
100 * Gets the GateAnnotations for each pattern.
101 * @return
102 */
103 public List<List<PatternAnnotation>> getGateAnnotations() {
104 return this.gateAnnotations;
105 }
106
107 /**
108 * Returns the main query.
109 * @return
110 */
111 public String getQuery() {
112 return this.query;
113 }
114
115 /**
116 * Gets the annotation set Name for this result
117 * @return
118 */
119 public String getAnnotationSetName() {
120 return annotationSetName;
121 }
122 }
|