incubator-ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From james-mas...@apache.org
Subject svn commit: r1400769 - in /incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts: AssertionAnalysisEngine.java ConceptLookup.java Converti2b2AnnotationsToCTAKES.java cleartk/AssertionCleartkAnalysisEngine.java
Date Mon, 22 Oct 2012 06:06:09 GMT
Author: james-masanz
Date: Mon Oct 22 06:06:08 2012
New Revision: 1400769

URL: http://svn.apache.org/viewvc?rev=1400769&view=rev
Log:
CTAKES-87 - Merge in assertion code from SF.net SVN that was not captured in the svndump

Modified:
    incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/AssertionAnalysisEngine.java
    incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/ConceptLookup.java
    incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/Converti2b2AnnotationsToCTAKES.java
    incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/AssertionCleartkAnalysisEngine.java

Modified: incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/AssertionAnalysisEngine.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/AssertionAnalysisEngine.java?rev=1400769&r1=1400768&r2=1400769&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/AssertionAnalysisEngine.java
(original)
+++ incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/AssertionAnalysisEngine.java
Mon Oct 22 06:06:08 2012
@@ -65,7 +65,7 @@ import org.apache.ctakes.typesystem.type
 
 public class AssertionAnalysisEngine extends JCasAnnotator_ImplBase
 {
-  Logger logger = Logger.getLogger(AssertionAnalysisEngine.class.getName());
+  private static Logger logger = Logger.getLogger(AssertionAnalysisEngine.class.getName());
   
   AssertionDecoderConfiguration assertionDecoderConfiguration;
 
@@ -246,95 +246,7 @@ public class AssertionAnalysisEngine ext
 //      logger.info(String.format("removed entityMention (%s) from indexes",
 //          entityMention.toString()));
 //      entityMention.removeFromIndexes();
-      if (currentAssertionType == null)
-      {
-        String message = "current assertion type is null; this is a problem!!";
-        System.err.println(message);
-        logger.severe(message);
-        // Exception runtimeException = new RuntimeException(message);
-        // throw new AnalysisEngineProcessException(runtimeException);
-      
-        // ALL OBVIOUS ERROR VALUES!!
-        annotation.setSubject("skipped");
-        annotation.setPolarity(-2);
-        annotation.setConfidence(-2.0f);
-        annotation.setUncertainty(-2);
-        annotation.setConditional(false);
-        annotation.setGeneric(false);
-
-      } else if (currentAssertionType.equals("present"))
-      // PRESENT (mastif value)
-      {
-        //debugAnnotationsInCas(jcas, entityMention, "=== BEFORE setting entity mention properties
(PRESENT)... ===");
-        // ALL DEFAULT VALUES!! (since this is present)
-        annotation.setSubject(CONST.ATTR_SUBJECT_PATIENT);
-        annotation.setPolarity(1);
-        annotation.setConfidence(1.0f);
-        annotation.setUncertainty(0);
-        annotation.setConditional(false);
-        annotation.setGeneric(false);
-
-        //debugAnnotationsInCas(jcas, entityMention, "=== AFTER setting entity mention properties
(PRESENT)... ===");
-      } else if (currentAssertionType.equals("absent"))
-      // ABSENT (mastif value)
-      {
-        annotation.setSubject(CONST.ATTR_SUBJECT_PATIENT);
-        annotation.setPolarity(-1); // NOT DEFAULT VALUE
-        annotation.setConfidence(1.0f);
-        annotation.setUncertainty(0);
-        annotation.setConditional(false);
-        annotation.setGeneric(false);
-
-      } else if (currentAssertionType.equals("associated_with_someone_else"))
-      // ASSOCIATED WITH SOMEONE ELSE (mastif value)
-      {
-        annotation.setSubject("CONST.ATTR_SUBJECT_FAMILY_MEMBER"); // NOT DEFAULT VALUE
-        annotation.setPolarity(1);
-        annotation.setConfidence(1.0f);
-        annotation.setUncertainty(0);
-        annotation.setConditional(false);
-        annotation.setGeneric(false);
-
-      } else if (currentAssertionType.equals("conditional"))
-      // CONDITIONAL (mastif value)
-      {
-        // currently no mapping to sharp type...all sharp properties are defaults!
-        annotation.setSubject(CONST.ATTR_SUBJECT_PATIENT);
-        annotation.setPolarity(1);
-        annotation.setConfidence(1.0f);
-        annotation.setUncertainty(0);
-        annotation.setConditional(false);
-        annotation.setGeneric(false);
-
-      } else if (currentAssertionType.equals("hypothetical"))
-      // HYPOTHETICAL (mastif value)
-      {
-        annotation.setSubject(CONST.ATTR_SUBJECT_PATIENT);
-        annotation.setPolarity(1);
-        annotation.setConfidence(1.0f);
-        annotation.setUncertainty(0);
-        annotation.setConditional(true); // NOT DEFAULT VALUE
-        annotation.setGeneric(false);
-
-      } else if (currentAssertionType.equals("possible"))
-      // POSSIBLE (mastif value)
-      {
-        annotation.setSubject(CONST.ATTR_SUBJECT_PATIENT);
-        annotation.setPolarity(1);
-        annotation.setConfidence(1.0f);
-        annotation.setUncertainty(1); // NOT DEFAULT VALUE
-        annotation.setConditional(false);
-        annotation.setGeneric(false);
-      } else
-      {
-        String message = String.format(
-            "unexpected assertion value returned!! \"%s\"",
-            currentAssertionType);
-        logger.severe(message);
-        System.err.println(message);
-        Exception runtimeException = new RuntimeException(message);
-        throw new AnalysisEngineProcessException(runtimeException);
-      }
+      mapI2B2AssertionValueToCtakes(currentAssertionType, annotation);
       
 //      // Overwrite mastif's generic attribute with Mayo's generic attribute
 //      Boolean generic = GenericAttributeClassifier.getGeneric(jcas,entityMention);
@@ -371,6 +283,100 @@ public class AssertionAnalysisEngine ext
     logger.info("(logging statement) AssertionAnalysisEngine.process() END");
   }
 
