-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwResult.java
40 lines (34 loc) · 1.22 KB
/
wResult.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
package com.company;
import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.List;
import org.lemurproject.galago.core.retrieval.ScoredDocument;
public class wResult {
private PrintStream out;
public wResult (String outputFileName, boolean append) throws UnsupportedEncodingException, FileNotFoundException{
out = new PrintStream(new BufferedOutputStream(new FileOutputStream(outputFileName, append)), true, "UTF-8");
}
public wResult (){
out = System.out;
}
public void write (String queryNumber, List<ScoredDocument> results, boolean trecFormat) {
if (!results.isEmpty()) {
for (ScoredDocument sd : results) {
if (trecFormat) {
out.println(sd.toTRECformat(queryNumber));
} else {
out.println(sd.toString(queryNumber));
}
}
}
}
public void write (String queryNumber, List<ScoredDocument> results) {
write(queryNumber, results, true);
}
public void close (){
out.close();
}
}