Skip to content

Commit

Permalink
Improves debug messages and usability of Experiment classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Michel Oleynik committed Jul 14, 2017
1 parent 1314087 commit d96a205
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/main/java/at/medunigraz/imi/bst/trec/RunnerDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ public static void main(String[] args) {
Query pmDecorator = new WordRemovalQueryDecorator(
new TemplateQueryDecorator(pmTemplate, new ElasticSearchQuery("trec")));

bestExperiments.add(new Experiment().withId("example-pmid").withDecorator(pmDecorator));
bestExperiments.add(new Experiment().withId("extra-pmid").withDecorator(pmDecorator));
bestExperiments.add(new Experiment().withId("topics2017-pmid").withDecorator(pmDecorator));
bestExperiments.add(Experiment.create().withId("example-pmid").withDecorator(pmDecorator));
bestExperiments.add(Experiment.create().withId("extra-pmid").withDecorator(pmDecorator));
bestExperiments.add(Experiment.create().withId("topics2017-pmid").withDecorator(pmDecorator));


final File ctTemplate = new File(RunnerDemo.class.getResource("/templates/baseline-ct.json").getFile());
Query ctDecorator = new TemplateQueryDecorator(ctTemplate, new ElasticSearchQuery("clinicaltrials"));

bestExperiments.add(new Experiment().withId("extra-ct").withDecorator(ctDecorator));
bestExperiments.add(Experiment.create().withId("extra-ct").withDecorator(ctDecorator));


for (Experiment exp : bestExperiments) {
Expand All @@ -40,9 +40,9 @@ public static void main(String[] args) {
e.printStackTrace();
}
}

for (Experiment exp : bestExperiments) {

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ public class Experiment extends Thread {
private String id;
private Query decorator;

public Experiment() {
private Experiment() {
}

public static Experiment create() {
return new Experiment();
}

public static Experiment create(Experiment base) {
return new Experiment().withId(base.id).withDecorator(base.decorator);
}

public Experiment withId(String id) {
Expand All @@ -41,8 +49,10 @@ public Experiment withDecorator(Query decorator) {
@Override
public void run() {
final String collection = id.substring(0, id.indexOf('-'));

final String name = id + " with decorator " + decorator.getName();

LOG.info("Running collection '" + id + "'...");
LOG.info("Running collection " + name + "...");

File example = new File(CSVStatsWriter.class.getResource("/topics/" + collection + ".xml").getPath());
TopicSet topicSet = new TopicSet(example);
Expand All @@ -66,17 +76,15 @@ public void run() {
File goldStandard = new File(CSVStatsWriter.class.getResource("/gold-standard/" + id + ".qrels").getPath());
TrecEval te = new TrecEval(goldStandard, output);

LOG.debug("NDCG: " + te.getNDCG());
LOG.trace(te.getMetricsByTopic("all"));

XMLStatsWriter xsw = new XMLStatsWriter(new File("stats/" + id + ".xml"));
xsw.write(te.getMetrics());
xsw.close();

CSVStatsWriter csw = new CSVStatsWriter(new File("stats/" + id + ".csv"));
csw.write(te.getMetrics());
csw.close();

LOG.info("Collection '" + id + "' finished.");

LOG.info("Collection " + name + " finished. NDCG: " + te.getNDCG());
LOG.trace(te.getMetricsByTopic("all"));
}
}

0 comments on commit d96a205

Please sign in to comment.