+  public static void mapI2B2AssertionValueToCtakes(String assertionType,
+      IdentifiedAnnotation annotation) throws AnalysisEngineProcessException
+  {
+    if (assertionType == null)
+    {
+      String message = "current assertion type is null; this is a problem!!";
+      System.err.println(message);
+      logger.severe(message);
+      // Exception runtimeException = new RuntimeException(message);
+      // throw new AnalysisEngineProcessException(runtimeException);
+    
+      // ALL OBVIOUS ERROR VALUES!!
+      annotation.setSubject("skipped");
+      annotation.setPolarity(-2);
+      annotation.setConfidence(-2.0f);
+      annotation.setUncertainty(-2);
+      annotation.setConditional(false);
+      annotation.setGeneric(false);
+
+    } else if (assertionType.equals("present"))
+    // PRESENT (mastif value)
+    {
+      //debugAnnotationsInCas(jcas, entityMention, "=== BEFORE setting entity mention properties
(PRESENT)... ===");
+      // ALL DEFAULT VALUES!! (since this is present)
+      annotation.setSubject(CONST.ATTR_SUBJECT_PATIENT);
+      annotation.setPolarity(1);
+      annotation.setConfidence(1.0f);
+      annotation.setUncertainty(0);
+      annotation.setConditional(false);
+      annotation.setGeneric(false);
+
+      //debugAnnotationsInCas(jcas, entityMention, "=== AFTER setting entity mention properties
(PRESENT)... ===");
+    } else if (assertionType.equals("absent"))
+    // ABSENT (mastif value)
+    {
+      annotation.setSubject(CONST.ATTR_SUBJECT_PATIENT);
+      annotation.setPolarity(-1); // NOT DEFAULT VALUE
+      annotation.setConfidence(1.0f);
+      annotation.setUncertainty(0);
+      annotation.setConditional(false);
+      annotation.setGeneric(false);
+
+    } else if (assertionType.equals("associated_with_someone_else"))
+    // ASSOCIATED WITH SOMEONE ELSE (mastif value)
+    {
+      annotation.setSubject("CONST.ATTR_SUBJECT_FAMILY_MEMBER"); // NOT DEFAULT VALUE
+      annotation.setPolarity(1);
+      annotation.setConfidence(1.0f);
+      annotation.setUncertainty(0);
+      annotation.setConditional(false);
+      annotation.setGeneric(false);
+
+    } else if (assertionType.equals("conditional"))
+    // CONDITIONAL (mastif value)
+    {
+      // currently no mapping to sharp type...all sharp properties are defaults!
+      annotation.setSubject(CONST.ATTR_SUBJECT_PATIENT);
+      annotation.setPolarity(1);
+      annotation.setConfidence(1.0f);
+      annotation.setUncertainty(0);
+      annotation.setConditional(false);
+      annotation.setGeneric(false);
+
+    } else if (assertionType.equals("hypothetical"))
+    // HYPOTHETICAL (mastif value)
+    {
+      annotation.setSubject(CONST.ATTR_SUBJECT_PATIENT);
+      annotation.setPolarity(1);
+      annotation.setConfidence(1.0f);
+      annotation.setUncertainty(0);
+      annotation.setConditional(true); // NOT DEFAULT VALUE
+      annotation.setGeneric(false);
+
+    } else if (assertionType.equals("possible"))
+    // POSSIBLE (mastif value)
+    {
+      annotation.setSubject(CONST.ATTR_SUBJECT_PATIENT);
+      annotation.setPolarity(1);
+      annotation.setConfidence(1.0f);
+      annotation.setUncertainty(1); // NOT DEFAULT VALUE
+      annotation.setConditional(false);
+      annotation.setGeneric(false);
+    } else
+    {
+      String message = String.format(
+          "unexpected assertion value returned!! \"%s\"",
+          assertionType);
+      logger.severe(message);
+      System.err.println(message);
+      Exception runtimeException = new RuntimeException(message);
+      throw new AnalysisEngineProcessException(runtimeException);
+    }
+  }
+
   public void debugAnnotationsInCas(JCas jcas, IdentifiedAnnotation annotation,
       String label)
   {

Modified: incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/ConceptLookup.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/ConceptLookup.java?rev=1400769&r1=1400768&r2=1400769&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/ConceptLookup.java
(original)
+++ incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/ConceptLookup.java
Mon Oct 22 06:06:08 2012
@@ -38,6 +38,10 @@ public class ConceptLookup
   protected static HashSet<String> treatmentSet = new HashSet<String>();
   protected static HashSet<String> ignoredSet = new HashSet<String>();
 
+  public static final String REVERSE_LOOKUP_PROBLEM_TUI = "T019";
+  public static final String REVERSE_LOOKUP_TEST_TUI = "T059";
+  public static final String REVERSE_LOOKUP_TREATMENT_TUI = "T116";
+
   static
   {
     String diseasesAndDisordersTuis[] =
@@ -156,5 +160,43 @@ public class ConceptLookup
     
     return conceptType;
   }
+  
+  public static FSArray reverseLookup(ConceptType conceptType, JCas jcas)
+  {
+	  if (conceptType == null) return null;
+	  
+//	  FSIndexRepository fsIndexRepository = jcas.getFSIndexRepository();
+//	  fsIndexRepository.addFS();
+//	  fsIndexRepository.
+
+	  FSArray ontologyConceptArray = new FSArray(jcas, 1);
+	  OntologyConcept ontologyConcept = new OntologyConcept(jcas);
+	  String codingScheme = null;
+	  String code = null;
+	  if (conceptType.equals(ConceptType.TREATMENT))
+	  {
+		codingScheme = "RXNORM";
+		code = ConceptLookup.REVERSE_LOOKUP_TREATMENT_TUI;
+	  } else if (conceptType.equals(ConceptType.PROBLEM))
+	  {
+		codingScheme = "SNOMEDCT";
+		code = ConceptLookup.REVERSE_LOOKUP_PROBLEM_TUI;
+	  } else if (conceptType.equals(ConceptType.TEST))
+	  {
+		codingScheme = "SNOMEDCT";
+		code = ConceptLookup.REVERSE_LOOKUP_TEST_TUI;
+	  } else
+	  {
+		codingScheme = null;
+		code = null;
+	  }
+	  ontologyConcept.setCode(code);
+	  ontologyConcept.setCodingScheme(codingScheme);
+	  
+	  ontologyConceptArray.set(0,  ontologyConcept);
+	  
+	  return ontologyConceptArray;
+	  
+  }
 
 }

