You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ctakes.apache.org by tm...@apache.org on 2013/05/03 13:29:34 UTC
svn commit: r1478735 -
/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.java
Author: tmill
Date: Fri May 3 11:29:34 2013
New Revision: 1478735
URL: http://svn.apache.org/r1478735
Log:
Added pre-processing pipeline to adjust PP-aligned timex mentions down the tree to the rightmost NP.
Modified:
ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.java
Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.java?rev=1478735&r1=1478734&r2=1478735&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.java (original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.java Fri May 3 11:29:34 2013
@@ -52,7 +52,9 @@ import org.apache.ctakes.temporal.ae.THY
import org.apache.ctakes.temporal.ae.THYMETreebankReader;
import org.apache.ctakes.typesystem.type.syntax.BaseToken;
import org.apache.ctakes.typesystem.type.syntax.Chunk;
+import org.apache.ctakes.typesystem.type.syntax.TreebankNode;
import org.apache.ctakes.typesystem.type.textsem.EntityMention;
+import org.apache.ctakes.typesystem.type.textsem.TimeMention;
import org.apache.ctakes.typesystem.type.textspan.LookupWindowAnnotation;
import org.apache.ctakes.typesystem.type.textspan.Segment;
import org.apache.ctakes.typesystem.type.textspan.Sentence;
@@ -121,12 +123,9 @@ public abstract class Evaluation_ImplBas
@Option
public boolean getPrintErrors();
- @Option
- public boolean getMergeOverlap();
-
@Option(longName = "kernelParams", defaultToNull=true)
- public String getKernelParams();
-}
+ public String getKernelParams();
+ }
protected File rawTextDirectory;
@@ -409,6 +408,7 @@ public abstract class Evaluation_ImplBas
// add constituency parser (or gold standard treebank if we have it)
if(this.treebankDirectory != null){
aggregateBuilder.add(THYMETreebankReader.getDescription(this.treebankDirectory));
+ aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(TimexAnnotationCorrector.class));
}else{
aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(ConstituencyParser.class));
}
@@ -540,6 +540,45 @@ public abstract class Evaluation_ImplBas
}
}
}
+
+ public static class TimexAnnotationCorrector extends JCasAnnotator_ImplBase {
+ @Override
+ public void process(JCas jCas) throws AnalysisEngineProcessException {
+ JCas goldView, systemView;
+ try {
+ goldView = jCas.getView(GOLD_VIEW_NAME);
+ systemView = jCas.getView(CAS.NAME_DEFAULT_SOFA);
+ } catch (CASException e) {
+ e.printStackTrace();
+ throw new AnalysisEngineProcessException();
+ }
+ for(TimeMention mention : JCasUtil.select(goldView, TimeMention.class)){
+ // for each time expression, get the treebank node with the same span.
+ List<TreebankNode> nodes = JCasUtil.selectCovered(systemView, TreebankNode.class, mention);
+ TreebankNode sameSpanNode = null;
+ for(TreebankNode node : nodes){
+ if(node.getBegin() == mention.getBegin() && node.getEnd() == mention.getEnd()){
+ sameSpanNode = node;
+ break;
+ }
+ }
+ if(sameSpanNode != null){
+ // look at node at the position of the timex3.
+ if(sameSpanNode.getNodeType().equals("PP")){
+ // if it is a PP it should be moved down to the NP
+ int numChildren = sameSpanNode.getChildren().size();
+ if(sameSpanNode.getChildren(numChildren-1).getNodeType().equals("NP")){
+ // move the time span to this node:
+ TreebankNode mentionNode = sameSpanNode.getChildren(numChildren-1);
+ mention.setBegin(mentionNode.getBegin());
+ mention.setEnd(mentionNode.getEnd());
+ }
+ }
+ }
+ }
+ }
+ }
+
public static class CopyFromGold extends JCasAnnotator_ImplBase {