
io.github.repir.TestSet.Topic.TopicReaderTREC Maven / Gradle / Ivy
The newest version!
package io.github.repir.TestSet.Topic;
import io.github.repir.Repository.Repository;
import io.github.repir.tools.io.Datafile;
import io.github.repir.tools.io.struct.StructuredTextFile;
import io.github.repir.tools.lib.Log;
import java.util.HashMap;
/**
* A reader for topic files used in TREC1-8 ad-hoc.
*
* @author jer
*/
public class TopicReaderTREC extends StructuredTextFile implements TopicReader {
public static Log log = new Log(TopicReaderTREC.class);
public IntField number = this.addInt("number", "([ \\c]+:)?", "(?=<)|$", "", "");
public StringField domain = this.addString("domain", "([ \\c]+:)?", "(?=<)|$", "", "");
public StringField title = this.addString("title", "([ \\c]+:)?", "(?=<)|$", "", "");
public StringField description = this.addString("description", "([ \\c]+:)?", "(?=<)|$", "", "");
public StringField summary = this.addString("summary", "([ \\c]+:)?", "(?=<)|$", "", "");
public StringField narrative = this.addString("narrative", "([ \\c]+:)?", "(?=<)|$", "", "");
public TopicReaderTREC(Datafile df) {
super(df);
}
public TopicReaderTREC(Repository repository) {
super(repository.getTopicsFile());
}
public FolderNode createRoot() {
return addNode(null, "top", "", " ", "", " ");
}
@Override
public HashMap getTopics() {
HashMap topics = new HashMap();
this.openRead();
while (this.nextRecord()) {
topics.put(this.number.get(),
new TestSetTopic(number.get(),
(domain.get() == null) ? "" : domain.get(),
title.get()));
}
return topics;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy