-
Notifications
You must be signed in to change notification settings - Fork 0
/
QryIopTerm.java
54 lines (48 loc) · 1.5 KB
/
QryIopTerm.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* Copyright (c) 2016, Carnegie Mellon University. All Rights Reserved.
*/
import java.io.*;
import java.util.*;
/**
* The TERM operator for all retrieval models. The TERM operator stores
* information about a query term, for example "apple" in the query
* "#AND (apple pie). Although it may seem odd to use a query
* operator to store a term, doing so makes it easy to build
* structured queries with nested query operators.
*
*/
public class QryIopTerm extends QryIop {
private String term;
/**
* The term is assumed to match the body field.
* @param termString A term string.
*/
public QryIopTerm(String termString) {
this.term = termString;
this.field = "body"; // Default field if none is specified.
}
/**
* The term matches in the specified field.
* @param termString A term string.
* @param fieldString A field string.
*/
public QryIopTerm(String termString, String fieldString) {
this.term = termString;
this.field = fieldString;
}
/**
* Evaluate the query operator; the result is an internal inverted
* list that may be accessed via the internal iterators.
* @throws IOException Error accessing the Lucene index.
*/
protected void evaluate () throws IOException {
this.invertedList = new InvList(this.term, this.field);
}
/**
* Get a string version of this query operator.
* @return The string version of this query operator.
*/
public String toString(){
return (this.term + "." + this.field);
}
}