ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tm...@apache.org
Subject svn commit: r1494726 - in /ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk: ./ extractors/
Date Wed, 19 Jun 2013 18:20:51 GMT
Author: tmill
Date: Wed Jun 19 18:20:51 2013
New Revision: 1494726

URL: http://svn.apache.org/r1494726
Log:
Modified tree fragment feature interface, fixed polarity and uncertainty to deal.

Added:
    ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/extractors/AboveLeftFragmentExtractor.java
  (with props)
    ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/extractors/AboveRightFragmentExtractor.java
  (with props)
Modified:
    ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/PolarityCleartkAnalysisEngine.java
    ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/UncertaintyCleartkAnalysisEngine.java
    ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/extractors/TreeFragmentFeatureExtractor.java

Modified: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/PolarityCleartkAnalysisEngine.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/PolarityCleartkAnalysisEngine.java?rev=1494726&r1=1494725&r2=1494726&view=diff
==============================================================================
--- ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/PolarityCleartkAnalysisEngine.java
(original)
+++ ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/PolarityCleartkAnalysisEngine.java
Wed Jun 19 18:20:51 2013
@@ -20,9 +20,10 @@ package org.apache.ctakes.assertion.medf
 
 import java.util.ArrayList;
 
+import org.apache.ctakes.assertion.medfacts.cleartk.extractors.AboveLeftFragmentExtractor;
+import org.apache.ctakes.assertion.medfacts.cleartk.extractors.AboveRightFragmentExtractor;
 import org.apache.ctakes.assertion.medfacts.cleartk.extractors.ContextWordWindowExtractor;
 import org.apache.ctakes.assertion.medfacts.cleartk.extractors.NegationDependencyFeatureExtractor;
-import org.apache.ctakes.assertion.medfacts.cleartk.extractors.TreeFragmentFeatureExtractor;
 import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
 import org.apache.uima.UimaContext;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
@@ -43,7 +44,8 @@ public class PolarityCleartkAnalysisEngi
 		}
 		this.entityFeatureExtractors.add(new NegationDependencyFeatureExtractor());
 		this.entityFeatureExtractors.add(new ContextWordWindowExtractor("org/apache/ctakes/assertion/models/polarity.txt"));
-		this.entityFeatureExtractors.add(new TreeFragmentFeatureExtractor("org/apache/ctakes/assertion/models/sharpPolarityFrags.txt"));
+		this.entityFeatureExtractors.add(new AboveLeftFragmentExtractor("AL_Polarity","org/apache/ctakes/assertion/models/sharpPolarityFrags.txt"));
+		this.entityFeatureExtractors.add(new AboveRightFragmentExtractor("AR_Polarity","org/apache/ctakes/assertion/models/sharpArPolarityFrags.txt"));
 	}
 
 	@Override

Modified: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/UncertaintyCleartkAnalysisEngine.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/UncertaintyCleartkAnalysisEngine.java?rev=1494726&r1=1494725&r2=1494726&view=diff
==============================================================================
--- ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/UncertaintyCleartkAnalysisEngine.java
(original)
+++ ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/UncertaintyCleartkAnalysisEngine.java
Wed Jun 19 18:20:51 2013
@@ -18,12 +18,16 @@
  */
 package org.apache.ctakes.assertion.medfacts.cleartk;
 
+import java.util.ArrayList;
+
+import org.apache.ctakes.assertion.medfacts.cleartk.extractors.AboveLeftFragmentExtractor;
+import org.apache.ctakes.assertion.medfacts.cleartk.extractors.ContextWordWindowExtractor;
+import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
 import org.apache.uima.UimaContext;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.resource.ResourceInitializationException;
 import org.cleartk.classifier.Instance;
