ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlig...@apache.org
Subject svn commit: r1683802 - in /ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor: ae/ManifestationOfRelationExtractorAnnotator.java eval/RelationExtractorEvaluation.java
Date Fri, 05 Jun 2015 16:40:02 GMT
Author: dligach
Date: Fri Jun  5 16:40:02 2015
New Revision: 1683802

URL: http://svn.apache.org/r1683802
Log:
code for manifestation_of relation

Added:
    ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/ae/ManifestationOfRelationExtractorAnnotator.java
  (with props)
Modified:
    ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/eval/RelationExtractorEvaluation.java

Added: ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/ae/ManifestationOfRelationExtractorAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/ae/ManifestationOfRelationExtractorAnnotator.java?rev=1683802&view=auto
==============================================================================
--- ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/ae/ManifestationOfRelationExtractorAnnotator.java
(added)
+++ ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/ae/ManifestationOfRelationExtractorAnnotator.java
Fri Jun  5 16:40:02 2015
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ctakes.relationextractor.ae;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation;
+import org.apache.ctakes.typesystem.type.relation.ManifestationOfTextRelation;
+import org.apache.ctakes.typesystem.type.relation.RelationArgument;
+import org.apache.ctakes.typesystem.type.textsem.DiseaseDisorderMention;
+import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
+import org.apache.ctakes.typesystem.type.textsem.SignSymptomMention;
+import org.apache.ctakes.typesystem.type.textspan.Sentence;
+import org.apache.uima.fit.util.JCasUtil;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.tcas.Annotation;
+
+/**
+ * Identifies manifestation_of relation.
+ * 
+ * In SHARP data the arguments are the following:
+ * 
+ * arg1: AnatomicalSiteMention (4), DiseaseDisorderMention (74), LabMention (2), SignSymptomMention
(38)
+ * arg2: AnatomicalSiteMention (1), DiseaseDisorderMention (114), SignSymptomMention (3)
+ * 
+ * But for now, only considering only the most frequent cases:
+ * 
+ * arg1: disease/disorder, sign/symptom
+ * arg2: disease/disorder
+ */
+public class ManifestationOfRelationExtractorAnnotator extends RelationExtractorAnnotator
{
+
+  @Override
+  protected Class<? extends BinaryTextRelation> getRelationClass() {
+    return ManifestationOfTextRelation.class;
+  }
+
+  @Override
+  public List<IdentifiedAnnotationPair> getCandidateRelationArgumentPairs(
+      JCas identifiedAnnotationView,
+      Annotation sentence) {
+
+    List<DiseaseDisorderMention> diseaseDisorders =
+        JCasUtil.selectCovered(identifiedAnnotationView, DiseaseDisorderMention.class, sentence);
+    List<SignSymptomMention> signSymptoms = 
+        JCasUtil.selectCovered(identifiedAnnotationView, SignSymptomMention.class, sentence);
+
+    List<IdentifiedAnnotation> arg1s = new ArrayList<>();
+    arg1s.addAll(diseaseDisorders);
+    arg1s.addAll(signSymptoms);
+    
+    List<IdentifiedAnnotation> arg2s = new ArrayList<>();
+    arg2s.addAll(diseaseDisorders);
+    
+    List<IdentifiedAnnotationPair> pairs = new ArrayList<>();
+    for(IdentifiedAnnotation arg1 : arg1s) {
+      for(IdentifiedAnnotation arg2 : arg2s) {
+        pairs.add(new IdentifiedAnnotationPair(arg1, arg2));
+      }
+    }
+    
+    return pairs;
+  }
+
+  @Override
+  protected void createRelation(
+      JCas jCas,
+      IdentifiedAnnotation arg1,
+      IdentifiedAnnotation arg2,
+      String predictedCategory) {
+    RelationArgument relArg1 = new RelationArgument(jCas);
+    relArg1.setArgument(arg1);
+    relArg1.setRole("Argument");
+    relArg1.addToIndexes();
+    RelationArgument relArg2 = new RelationArgument(jCas);
+    relArg2.setArgument(arg2);
+    relArg2.setRole("Related_to");
+    relArg2.addToIndexes();
+    ManifestationOfTextRelation relation = new ManifestationOfTextRelation(jCas);
+    relation.setArg1(relArg1);
+    relation.setArg2(relArg2);
+    relation.setCategory(predictedCategory);
+    relation.addToIndexes();
+  }
+
+  @Override
+  protected Class<? extends Annotation> getCoveringClass() {
+    return Sentence.class;
+  }
+}

Propchange: ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/ae/ManifestationOfRelationExtractorAnnotator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/eval/RelationExtractorEvaluation.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/eval/RelationExtractorEvaluation.java?rev=1683802&r1=1683801&r2=1683802&view=diff
==============================================================================
--- ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/eval/RelationExtractorEvaluation.java
(original)
+++ ctakes/trunk/ctakes-relation-extractor/src/main/java/org/apache/ctakes/relationextractor/eval/RelationExtractorEvaluation.java
Fri Jun  5 16:40:02 2015
@@ -33,12 +33,14 @@ import org.apache.ctakes.relationextract
 import org.apache.ctakes.relationextractor.ae.DegreeOfRelationExtractorAnnotator;
 import org.apache.ctakes.relationextractor.ae.LocationOfRelationExtractorAnnotator;
 import org.apache.ctakes.relationextractor.ae.ManagesTreatsRelationExtractorAnnotator;
+import org.apache.ctakes.relationextractor.ae.ManifestationOfRelationExtractorAnnotator;
 import org.apache.ctakes.relationextractor.ae.RelationExtractorAnnotator;
 import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation;
 import org.apache.ctakes.typesystem.type.relation.CausesBringsAboutTextRelation;
 import org.apache.ctakes.typesystem.type.relation.DegreeOfTextRelation;
 import org.apache.ctakes.typesystem.type.relation.LocationOfTextRelation;
 import org.apache.ctakes.typesystem.type.relation.ManagesTreatsTextRelation;
+import org.apache.ctakes.typesystem.type.relation.ManifestationOfTextRelation;
 import org.apache.ctakes.typesystem.type.relation.RelationArgument;
 import org.apache.ctakes.typesystem.type.textsem.EntityMention;
 import org.apache.ctakes.typesystem.type.textsem.EventMention;
@@ -154,6 +156,13 @@ public class RelationExtractorEvaluation
             0.5f },
         new String[] { "-s", "0", "-c", "1.0" }));
 
+    RELATION_CLASSES.put("manifestation_of", ManifestationOfTextRelation.class);
+    ANNOTATOR_CLASSES.put(ManifestationOfTextRelation.class, ManifestationOfRelationExtractorAnnotator.class);
+    BEST_PARAMETERS.put(ManifestationOfTextRelation.class, new ParameterSettings(
+        LibLinearStringOutcomeDataWriter.class,
+        new Object[] { RelationExtractorAnnotator.PARAM_PROBABILITY_OF_KEEPING_A_NEGATIVE_EXAMPLE,
+            0.5f },
+        new String[] { "-s", "0", "-c", "1.0" }));
   }
 
   public static void main(String[] args) throws Exception {



Mime
View raw message