ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlig...@apache.org
Subject svn commit: r1471126 - /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/baselines/BaselineEventTimeRelationAnnotator.java
Date Tue, 23 Apr 2013 20:04:08 GMT
Author: dligach
Date: Tue Apr 23 20:04:08 2013
New Revision: 1471126

URL: http://svn.apache.org/r1471126
Log:
cleanup

Modified:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/baselines/BaselineEventTimeRelationAnnotator.java

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/baselines/BaselineEventTimeRelationAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/baselines/BaselineEventTimeRelationAnnotator.java?rev=1471126&r1=1471125&r2=1471126&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/baselines/BaselineEventTimeRelationAnnotator.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/baselines/BaselineEventTimeRelationAnnotator.java
Tue Apr 23 20:04:08 2013
@@ -48,31 +48,27 @@ public class BaselineEventTimeRelationAn
       JCas jCas,
       Annotation sentence) {
   
-    List<IdentifiedAnnotationPair> pairs = Lists.newArrayList();
     List<EventMention> events = JCasUtil.selectCovered(jCas, EventMention.class, sentence);
     List<TimeMention> times = JCasUtil.selectCovered(jCas, TimeMention.class, sentence);
     
     if(times.size() != 1 || events.size() < 1) {
-      return pairs;
+      return Lists.newArrayList();
     }
 
+    // compute token distance for each time-event pair
+    HashMap<IdentifiedAnnotationPair, Integer> distanceLookup = new HashMap<IdentifiedAnnotationPair,
Integer>();
     for (EventMention event : events) {
       // ignore subclasses like Procedure and Disease/Disorder
       if (event.getClass().equals(EventMention.class)) {
         for (TimeMention time : times) {
-          pairs.add(new IdentifiedAnnotationPair(time, event));
+          IdentifiedAnnotationPair pair = new IdentifiedAnnotationPair(time, event);
+          List<BaseToken> baseTokens = JCasUtil.selectBetween(jCas, BaseToken.class,
pair.getArg1(), pair.getArg2());
+          int distance = baseTokens.size();
+          distanceLookup.put(pair, distance);
         }
       }
     }
 
-    // compute token distance for each time-event pair
-    HashMap<IdentifiedAnnotationPair, Integer> distanceLookup = new HashMap<IdentifiedAnnotationPair,
Integer>();
-    for(IdentifiedAnnotationPair pair : pairs) {
-      List<BaseToken> baseTokens = JCasUtil.selectBetween(jCas, BaseToken.class, pair.getArg1(),
pair.getArg2());
-      int distance = baseTokens.size();
-      distanceLookup.put(pair, distance);
-    }
-
     // find the pair where the distance between entities is the smallest and return it
     List<IdentifiedAnnotationPair> rankedPairs = new ArrayList<IdentifiedAnnotationPair>(distanceLookup.keySet());
     Function<IdentifiedAnnotationPair, Integer> getValue = Functions.forMap(distanceLookup);



Mime
View raw message