Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListResult output #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import de.unihd.dbs.heideltime.standalone.components.impl.JCasFactoryImpl;
import de.unihd.dbs.heideltime.standalone.components.impl.JVnTextProWrapper;
import de.unihd.dbs.heideltime.standalone.components.impl.StanfordPOSTaggerWrapper;
import de.unihd.dbs.heideltime.standalone.components.impl.ListResultFormatter;
import de.unihd.dbs.heideltime.standalone.components.impl.TimeMLResultFormatter;
import de.unihd.dbs.heideltime.standalone.components.impl.TreeTaggerWrapper;
import de.unihd.dbs.heideltime.standalone.components.impl.UimaContextImpl;
Expand Down Expand Up @@ -428,8 +429,12 @@ private void establishPartOfSpeechInformation(JCas jcas) {
private ResultFormatter getFormatter() {
if (outputType.toString().equals("xmi")){
return new XMIResultFormatter();
} else {
return new TimeMLResultFormatter();
}
else if (outputType.toString().equals("list")) {
return new ListResultFormatter();
}
else{
return new TimeMLResultFormatter();
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/de/unihd/dbs/heideltime/standalone/OutputType.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,10 @@ public String toString() {
public String toString() {
return "xmi";
}
},
LIST {
public String toString() {
return "list";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* ListResultFormatter.java
*
* Copyright (c) 2011, Database Research Group, Institute of Computer Science, University of Heidelberg.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU General Public License.
*
*/

package de.unihd.dbs.heideltime.standalone.components.impl;

import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.uima.cas.FSIterator;
import org.apache.uima.jcas.JCas;

import de.unihd.dbs.heideltime.standalone.components.ResultFormatter;
import de.unihd.dbs.uima.types.heideltime.Timex3;
import de.unihd.dbs.uima.types.heideltime.Timex3Interval;

/**
* List Results Formatter
*
*
* @author Francesco Paolo Albano, Politecnico di Bari
* @version 1.0
*/
public class ListResultFormatter implements ResultFormatter {
public String format(JCas jcas) throws Exception {
final String documentText = jcas.getDocumentText();
String outText = new String();


//Logger l = Logger.getLogger("ListResultFormatter");
//l.log(Level.INFO, "Start List ResultFormatter");

FSIterator iterIntervals = jcas.getAnnotationIndex(Timex3Interval.type).iterator();
while(iterIntervals.hasNext()) {
Timex3Interval t = (Timex3Interval) iterIntervals.next();

Integer start = t.getBegin();
Integer end = t.getEnd();
outText += t.getTimexType()+"\t"+start+" "+end+"\t"+documentText.substring(start, end)+"\t"+t.getTimexValueEB()+"-"+t.getTimexValueLB() +"\t"+t.getTimexValueEE()+"-"+t.getTimexValueLE()+"\n";
}


//only for timex3
//we want TYPE start end Text NormalizedValue
FSIterator iterTimex = jcas.getAnnotationIndex(Timex3.type).iterator();
while(iterTimex.hasNext()) {
Timex3 t = (Timex3) iterTimex.next();


Integer start = t.getBegin();
Integer end = t.getEnd();
outText += t.getTimexType()+"\t"+start+" "+end+"\t"+documentText.substring(start, end)+"\t"+t.getTimexValue()+"\n";
}

//l.log(Level.INFO, "End List ResultFormatter");
return outText;
}
}