ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tm...@apache.org
Subject svn commit: r1715384 - /ctakes/sandbox/ctakes-coref-cleartk/src/main/java/org/apache/ctakes/coreference/ae/features/cluster/MentionClusterAttributeAgreementFeaturesExtractor.java
Date Fri, 20 Nov 2015 16:19:28 GMT
Author: tmill
Date: Fri Nov 20 16:19:28 2015
New Revision: 1715384

URL: http://svn.apache.org/viewvc?rev=1715384&view=rev
Log:
Attribute agreement features.

Added:
    ctakes/sandbox/ctakes-coref-cleartk/src/main/java/org/apache/ctakes/coreference/ae/features/cluster/MentionClusterAttributeAgreementFeaturesExtractor.java

Added: ctakes/sandbox/ctakes-coref-cleartk/src/main/java/org/apache/ctakes/coreference/ae/features/cluster/MentionClusterAttributeAgreementFeaturesExtractor.java
URL: http://svn.apache.org/viewvc/ctakes/sandbox/ctakes-coref-cleartk/src/main/java/org/apache/ctakes/coreference/ae/features/cluster/MentionClusterAttributeAgreementFeaturesExtractor.java?rev=1715384&view=auto
==============================================================================
--- ctakes/sandbox/ctakes-coref-cleartk/src/main/java/org/apache/ctakes/coreference/ae/features/cluster/MentionClusterAttributeAgreementFeaturesExtractor.java
(added)
+++ ctakes/sandbox/ctakes-coref-cleartk/src/main/java/org/apache/ctakes/coreference/ae/features/cluster/MentionClusterAttributeAgreementFeaturesExtractor.java
Fri Nov 20 16:19:28 2015
@@ -0,0 +1,56 @@
+package org.apache.ctakes.coreference.ae.features.cluster;
+
+import static org.apache.ctakes.coreference.ae.features.TokenFeatureExtractor.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ctakes.core.util.ListIterable;
+import org.apache.ctakes.relationextractor.ae.features.RelationFeaturesExtractor;
+import org.apache.ctakes.typesystem.type.relation.CollectionTextRelation;
+import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
+import org.apache.ctakes.typesystem.type.textsem.Markable;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.jcas.JCas;
+import org.cleartk.ml.Feature;
+import org.cleartk.ml.feature.extractor.CleartkExtractorException;
+import org.cleartk.ml.feature.extractor.FeatureExtractor1;
+
+public class MentionClusterAttributeAgreementFeaturesExtractor implements
+    RelationFeaturesExtractor<CollectionTextRelation, IdentifiedAnnotation>, FeatureExtractor1<Markable>
{
+
+  @Override
+  public List<Feature> extract(JCas jCas, CollectionTextRelation cluster,
+      IdentifiedAnnotation mention) throws AnalysisEngineProcessException {
+    List<Feature> features = new ArrayList<>();
+    
+    boolean mentionNegated = isNegated(mention);
+    boolean matchNeg = true;
+    
+    for(IdentifiedAnnotation member : new ListIterable<IdentifiedAnnotation>(cluster.getMembers())){
+      if(mentionNegated != isNegated(member)){
+        matchNeg = false;
+      }
+    }
+    
+    features.add(new Feature("MC_AGREE_NEG", matchNeg));
+
+    
+    return features;
+  }
+
+  @Override
+  public List<Feature> extract(JCas view, Markable mention)
+      throws CleartkExtractorException {
+    List<Feature> features = new ArrayList<>();
+    
+    boolean mentionNegated = isNegated(mention);
+    features.add(new Feature("MC_MENTION_NEGATED", mentionNegated));
+    
+    boolean mentionUncertain = isUncertain(mention);
+    features.add(new Feature("MC_MENTION_UNCERTAIN", mentionUncertain));
+    
+    return features;
+  }
+
+}



Mime
View raw message