-
-import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
+import org.cleartk.classifier.feature.extractor.simple.SimpleFeatureExtractor;
 
 public class UncertaintyCleartkAnalysisEngine extends AssertionCleartkAnalysisEngine {
 
@@ -31,6 +35,11 @@ public class UncertaintyCleartkAnalysisE
 	public void initialize(UimaContext context) throws ResourceInitializationException {
 		super.initialize(context);
 		probabilityOfKeepingADefaultExample = 0.1;
+		if(this.entityFeatureExtractors == null){
+			this.entityFeatureExtractors = new ArrayList<SimpleFeatureExtractor>();
+		}
+		this.entityFeatureExtractors.add(new ContextWordWindowExtractor("org/apache/ctakes/assertion/models/uncertainty.txt"));
+		this.entityFeatureExtractors.add(new AboveLeftFragmentExtractor("ALUncertainty", "org/apache/ctakes/assertion/models/sharpUncertaintyFrags.txt"));
 	}
 	
 	@Override

Added: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/extractors/AboveLeftFragmentExtractor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/extractors/AboveLeftFragmentExtractor.java?rev=1494726&view=auto
==============================================================================
--- ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/extractors/AboveLeftFragmentExtractor.java
(added)
+++ ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/extractors/AboveLeftFragmentExtractor.java
Wed Jun 19 18:20:51 2013
@@ -0,0 +1,36 @@
+package org.apache.ctakes.assertion.medfacts.cleartk.extractors;
+
+import static org.apache.ctakes.assertion.util.AssertionTreeUtils.extractAboveLeftConceptTree;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ctakes.constituency.parser.util.TreeUtils;
+import org.apache.ctakes.utils.tree.SimpleTree;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.tcas.Annotation;
+import org.cleartk.classifier.Feature;
+import org.cleartk.util.CleartkInitializationException;
+
+public class AboveLeftFragmentExtractor extends TreeFragmentFeatureExtractor {
+
+  public AboveLeftFragmentExtractor(String prefix, String resourceFilename)
+      throws CleartkInitializationException {
+    super(prefix, resourceFilename);
+  }
+
+  @Override
+  public List<Feature> extract(JCas jcas, Annotation annotation) {
+    List<Feature> features = new ArrayList<Feature>();
+    SimpleTree tree = extractAboveLeftConceptTree(jcas, annotation, sems);
+    
+    for(SimpleTree frag : frags){
+      if(TreeUtils.containsIgnoreCase(tree, frag)){
+        features.add(new Feature("TreeFrag_" + prefix, frag.toString()));
+      }
+    }
+  
+    return features;
+  }
+
+}

Propchange: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/extractors/AboveLeftFragmentExtractor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/extractors/AboveRightFragmentExtractor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/extractors/AboveRightFragmentExtractor.java?rev=1494726&view=auto
==============================================================================
--- ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/extractors/AboveRightFragmentExtractor.java
(added)
+++ ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/extractors/AboveRightFragmentExtractor.java
Wed Jun 19 18:20:51 2013
@@ -0,0 +1,35 @@
+package org.apache.ctakes.assertion.medfacts.cleartk.extractors;
+
+import static org.apache.ctakes.assertion.util.AssertionTreeUtils.extractAboveRightConceptTree;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ctakes.constituency.parser.util.TreeUtils;
+import org.apache.ctakes.utils.tree.SimpleTree;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.tcas.Annotation;
+import org.cleartk.classifier.Feature;
+import org.cleartk.util.CleartkInitializationException;
+
+public class AboveRightFragmentExtractor extends TreeFragmentFeatureExtractor {
+
+  public AboveRightFragmentExtractor(String prefix, String resourceFilename)
+      throws CleartkInitializationException {
+    super(prefix, resourceFilename);
+  }
+
+  @Override
+  public List<Feature> extract(JCas jcas, Annotation annotation) {
+    List<Feature> features = new ArrayList<Feature>();
+    SimpleTree tree = extractAboveRightConceptTree(jcas, annotation, sems);
+    
+    for(SimpleTree frag : frags){
+      if(TreeUtils.containsIgnoreCase(tree, frag)){
+        features.add(new Feature("TreeFrag_" + prefix, frag.toString()));
+      }
+    }
+  
+    return features;
+  }
+}

Propchange: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/extractors/AboveRightFragmentExtractor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/extractors/TreeFragmentFeatureExtractor.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/extractors/TreeFragmentFeatureExtractor.java?rev=1494726&r1=1494725&r2=1494726&view=diff
==============================================================================
--- ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/extractors/TreeFragmentFeatureExtractor.java
(original)
+++ ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/extractors/TreeFragmentFeatureExtractor.java
Wed Jun 19 18:20:51 2013
@@ -45,14 +45,15 @@ import org.cleartk.util.CleartkInitializ
  * Model location is hardcoded as of right now.
  * TODO: Parameterize & unstaticize this so that, e.g., multiple projects could use this
feature if necessary.
  */
-public class TreeFragmentFeatureExtractor implements SimpleFeatureExtractor {
+public abstract class TreeFragmentFeatureExtractor implements SimpleFeatureExtractor {
 	public static final String PARAM_OUTPUTDIR = "outputDir";
 	public static final String PARAM_SEMDIR = "semDir";
-	static HashSet<SimpleTree> frags = null;
-	private SemanticClasses sems = null;
+	protected static HashSet<SimpleTree> frags = null;
+	protected SemanticClasses sems = null;
+	protected String prefix = null;
 
-	public TreeFragmentFeatureExtractor(String resourceFilename) throws CleartkInitializationException{
-		if(frags == null) initializeFrags(resourceFilename);
+	public TreeFragmentFeatureExtractor(String prefix, String resourceFilename) throws CleartkInitializationException{
+		initializeFrags(resourceFilename);
 		try{
 			sems = new SemanticClasses(FileLocator.locateFile("org/apache/ctakes/assertion/semantic_classes").getAbsolutePath());
 		}catch(Exception e){
@@ -74,18 +75,5 @@ public class TreeFragmentFeatureExtracto
 	}
 
 	@Override
-	public List<Feature> extract(JCas jcas, Annotation annotation)
-			throws CleartkExtractorException {
-		List<Feature> features = new ArrayList<Feature>();
-		SimpleTree tree = extractAboveLeftConceptTree(jcas, annotation, sems);
-		
-		for(SimpleTree frag : frags){
-			if(TreeUtils.containsIgnoreCase(tree, frag)){
-				features.add(new Feature("TreeFrag", frag.toString()));
-			}
-		}
-	
-		return features;
-	}
-
+	public abstract List<Feature> extract(JCas jcas, Annotation annotation);
 }



Mime
View raw message