incubator-ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject svn commit: r1437504 - in /incubator/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core: ae/SHARPKnowtatorXMLReader.java util/SHARPKnowtatorXMLDefaults.java
Date Wed, 23 Jan 2013 15:52:34 GMT
Author: swu
Date: Wed Jan 23 15:52:34 2013
New Revision: 1437504

URL: http://svn.apache.org/viewvc?rev=1437504&view=rev
Log:
SHARPKnowtatorXMLReader: automatically set subject values to patient unless you turn SET_DEFAULTS
off

Added:
    incubator/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/util/SHARPKnowtatorXMLDefaults.java
Modified:
    incubator/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/SHARPKnowtatorXMLReader.java

Modified: incubator/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/SHARPKnowtatorXMLReader.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/SHARPKnowtatorXMLReader.java?rev=1437504&r1=1437503&r2=1437504&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/SHARPKnowtatorXMLReader.java
(original)
+++ incubator/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/SHARPKnowtatorXMLReader.java
Wed Jan 23 15:52:34 2013
@@ -32,6 +32,7 @@ import java.util.Set;
 
 import org.apache.ctakes.core.knowtator.KnowtatorAnnotation;
 import org.apache.ctakes.core.knowtator.KnowtatorXMLParser;
+import org.apache.ctakes.core.util.SHARPKnowtatorXMLDefaults;
 import org.apache.ctakes.typesystem.type.constants.CONST;
 import org.apache.ctakes.typesystem.type.refsem.AnatomicalSiteMention;
 import org.apache.ctakes.typesystem.type.refsem.BodyLaterality;
@@ -108,6 +109,7 @@ public class SHARPKnowtatorXMLReader ext
   
   // paramater that should contain the path to text files, with Knowtator XML in a "nephew"
   public static final String PARAM_TEXTURI = "TextURI";
+  public static final String SET_DEFAULTS = "SetDefaults";
 
   private static final Map<String, String> knowtatorSubjectValuesMappedToCasValues;
   static {
@@ -138,6 +140,7 @@ public class SHARPKnowtatorXMLReader ext
   
   // path to knowtator xml files
   public static File textURIDirectory;
+  public static Boolean setDefaults;
 
   /**
    * Get the URI that the text in this class was loaded from
@@ -188,6 +191,8 @@ public class SHARPKnowtatorXMLReader ext
 
 	try {
 		textURIDirectory = new File( (String) aContext.getConfigParameterValue(PARAM_TEXTURI) );
+		Boolean sd = (Boolean) aContext.getConfigParameterValue(SET_DEFAULTS);
+		setDefaults = (sd==null)? true : sd;
 	} catch (NullPointerException e) {
 		textURIDirectory = null;
 	}
@@ -610,6 +615,7 @@ public class SHARPKnowtatorXMLReader ext
         String code = stringSlots.remove("associatedCode");
         SubjectModifier modifier = new SubjectModifier(jCas, coveringSpan.begin, coveringSpan.end);
         if (value!=null) value = knowtatorSubjectValuesMappedToCasValues.get(value);
+        if (setDefaults) value = SHARPKnowtatorXMLDefaults.getSubject(value);
         modifier.setSubject(value);
         modifier.addToIndexes();
         idAnnotationMap.put(annotation.id, modifier);
@@ -1073,8 +1079,8 @@ public class SHARPKnowtatorXMLReader ext
     KnowtatorAnnotation negationIndicator = annotationSlots.remove("negation_indicator_CU");
     delayedFeatures.add(new NegationFeature(identifiedAnnotation, negationIndicator));
     KnowtatorAnnotation subject = annotationSlots.remove("subject_CU");
-    //subject.stringSlots.get("subject_normalization_CU");
     delayedFeatures.add(new SubjectFeature(identifiedAnnotation, subject));
+    if (setDefaults && subject==null) { identifiedAnnotation.setSubject(SHARPKnowtatorXMLDefaults.getSubject());
}
     KnowtatorAnnotation uncertainty = annotationSlots.remove("uncertainty_indicator_CU");
     delayedFeatures.add(new UncertaintyFeature(identifiedAnnotation, uncertainty));
 
@@ -1552,6 +1558,7 @@ public class SHARPKnowtatorXMLReader ext
     protected void setValue(TOP valueAnnotation) {
       Modifier subjectModifier = (Modifier) valueAnnotation;
       String normalizedSubject = subjectModifier.getSubject();
+      if (setDefaults) normalizedSubject = SHARPKnowtatorXMLDefaults.getSubject(normalizedSubject);
       //if (normalizedSubject!=null) LOGGER.error("INFO: subject = " + normalizedSubject);
// TODO remove this debug line
       this.annotation.setSubject(normalizedSubject);
     }

Added: incubator/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/util/SHARPKnowtatorXMLDefaults.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/util/SHARPKnowtatorXMLDefaults.java?rev=1437504&view=auto
==============================================================================
--- incubator/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/util/SHARPKnowtatorXMLDefaults.java
(added)
+++ incubator/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/util/SHARPKnowtatorXMLDefaults.java
Wed Jan 23 15:52:34 2013
@@ -0,0 +1,36 @@
+package org.apache.ctakes.core.util;
+
+import java.util.Map;
+
+import org.apache.ctakes.core.knowtator.KnowtatorAnnotation;
+import org.apache.ctakes.typesystem.type.constants.CONST;
+
+/**
+ * A helper class that centralizes methods to assign all the 
+ * default values from the SHARP corpus annotation guidelines.
+ * 
+ * @author stephen wu
+ *
+ */
+public class SHARPKnowtatorXMLDefaults {
+
+	public static String getSubject(String normalizedSubject) {
+		if (normalizedSubject==null) {
+			return CONST.ATTR_SUBJECT_PATIENT;
+		}
+		return normalizedSubject;
+	}
+
+	public static String getSubject() {
+		return CONST.ATTR_SUBJECT_PATIENT;
+	}
+
+//	public static String getSubject(Map<String, KnowtatorAnnotation> annotationSlots)
{
+//		if (annotationSlots.get("subject_CU")==null) {
+//			return CONST.ATTR_SUBJECT_PATIENT;
+//		}
+//		return annotationSlots.get("subject_CU").stringSlots.get("subject_normalization_CU");
+//	}
+
+
+}
\ No newline at end of file



Mime
View raw message