incubator-ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlig...@apache.org
Subject svn commit: r1430337 - /incubator/ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/data/GoldAnnotationStatsCalculator.java
Date Tue, 08 Jan 2013 15:47:18 GMT
Author: dligach
Date: Tue Jan  8 15:47:17 2013
New Revision: 1430337

URL: http://svn.apache.org/viewvc?rev=1430337&view=rev
Log:
added calculations for the number of entity pairs in a sentence

Modified:
    incubator/ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/data/GoldAnnotationStatsCalculator.java

Modified: incubator/ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/data/GoldAnnotationStatsCalculator.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/data/GoldAnnotationStatsCalculator.java?rev=1430337&r1=1430336&r2=1430337&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/data/GoldAnnotationStatsCalculator.java
(original)
+++ incubator/ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/data/GoldAnnotationStatsCalculator.java
Tue Jan  8 15:47:17 2013
@@ -19,7 +19,10 @@
 package org.apache.ctakes.relationextractor.data;
 
 import java.util.Collection;
+import java.util.List;
 
+import org.apache.ctakes.relationextractor.ae.EntityMentionPairRelationExtractorAnnotator;
+import org.apache.ctakes.relationextractor.ae.RelationExtractorAnnotator.IdentifiedAnnotationPair;
 import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation;
 import org.apache.ctakes.typesystem.type.syntax.BaseToken;
 import org.apache.ctakes.typesystem.type.textsem.EntityMention;
@@ -48,6 +51,7 @@ public class GoldAnnotationStatsCalculat
 	public int tokenCount;
 	public int sentenceCount;
 	public int entityMentionCount;
+	public int entityMentionPairCount;
 	public Multiset<String> relationTypes;
 	
 	@Override
@@ -56,6 +60,7 @@ public class GoldAnnotationStatsCalculat
 	  tokenCount = 0;
 	  sentenceCount = 0;
 	  entityMentionCount = 0;
+	  entityMentionPairCount = 0;
 	  relationTypes = HashMultiset.create();
 	}
   
@@ -63,11 +68,12 @@ public class GoldAnnotationStatsCalculat
 	public void collectionProcessComplete() throws AnalysisEngineProcessException {
 
 	  System.out.println();
-	  System.out.println("token count: " + tokenCount);
-	  System.out.println("sentence count: " + sentenceCount);
-	  System.out.println("entity mention count: " + entityMentionCount);
-	  System.out.println("location_of count: " + relationTypes.count("location_of"));
-	  System.out.println("degree_of count: " + relationTypes.count("degree_of"));
+	  System.out.format("%-30s%d\n", "token count", tokenCount);
+	  System.out.format("%-30s%d\n", "sentence count", sentenceCount);
+	  System.out.format("%-30s%d\n", "entity mention count", entityMentionCount);
+	  System.out.format("%-30s%d\n", "entity mention pair count", entityMentionPairCount);
+	  System.out.format("%-30s%d\n", "location_of count", relationTypes.count("location_of"));
+	  System.out.format("%-30s%d\n", "degree_of count", relationTypes.count("degree_of"));
   }
   
 	@Override
@@ -79,10 +85,11 @@ public class GoldAnnotationStatsCalculat
     } catch (CASException e) {
       throw new AnalysisEngineProcessException(e);
     }	  
-
+    
     countTokens(jCas); // tokens exist in system view (not in gold)
     countSentences(jCas);
     countEntities(goldView);
+    countEntityMentionPairs(jCas, goldView); // TODO: need gold view?
     countRelationTypes(goldView); 
   }
 	
@@ -96,6 +103,16 @@ public class GoldAnnotationStatsCalculat
 	  Collection<Sentence> sentences = JCasUtil.select(jCas, Sentence.class);
 	  sentenceCount += sentences.size();
 	}
+	
+  private void countEntityMentionPairs(JCas jCas, JCas goldView) {
+    
+    for(Sentence sentence : JCasUtil.select(jCas, Sentence.class)) {
+      EntityMentionPairRelationExtractorAnnotator emPairAnnot = new EntityMentionPairRelationExtractorAnnotator();
+      List<IdentifiedAnnotationPair> pairs = emPairAnnot.getCandidateRelationArgumentPairs(goldView,
sentence);
+      entityMentionPairCount += pairs.size();
+    }
+  }
+	
 	private void countRelationTypes(JCas jCas) {
 	  
     for(BinaryTextRelation binaryTextRelation : JCasUtil.select(jCas, BinaryTextRelation.class))
{



Mime
View raw message