-
Notifications
You must be signed in to change notification settings - Fork 0
/
QrySopScore.java
71 lines (61 loc) · 2.14 KB
/
QrySopScore.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* Copyright (c) 2016, Carnegie Mellon University. All Rights Reserved.
*/
import java.io.*;
import java.lang.IllegalArgumentException;
/**
* The SCORE operator for all retrieval models.
*/
public class QrySopScore extends QrySop {
/**
* Document-independent values that should be determined just once.
* Some retrieval models have these, some don't.
*/
/**
* Indicates whether the query has a match.
* @param r The retrieval model that determines what is a match
* @return True if the query matches, otherwise false.
*/
public boolean docIteratorHasMatch (RetrievalModel r) {
return this.docIteratorHasMatchFirst (r);
}
/**
* Get a score for the document that docIteratorHasMatch matched.
* @param r The retrieval model that determines how scores are calculated.
* @return The document score.
* @throws IOException Error accessing the Lucene index
*/
public double getScore (RetrievalModel r) throws IOException {
if (r instanceof RetrievalModelUnrankedBoolean) {
return this.getScoreUnrankedBoolean (r);
} else {
throw new IllegalArgumentException
(r.getClass().getName() + " doesn't support the SCORE operator.");
}
}
/**
* getScore for the Unranked retrieval model.
* @param r The retrieval model that determines how scores are calculated.
* @return The document score.
* @throws IOException Error accessing the Lucene index
*/
public double getScoreUnrankedBoolean (RetrievalModel r) throws IOException {
if (! this.docIteratorHasMatchCache()) {
return 0.0;
} else {
return 1.0;
}
}
/**
* Initialize the query operator (and its arguments), including any
* internal iterators. If the query operator is of type QryIop, it
* is fully evaluated, and the results are stored in an internal
* inverted list that may be accessed via the internal iterator.
* @param r A retrieval model that guides initialization
* @throws IOException Error accessing the Lucene index.
*/
public void initialize (RetrievalModel r) throws IOException {
Qry q = this.args.get (0);
q.initialize (r);
}
}