Modified: incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/Converti2b2AnnotationsToCTAKES.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/Converti2b2AnnotationsToCTAKES.java?rev=1400769&r1=1400768&r2=1400769&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/Converti2b2AnnotationsToCTAKES.java
(original)
+++ incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/Converti2b2AnnotationsToCTAKES.java
Mon Oct 22 06:06:08 2012
@@ -75,6 +75,7 @@ import org.apache.uima.util.XMLSerialize
  */
 
 public class Converti2b2AnnotationsToCTAKES {
+	private static Logger logger = Logger.getLogger(Converti2b2AnnotationsToCTAKES.class);
 	
 	private static CAS getTypeSystemFromDescriptor(String descriptor) throws InvalidXMLException,
IOException, ResourceInitializationException, CASException {
 		XMLParser xmlParser = UIMAFramework.getXMLParser();
@@ -110,7 +111,7 @@ public class Converti2b2AnnotationsToCTA
 	    }
 	  }
 	
-	public static void main(String [] args) throws IOException, InvalidXMLException, CASException,
SAXException {
+	public static void main(String [] args) throws IOException, InvalidXMLException, CASException,
SAXException, AnalysisEngineProcessException {
 		//File currentTextFile = new File(args[0]);
 		File assertionDir = new File(args[1]);
 		File dir = new File(args[0]);
@@ -183,20 +184,58 @@ public class Converti2b2AnnotationsToCTA
 					tok.addToIndexes();
 				}
 			}
