ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tm...@apache.org
Subject svn commit: r1463265 - in /ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion: eval/AssertionEvaluation.java medfacts/cleartk/HistoryCleartkAnalysisEngine.java
Date Mon, 01 Apr 2013 19:45:02 GMT
Author: tmill
Date: Mon Apr  1 19:45:02 2013
New Revision: 1463265

URL: http://svn.apache.org/r1463265
Log:
addresses ctakes-182: Modifications to make historyOf run correctly.

Modified:
    ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/AssertionEvaluation.java
    ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/HistoryCleartkAnalysisEngine.java

Modified: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/AssertionEvaluation.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/AssertionEvaluation.java?rev=1463265&r1=1463264&r2=1463265&view=diff
==============================================================================
--- ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/AssertionEvaluation.java
(original)
+++ ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/AssertionEvaluation.java
Mon Apr  1 19:45:02 2013
@@ -273,6 +273,7 @@ protected static Options options = new O
     if (!options.ignoreUncertainty) { annotationTypes.add("uncertainty"); }
     if (!options.ignoreSubject) { annotationTypes.add("subject"); }
     if (!options.ignoreGeneric) { annotationTypes.add("generic"); }
+    if (!options.ignoreHistory) { annotationTypes.add("historyOf"); }
     
     AssertionEvaluation evaluation = new AssertionEvaluation(
         modelsDir,
@@ -746,6 +747,9 @@ public static void printScore(Map<String
     	  historyStats.add(goldEntitiesAndEvents, systemEntitiesAndEvents,
     			  AnnotationStatistics.<IdentifiedAnnotation>annotationToSpan(),
     			  AnnotationStatistics.<IdentifiedAnnotation>annotationToFeatureValue("historyOf"));
+    	  if(options.printErrors){
+    		  printErrors(jCas, goldEntitiesAndEvents, systemEntitiesAndEvents, "historyOf", CONST.NE_HISTORY_OF_PRESENT,
Integer.class);
+    	  }
       }
       
     }
@@ -1004,6 +1008,18 @@ private void addCleartkAttributeAnnotato
 		);
 		builder.add(genericAnnotator);
 	}
+	
+	if(!options.ignoreHistory){
+		AnalysisEngineDescription historyAnnotator = AnalysisEngineFactory.createPrimitiveDescription(HistoryCleartkAnalysisEngine.class);
+		ConfigurationParameterFactory.addConfigurationParameters(
+				historyAnnotator,
+				AssertionCleartkAnalysisEngine.PARAM_GOLD_VIEW_NAME,
+				AssertionEvaluation.GOLD_VIEW_NAME,
+				GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
+				new File(new File(directory, "historyOf"), "model.jar").getPath()
+				);
+		builder.add(historyAnnotator);
+	}
 }
 
   public static final String GOLD_VIEW_NAME = "GoldView";
@@ -1249,6 +1265,7 @@ private void addCleartkAttributeAnnotato
         newGoldEntityMention.setGeneric(oldSystemEntityMention.getGeneric());
         newGoldEntityMention.setPolarity(oldSystemEntityMention.getPolarity());
         newGoldEntityMention.setSubject(oldSystemEntityMention.getSubject());
+        newGoldEntityMention.setHistoryOf(oldSystemEntityMention.getHistoryOf());
 
         // copying non-assertion fields
         newGoldEntityMention.setConfidence(oldSystemEntityMention.getConfidence());
@@ -1267,6 +1284,7 @@ private void addCleartkAttributeAnnotato
         newGoldEventMention.setGeneric(oldSystemEventMention.getGeneric());
         newGoldEventMention.setPolarity(oldSystemEventMention.getPolarity());
         newGoldEventMention.setSubject(oldSystemEventMention.getSubject());
+        newGoldEventMention.setHistoryOf(oldSystemEventMention.getHistoryOf());
 
         // copying non-assertion fields
         newGoldEventMention.setConfidence(oldSystemEventMention.getConfidence());

Modified: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/HistoryCleartkAnalysisEngine.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/HistoryCleartkAnalysisEngine.java?rev=1463265&r1=1463264&r2=1463265&view=diff
==============================================================================
--- ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/HistoryCleartkAnalysisEngine.java
(original)
+++ ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/HistoryCleartkAnalysisEngine.java
Mon Apr  1 19:45:02 2013
@@ -22,6 +22,7 @@ import java.util.ArrayList;
 
 import org.apache.ctakes.assertion.attributes.features.GenericFeaturesExtractor;
 import org.apache.ctakes.assertion.attributes.features.HistoryFeaturesExtractor;
+import org.apache.ctakes.typesystem.type.constants.CONST;
 import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
 import org.apache.uima.UimaContext;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
@@ -67,20 +68,20 @@ public class HistoryCleartkAnalysisEngin
 			Instance<String> instance) throws AnalysisEngineProcessException {
 		if (this.isTraining())
 	      {
-	        String generic = entityMention.getGeneric()? "1":"0";
+			int history = entityMention.getHistoryOf(); 
 
 	        // downsampling. initialize probabilityOfKeepingADefaultExample to 1.0 for no downsampling
-	        if ("0".equals(generic) 
+	        if (history == CONST.NE_HISTORY_OF_ABSENT
 	        		&& coin.nextDouble() >= this.probabilityOfKeepingADefaultExample) {
 	        	return;
 	        }
-	        instance.setOutcome(generic);
+	                
+	        instance.setOutcome(String.valueOf(history));
 	        this.dataWriter.write(instance);
 	      } else
 	      {
 	        String label = this.classifier.classify(instance.getFeatures());
-	        entityMention.setGeneric("1".equals(label));
+	        entityMention.setHistoryOf(Integer.parseInt(label));
 	      }
 	}
-
 }



Mime
View raw message