incubator-ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlig...@apache.org
Subject svn commit: r1429986 - /incubator/ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/data/GoldAnnotationStatsCalculator.java
Date Mon, 07 Jan 2013 20:06:07 GMT
Author: dligach
Date: Mon Jan  7 20:06:07 2013
New Revision: 1429986

URL: http://svn.apache.org/viewvc?rev=1429986&view=rev
Log:
added a sentence counter and an entity counter

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=1429986&r1=1429985&r2=1429986&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
Mon Jan  7 20:06:07 2013
@@ -18,8 +18,12 @@
  */
 package org.apache.ctakes.relationextractor.data;
 
+import java.util.Collection;
+
 import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation;
 import org.apache.ctakes.typesystem.type.syntax.BaseToken;
+import org.apache.ctakes.typesystem.type.textsem.EntityMention;
+import org.apache.ctakes.typesystem.type.textspan.Sentence;
 import org.apache.uima.UimaContext;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.cas.CASException;
@@ -42,12 +46,16 @@ public class GoldAnnotationStatsCalculat
 
 	public static final String goldViewName = "GoldView";
 	public int tokenCount;
+	public int sentenceCount;
+	public int entityMentionCount;
 	public Multiset<String> relationTypes;
 	
 	@Override
   public void initialize(UimaContext context) throws ResourceInitializationException {
 	  
 	  tokenCount = 0;
+	  sentenceCount = 0;
+	  entityMentionCount = 0;
 	  relationTypes = HashMultiset.create();
 	}
   
@@ -56,6 +64,8 @@ public class GoldAnnotationStatsCalculat
 
 	  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"));
   }
@@ -71,16 +81,21 @@ public class GoldAnnotationStatsCalculat
     }	  
 
     countTokens(jCas); // tokens exist in system view (not in gold)
-    countRelationTypes(goldView); // gold relations are in gold view
+    countSentences(jCas);
+    countEntities(goldView);
+    countRelationTypes(goldView); 
   }
 	
 	private void countTokens(JCas jCas) {
     
-	  for(BaseToken baseToken : JCasUtil.select(jCas, BaseToken.class)) {
-	    tokenCount++;
-    }
+	  Collection<BaseToken> baseTokens = JCasUtil.select(jCas, BaseToken.class);
+	  tokenCount += baseTokens.size();
 	}
 	
+	private void countSentences(JCas jCas) {
+	  Collection<Sentence> sentences = JCasUtil.select(jCas, Sentence.class);
+	  sentenceCount += sentences.size();
+	}
 	private void countRelationTypes(JCas jCas) {
 	  
     for(BinaryTextRelation binaryTextRelation : JCasUtil.select(jCas, BinaryTextRelation.class))
{
@@ -88,4 +103,10 @@ public class GoldAnnotationStatsCalculat
       relationTypes.add(category);
     }
 	}
+	
+	private void countEntities(JCas jCas) {
+	  
+	  Collection<EntityMention> entityMentions = JCasUtil.select(jCas, EntityMention.class);
+	  entityMentionCount += entityMentions.size();
+	}
 }



Mime
View raw message