+			logger.info("before assertions");
 			for (Annotation a : assertions) {
-				Concept assertion = new Concept(jcas);
+				logger.info("  begin assertion");
+				logger.info("  assertion: " + a.toString());
+				//Concept assertion = new Concept(jcas);
+
+				org.mitre.medfacts.i2b2.annotation.AssertionAnnotation i2b2Assertion = (org.mitre.medfacts.i2b2.annotation.AssertionAnnotation)a;
+				ConceptType conceptType = i2b2Assertion.getConceptType();
+
+				IdentifiedAnnotation entityOrEventMention = null;
+				if (conceptType.equals(ConceptType.TREATMENT))
+				{
+				  entityOrEventMention = new EventMention(jcas);
+				} else
+				{
+				  entityOrEventMention = new EntityMention(jcas);
+				}
+				
 				LineAndTokenPosition assertionStart = new LineAndTokenPosition();
 				LineAndTokenPosition assertionEnd = new LineAndTokenPosition();
 				assertionStart.setLine(a.getBegin().getLine());
 				assertionStart.setTokenOffset(a.getBegin().getTokenOffset());
 				assertionEnd.setLine(a.getEnd().getLine());
 				assertionEnd.setTokenOffset(a.getEnd().getTokenOffset());
-				assertion.setBegin(converter.convert(assertionStart).getBegin());
-				assertion.setEnd(converter.convert(assertionEnd).getEnd() + 1);
-				assertion.setConceptType("PROBLEM");
-				assertion.addToIndexes();
+				
+//				assertion.setBegin(converter.convert(assertionStart).getBegin());
+//				assertion.setEnd(converter.convert(assertionEnd).getEnd() + 1);
+//				assertion.setConceptType("PROBLEM");
+//				assertion.addToIndexes();
+				
+				entityOrEventMention.setBegin(converter.convert(assertionStart).getBegin());
+				entityOrEventMention.setEnd(converter.convert(assertionEnd).getEnd());
+				entityOrEventMention.setConfidence(1.0f);
+				
+				FSArray ontologyConceptArray = ConceptLookup.reverseLookup(conceptType, jcas);
+				entityOrEventMention.setOntologyConceptArr(ontologyConceptArray);
+				
+				//adjustAssertionAttributesByI2B2Convertion(entityOrEventMention, i2b2Assertion);
+				AssertionAnalysisEngine.mapI2B2AssertionValueToCtakes(i2b2Assertion.getAssertionValue().toString().toLowerCase(),
entityOrEventMention);
+				
+				entityOrEventMention.addToIndexes();
+				logger.info("  end assertion");
 			}
+			logger.info("after assertions");
 			writeXmi(cas,outFile);
 		}
 	}
+
+  private static void adjustAssertionAttributesByI2B2Convertion(
+      IdentifiedAnnotation entityOrEventMention,
+      org.mitre.medfacts.i2b2.annotation.AssertionAnnotation i2b2Assertion)
+  {
+    
+  }
 }

