-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwordWeight.java
47 lines (39 loc) · 1.16 KB
/
wordWeight.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
package com.company;
import javax.annotation.Nonnull;
import org.lemurproject.galago.core.retrieval.prf.WeightedTerm;
import org.lemurproject.galago.utility.lists.Scored;
// This class is copied from RelevanceModel1 in Galago!
public class wordWeight extends WeightedTerm {
// implementation of weighted term (term, score) pairs
public String term;
public wordWeight(String t) {
this(t, 0.0);
}
public wordWeight(String term, double score) {
super(score);
this.term = term;
}
@Override
public String getTerm() {
return term;
}
// The secondary sort is to have defined behavior for statistically tied samples.
@Override
public int compareTo(@Nonnull WeightedTerm other) {
wordWeight that = (wordWeight) other;
int result = -Double.compare(this.score, that.score);
if (result != 0) {
return result;
}
result = (this.term.compareTo(that.term));
return result;
}
@Override
public String toString() {
return "<" + term + "," + score + ">";
}
@Override
public Scored clone(double score) {
return new wordWeight(this.term, score);
}
}