-
Notifications
You must be signed in to change notification settings - Fork 0
/
QrySopOr.java
51 lines (44 loc) · 1.44 KB
/
QrySopOr.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
/**
* Copyright (c) 2016, Carnegie Mellon University. All Rights Reserved.
*/
import java.io.*;
/**
* The OR operator for all retrieval models.
*/
public class QrySopOr extends QrySop {
/**
* 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.docIteratorHasMatchMin (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 OR operator.");
}
}
/**
* getScore for the UnrankedBoolean retrieval model.
* @param r The retrieval model that determines how scores are calculated.
* @return The document score.
* @throws IOException Error accessing the Lucene index
*/
private double getScoreUnrankedBoolean (RetrievalModel r) throws IOException {
if (! this.docIteratorHasMatchCache()) {
return 0.0;
} else {
return 1.0;
}
}
}