Modified: incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/AssertionCleartkAnalysisEngine.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/AssertionCleartkAnalysisEngine.java?rev=1400769&r1=1400768&r2=1400769&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/AssertionCleartkAnalysisEngine.java
(original)
+++ incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/AssertionCleartkAnalysisEngine.java
Mon Oct 22 06:06:08 2012
@@ -26,15 +26,19 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.uima.UimaContext;
+import org.apache.uima.analysis_engine.AnalysisEngineDescription;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.jcas.JCas;
 import org.apache.uima.resource.ResourceInitializationException;
 import org.cleartk.classifier.CleartkAnnotator;
+import org.cleartk.classifier.CleartkAnnotatorDescriptionFactory;
 import org.cleartk.classifier.CleartkSequenceAnnotator;
 import org.cleartk.classifier.Instance;
 import org.cleartk.classifier.feature.extractor.ContextExtractor;
+import org.cleartk.classifier.feature.extractor.ContextExtractor.Covered;
 import org.cleartk.classifier.feature.extractor.ContextExtractor.Preceding;
 import org.cleartk.classifier.feature.extractor.ContextExtractor.Following;
+import org.cleartk.classifier.feature.extractor.simple.CoveredTextExtractor;
 import org.cleartk.classifier.feature.extractor.simple.SimpleFeatureExtractor;
 import org.cleartk.classifier.feature.extractor.simple.SpannedTextExtractor;
 import org.cleartk.classifier.feature.extractor.simple.TypePathExtractor;
@@ -43,7 +47,10 @@ import org.cleartk.classifier.feature.pr
 import org.cleartk.classifier.feature.proliferate.LowerCaseProliferator;
 import org.cleartk.classifier.feature.proliferate.NumericTypeProliferator;
 import org.cleartk.classifier.feature.proliferate.ProliferatingExtractor;
+import org.cleartk.classifier.opennlp.DefaultMaxentDataWriterFactory;
+import org.cleartk.classifier.opennlp.MaxentDataWriterFactory_ImplBase;
 import org.cleartk.type.test.Token;
+import org.uimafit.factory.ConfigurationParameterFactory;
 import org.uimafit.util.JCasUtil;
 
 import org.apache.ctakes.typesystem.type.syntax.BaseToken;
@@ -55,8 +62,10 @@ public class AssertionCleartkAnalysisEng
     CleartkSequenceAnnotator<String>
 {
 
-  private SimpleFeatureExtractor tokenFeatureExtractor;
+	public static final String PARAM_GOLD_VIEW_NAME = "GoldViewName";
+//private SimpleFeatureExtractor tokenFeatureExtractor;
   private List<ContextExtractor<IdentifiedAnnotation>> contextFeatureExtractors;
+  private List<ContextExtractor<BaseToken>> tokenContextFeatureExtractors;
   private List<SimpleFeatureExtractor> entityFeatureExtractors;
   
   public void initialize(UimaContext context) throws ResourceInitializationException {
@@ -68,7 +77,8 @@ public class AssertionCleartkAnalysisEng
     // the stem of the word, the text of the word itself, plus
     // features created from the word text like character ngrams
     this.entityFeatureExtractors = Arrays.asList(
-        new TypePathExtractor(IdentifiedAnnotation.class, "stem"),
+        new CoveredTextExtractor(),
+        //new TypePathExtractor(IdentifiedAnnotation.class, "stem"),
         new ProliferatingExtractor(
             new SpannedTextExtractor(),
             new LowerCaseProliferator(),    
@@ -81,9 +91,47 @@ public class AssertionCleartkAnalysisEng
     this.contextFeatureExtractors = new ArrayList<ContextExtractor<IdentifiedAnnotation>>();
     this.contextFeatureExtractors.add(new ContextExtractor<IdentifiedAnnotation>(
         IdentifiedAnnotation.class,
-        new TypePathExtractor(IdentifiedAnnotation.class, "stem"),
+        new CoveredTextExtractor(),
+        //new TypePathExtractor(IdentifiedAnnotation.class, "stem"),
         new Preceding(2),
         new Following(2)));
+    ContextExtractor<BaseToken> tokenContextExtractor1 = new ContextExtractor<BaseToken>(

+        BaseToken.class, 
+        new SpannedTextExtractor(), 
+        new ContextExtractor.Ngram(new Covered()),
+        
+        new ContextExtractor.Ngram(new Preceding(1)), 
+        new ContextExtractor.Ngram(new Preceding(2)), 
+        //new ContextExtractor.Ngram(new Preceding(1, 2)), 
+        new ContextExtractor.Ngram(new Preceding(3)), 
+        //new ContextExtractor.Ngram(new Preceding(2, 3)), 
+        new ContextExtractor.Ngram(new Following(1)), 
+        new ContextExtractor.Ngram(new Following(2)),
+        //new ContextExtractor.Ngram(new Following(1, 2)),
+        new ContextExtractor.Ngram(new Following(3))
+        //new ContextExtractor.Ngram(new Following(2,3))
+        ); 
+    tokenContextFeatureExtractors = new ArrayList<ContextExtractor<BaseToken>>();
+    tokenContextFeatureExtractors.add(tokenContextExtractor1);
+    
+    TypePathExtractor posExtractor = new TypePathExtractor(BaseToken.class, "partOfSpeech");
+    ContextExtractor<BaseToken> extractor2 = new ContextExtractor<BaseToken>(

+        BaseToken.class, 
+        posExtractor, 
+        new ContextExtractor.Ngram(new Covered()), 
+        new ContextExtractor.Ngram(new Preceding(1)), 
+        new ContextExtractor.Ngram(new Preceding(2)), 
+        new ContextExtractor.Ngram(new Following(1)), 
+        new ContextExtractor.Ngram(new Following(2)) 
+        /*
+        new ContextExtractor.Covered(), 
+        new ContextExtractor.Ngram(new Covered()) 
+        
+        new ContextExtractor.Ngram(new Preceding(1)), 
+        new ContextExtractor.Ngram(new Preceding(2)), 
+        */
+        );
+    tokenContextFeatureExtractors.add(extractor2);
 
   }
 
@@ -102,8 +150,8 @@ public class AssertionCleartkAnalysisEng
     {
       Instance<String> instance = new Instance<String>();
       
-      // extract all features that require only the entity mention annotation
-      instance.addAll(tokenFeatureExtractor.extract(jCas, entityMention));
+//      // extract all features that require only the entity mention annotation
+//      instance.addAll(tokenFeatureExtractor.extract(jCas, entityMention));
 
       // extract all features that require the token and sentence annotations
       Collection<Sentence> sentenceList = coveringSentenceMap.get(entityMention);
@@ -122,6 +170,12 @@ public class AssertionCleartkAnalysisEng
       for (ContextExtractor<IdentifiedAnnotation> extractor : this.contextFeatureExtractors)
{
         instance.addAll(extractor.extractWithin(jCas, entityMention, sentence));
       }
+      for (ContextExtractor<BaseToken> extractor : this.tokenContextFeatureExtractors)
{
+        instance.addAll(extractor.extract(jCas, entityMention));
+      }
+      for (SimpleFeatureExtractor extractor : this.entityFeatureExtractors) {
+        instance.addAll(extractor.extract(jCas, entityMention));
+      }
       
       if (this.isTraining())
       {
@@ -146,7 +200,10 @@ public class AssertionCleartkAnalysisEng
       for (String label : this.classify(instances))
       {
         int polarity = 1;
-        if (label != null && label.equals("negated"))
+        if (label!= null && label.equals("present"))
+        {
+          polarity = 1;
+        } else if (label != null && label.equals("negated"))
         {
           polarity = -1;
         }
@@ -156,4 +213,27 @@ public class AssertionCleartkAnalysisEng
 
   }
 
+  /*
+  public static AnalysisEngineDescription getClassifierDescription(String modelFileName)
+      throws ResourceInitializationException {
+    return CleartkAnnotatorDescriptionFactory.createCleartkAnnotator(
+        AssertionCleartkAnalysisEngine.class,
+        AssertionComponents.TYPE_SYSTEM_DESCRIPTION,
+        modelFileName);
+  }
+
+  public static AnalysisEngineDescription getWriterDescription(String outputDirectory)
+      throws ResourceInitializationException {
+    AnalysisEngineDescription aed = CleartkAnnotatorDescriptionFactory.createViterbiAnnotator(
+        AssertionCleartkAnalysisEngine.class,
+        AssertionComponents.TYPE_SYSTEM_DESCRIPTION,
+        DefaultMaxentDataWriterFactory.class,
+        outputDirectory);
+    ConfigurationParameterFactory.addConfigurationParameter(
+        aed,
+        MaxentDataWriterFactory_ImplBase.PARAM_COMPRESS,
+        true);
+    return aed;
+  }
+  */
 }



Mime
View raw message