ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From james-mas...@apache.org
Subject svn commit: r1466451 - in /ctakes/trunk/ctakes-template-filler: ./ .settings/ desc/ desc/analysis_engine/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/ctakes/ src/main/java/org/apache/ctakes/templa...
Date Wed, 10 Apr 2013 12:43:46 GMT
Author: james-masanz
Date: Wed Apr 10 12:43:45 2013
New Revision: 1466451

URL: http://svn.apache.org/r1466451
Log: (empty)

Added:
    ctakes/trunk/ctakes-template-filler/.classpath   (with props)
    ctakes/trunk/ctakes-template-filler/.project   (with props)
    ctakes/trunk/ctakes-template-filler/.settings/
    ctakes/trunk/ctakes-template-filler/.settings/org.eclipse.core.resources.prefs   (with
props)
    ctakes/trunk/ctakes-template-filler/.settings/org.eclipse.jdt.core.prefs   (with props)
    ctakes/trunk/ctakes-template-filler/desc/
    ctakes/trunk/ctakes-template-filler/desc/analysis_engine/
    ctakes/trunk/ctakes-template-filler/desc/analysis_engine/AggregateTemplateFiller.xml 
 (with props)
    ctakes/trunk/ctakes-template-filler/desc/analysis_engine/TemplateFillerAnnotator.xml 
 (with props)
    ctakes/trunk/ctakes-template-filler/pom.xml   (with props)
    ctakes/trunk/ctakes-template-filler/src/
    ctakes/trunk/ctakes-template-filler/src/main/
    ctakes/trunk/ctakes-template-filler/src/main/java/
    ctakes/trunk/ctakes-template-filler/src/main/java/org/
    ctakes/trunk/ctakes-template-filler/src/main/java/org/apache/
    ctakes/trunk/ctakes-template-filler/src/main/java/org/apache/ctakes/
    ctakes/trunk/ctakes-template-filler/src/main/java/org/apache/ctakes/templatefiller/
    ctakes/trunk/ctakes-template-filler/src/main/java/org/apache/ctakes/templatefiller/ae/
    ctakes/trunk/ctakes-template-filler/src/main/java/org/apache/ctakes/templatefiller/ae/TemplateFillerAnnotator.java
  (with props)
    ctakes/trunk/ctakes-template-filler/src/main/resources/

Added: ctakes/trunk/ctakes-template-filler/.classpath
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-template-filler/.classpath?rev=1466451&view=auto
==============================================================================
--- ctakes/trunk/ctakes-template-filler/.classpath (added)
+++ ctakes/trunk/ctakes-template-filler/.classpath Wed Apr 10 12:43:45 2013
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java">
+		<attributes>
+			<attribute name="optional" value="true"/>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry including="**/*.java" kind="src" path="src/main/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/UIMA"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java">
+		<attributes>
+			<attribute name="optional" value="true"/>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Propchange: ctakes/trunk/ctakes-template-filler/.classpath
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ctakes/trunk/ctakes-template-filler/.project
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-template-filler/.project?rev=1466451&view=auto
==============================================================================
--- ctakes/trunk/ctakes-template-filler/.project (added)
+++ ctakes/trunk/ctakes-template-filler/.project Wed Apr 10 12:43:45 2013
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>ctakes-template-filler</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.apache.uima.pear.UimaNature</nature>
+	</natures>
+</projectDescription>

Propchange: ctakes/trunk/ctakes-template-filler/.project
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ctakes/trunk/ctakes-template-filler/.settings/org.eclipse.core.resources.prefs
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-template-filler/.settings/org.eclipse.core.resources.prefs?rev=1466451&view=auto
==============================================================================
--- ctakes/trunk/ctakes-template-filler/.settings/org.eclipse.core.resources.prefs (added)
+++ ctakes/trunk/ctakes-template-filler/.settings/org.eclipse.core.resources.prefs Wed Apr
10 12:43:45 2013
@@ -0,0 +1,4 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding//src/main/resources=UTF-8
+encoding/<project>=UTF-8

Propchange: ctakes/trunk/ctakes-template-filler/.settings/org.eclipse.core.resources.prefs
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ctakes/trunk/ctakes-template-filler/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-template-filler/.settings/org.eclipse.jdt.core.prefs?rev=1466451&view=auto
==============================================================================
--- ctakes/trunk/ctakes-template-filler/.settings/org.eclipse.jdt.core.prefs (added)
+++ ctakes/trunk/ctakes-template-filler/.settings/org.eclipse.jdt.core.prefs Wed Apr 10 12:43:45
2013
@@ -0,0 +1,12 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6

Propchange: ctakes/trunk/ctakes-template-filler/.settings/org.eclipse.jdt.core.prefs
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ctakes/trunk/ctakes-template-filler/desc/analysis_engine/AggregateTemplateFiller.xml
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-template-filler/desc/analysis_engine/AggregateTemplateFiller.xml?rev=1466451&view=auto
==============================================================================
--- ctakes/trunk/ctakes-template-filler/desc/analysis_engine/AggregateTemplateFiller.xml (added)
+++ ctakes/trunk/ctakes-template-filler/desc/analysis_engine/AggregateTemplateFiller.xml Wed
Apr 10 12:43:45 2013
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<analysisEngineDescription xmlns="http://uima.apache.org/resourceSpecifier">
+  <frameworkImplementation>org.apache.uima.java</frameworkImplementation>
+  <primitive>false</primitive>
+  <delegateAnalysisEngineSpecifiers>
+    <delegateAnalysisEngine key="RelationExtractorAnnotator">
+      <import location="../../../ctakes-relation-extractor/desc/analysis_engine/RelationExtractorAggregate_wo_OrangeBook.xml"/>
+    </delegateAnalysisEngine>
+    <delegateAnalysisEngine key="TemplateFillerAnnotator">
+      <import location="../../../ctakes-template-filler/desc/analysis_engine/TemplateFillerAnnotator.xml"/>
+    </delegateAnalysisEngine>
+  </delegateAnalysisEngineSpecifiers>
+  <analysisEngineMetaData>
+    <name>AggregateTemplateFiller</name>
+    <description>Find named entities and relations using RelationExtractor, then fill
xxxxxxMention templates</description>
+    <version/>
+    <vendor/>
+    <configurationParameters searchStrategy="language_fallback">
+    </configurationParameters>
+    <configurationParameterSettings>
+    </configurationParameterSettings>
+    <flowConstraints>
+      <fixedFlow>
+        <node>RelationExtractorAnnotator</node>
+        <node>TemplateFillerAnnotator</node>
+      </fixedFlow>
+    </flowConstraints>
+    <typePriorities>
+      <name>Ordering</name>
+      <description>For subiterator</description>
+      <version>1.0</version>
+      <priorityList>
+        <type>org.apache.ctakes.typesystem.type.textspan.Segment</type>
+        <type>org.apache.ctakes.typesystem.type.textspan.Sentence</type>
+        <type>org.apache.ctakes.typesystem.type.syntax.BaseToken</type>
+      </priorityList>
+      <priorityList>
+        <type>org.apache.ctakes.typesystem.type.textspan.Sentence</type>
+        <type>org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation</type>
+      </priorityList>
+    </typePriorities>
+    <fsIndexCollection/>
+    <capabilities>
+      <capability>
+        <inputs/>
+        <outputs>
+        </outputs>
+        <languagesSupported/>
+      </capability>
+    </capabilities>
+    <operationalProperties>
+      <modifiesCas>true</modifiesCas>
+      <multipleDeploymentAllowed>true</multipleDeploymentAllowed>
+      <outputsNewCASes>false</outputsNewCASes>
+    </operationalProperties>
+  </analysisEngineMetaData>
+  <resourceManagerConfiguration/>
+</analysisEngineDescription>

Propchange: ctakes/trunk/ctakes-template-filler/desc/analysis_engine/AggregateTemplateFiller.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ctakes/trunk/ctakes-template-filler/desc/analysis_engine/TemplateFillerAnnotator.xml
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-template-filler/desc/analysis_engine/TemplateFillerAnnotator.xml?rev=1466451&view=auto
==============================================================================
--- ctakes/trunk/ctakes-template-filler/desc/analysis_engine/TemplateFillerAnnotator.xml (added)
+++ ctakes/trunk/ctakes-template-filler/desc/analysis_engine/TemplateFillerAnnotator.xml Wed
Apr 10 12:43:45 2013
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<analysisEngineDescription xmlns="http://uima.apache.org/resourceSpecifier">
+    <frameworkImplementation>org.apache.uima.java</frameworkImplementation>
+    <primitive>true</primitive>
+    <annotatorImplementationName>org.apache.ctakes.templatefiller.ae.TemplateFillerAnnotator</annotatorImplementationName>
+    <analysisEngineMetaData>
+        <name>TemplateFillerAnnotator</name>
+        <description></description>
+        <version>unknown</version>
+        <vendor></vendor>
+        <configurationParameters>
+        </configurationParameters>
+        <configurationParameterSettings>
+        </configurationParameterSettings>
+        <typeSystemDescription/>
+        <fsIndexCollection/>
+        <capabilities/>
+        <operationalProperties>
+            <modifiesCas>true</modifiesCas>
+            <multipleDeploymentAllowed>true</multipleDeploymentAllowed>
+            <outputsNewCASes>false</outputsNewCASes>
+        </operationalProperties>
+    </analysisEngineMetaData>
+</analysisEngineDescription>

Propchange: ctakes/trunk/ctakes-template-filler/desc/analysis_engine/TemplateFillerAnnotator.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ctakes/trunk/ctakes-template-filler/pom.xml
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-template-filler/pom.xml?rev=1466451&view=auto
==============================================================================
--- ctakes/trunk/ctakes-template-filler/pom.xml (added)
+++ ctakes/trunk/ctakes-template-filler/pom.xml Wed Apr 10 12:43:45 2013
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>ctakes-template-filler</artifactId>
+	<name>Apache cTAKES template filler</name>
+	<parent>
+		<groupId>org.apache.ctakes</groupId>
+		<artifactId>ctakes</artifactId>
+		<version>3.1.0-SNAPSHOT</version>
+	</parent>
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.ctakes</groupId>
+			<artifactId>ctakes-type-system</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.ctakes</groupId>
+			<artifactId>ctakes-core</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.ctakes</groupId>
+			<artifactId>ctakes-utils</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>log4j</groupId>
+			<artifactId>log4j</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+		</dependency>
+	</dependencies>
+</project>

Propchange: ctakes/trunk/ctakes-template-filler/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ctakes/trunk/ctakes-template-filler/src/main/java/org/apache/ctakes/templatefiller/ae/TemplateFillerAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-template-filler/src/main/java/org/apache/ctakes/templatefiller/ae/TemplateFillerAnnotator.java?rev=1466451&view=auto
==============================================================================
--- ctakes/trunk/ctakes-template-filler/src/main/java/org/apache/ctakes/templatefiller/ae/TemplateFillerAnnotator.java
(added)
+++ ctakes/trunk/ctakes-template-filler/src/main/java/org/apache/ctakes/templatefiller/ae/TemplateFillerAnnotator.java
Wed Apr 10 12:43:45 2013
@@ -0,0 +1,275 @@
+package org.apache.ctakes.templatefiller.ae;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.apache.uima.UimaContext;
+import org.apache.uima.analysis_component.JCasAnnotator_ImplBase;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.cas.FSIndex;
+import org.apache.uima.cas.FSIndexRepository;
+import org.apache.uima.cas.FSIterator;
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.impl.FeatureImpl;
+import org.apache.uima.cas.text.AnnotationIndex;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.JFSIndexRepository;
+import org.apache.uima.jcas.tcas.Annotation;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.ctakes.typesystem.type.constants.CONST;
+
+import org.apache.ctakes.typesystem.type.refsem.Severity;
+import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation;
+import org.apache.ctakes.typesystem.type.relation.DegreeOfTextRelation;
+import org.apache.ctakes.typesystem.type.relation.LocationOfTextRelation;
+import org.apache.ctakes.typesystem.type.relation.RelationArgument;
+import org.apache.ctakes.typesystem.type.textsem.AnatomicalSiteMention;
+import org.apache.ctakes.typesystem.type.textsem.DiseaseDisorderMention;
+import org.apache.ctakes.typesystem.type.textsem.EntityMention;
+import org.apache.ctakes.typesystem.type.textsem.EventMention;
+import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
+import org.apache.ctakes.typesystem.type.textsem.Modifier;
+import org.apache.ctakes.typesystem.type.textsem.ProcedureMention;
+import org.apache.ctakes.typesystem.type.textsem.SignSymptomMention;
+
+public class TemplateFillerAnnotator extends JCasAnnotator_ImplBase{
+
+    // LOG4J logger based on class name
+    private Logger logger = Logger.getLogger(getClass().getName());
+    private UimaContext uimaContext;
+    private boolean REMOVE_ORIGINAL_MENTIONS = false;
+
+    /**
+     * @param args
+     */
+    public static void main(String[] args) {
+	// For simple tests. 
+	// TODO Move to junit or other test classes later.
+
+    }
+
+    @Override
+    public void initialize(UimaContext aContext) throws ResourceInitializationException {
+
+	super.initialize(aContext);
+	uimaContext = aContext;
+
+	logger.info("Initializing " +  TemplateFillerAnnotator.class.getName());
+	
+    }
+
+    private void setAttributesFromOriginal(IdentifiedAnnotation mention, IdentifiedAnnotation
original) {
+	mention.setBegin(original.getBegin());
+    	mention.setEnd(original.getEnd());
+    	mention.setConditional(original.getConditional());
+    	mention.setConfidence(original.getConfidence());
+    	mention.setDiscoveryTechnique(original.getDiscoveryTechnique());
+    	mention.setGeneric(original.getGeneric());
+    	mention.setOntologyConceptArr(original.getOntologyConceptArr());
+    	mention.setPolarity(original.getPolarity());
+    	mention.setSegmentID(original.getSegmentID());
+    	mention.setSentenceID(original.getSentenceID());
+    	mention.setSubject(original.getSubject());
+    	mention.setTypeID(original.getTypeID());
+    	mention.setUncertainty(original.getUncertainty());
+    	mention.addToIndexes();
+    }
+
+    @Override
+    public void process(JCas jcas) throws AnalysisEngineProcessException {
+	
+	logger.info("process(JCas) in " + TemplateFillerAnnotator.class.getName());
+	
+	// Get all IdentifiedAnnotations
+	FSIterator<Annotation> identifiedAnnotationsIter = getAllAnnotations(jcas, IdentifiedAnnotation.type);
+
+	Map<IdentifiedAnnotation, IdentifiedAnnotation> mapToMentions = new HashMap<IdentifiedAnnotation,
IdentifiedAnnotation>();
+
+	// For each IdentifiedAnnotations, if it is of one of the right types, copy to the appropriate
new subtype
+	List<Annotation> annotationsToRemoveFromCas = new ArrayList<Annotation>(); 
+	while (identifiedAnnotationsIter.hasNext()) {
+	    IdentifiedAnnotation original = (IdentifiedAnnotation)identifiedAnnotationsIter.next();
+	    IdentifiedAnnotation mention = null;
+	    switch (original.getTypeID()) {
+	    
+	    	case CONST.NE_TYPE_ID_ANATOMICAL_SITE: ;
+	    	//org.apache.ctakes.typesystem.type.textsem.AnatomicalSiteMention
+	    	//org.apache.ctakes.typesystem.type.textsem.EntityMention
+	    	mention = new AnatomicalSiteMention(jcas);
+	    	mapToMentions.put(original, mention);
+	    	setAttributesFromOriginal(mention, original);
+	    	annotationsToRemoveFromCas.add(original);
+	    	break;
+    		
+	    	case CONST.NE_TYPE_ID_DISORDER: ;
+	    	//org.apache.ctakes.typesystem.type.textsem.DiseaseDisorderMention
+	    	//org.apache.ctakes.typesystem.type.textsem.EventMention
+	    	mention = new DiseaseDisorderMention(jcas);
+	    	mapToMentions.put(original, mention);
+	    	setAttributesFromOriginal(mention, original);
+	    	annotationsToRemoveFromCas.add(original);
+	    	break;
+    		
+	    	case CONST.NE_TYPE_ID_DRUG: ;
+	    	// TODO use org.apache.ctakes.typesystem.type.textsem.MedicationMention
+	    	//org.apache.ctakes.typesystem.type.textsem.MedicationEventMention
+	    	//org.apache.ctakes.typesystem.type.textsem.EventMention
+
+	    	// TODO is this needed or are we already creating MedicationEventMentions
+	    	//mention = new MedicationEventMention(jcas);
+	    	//mapToMentions.put(original, mention);
+	    	//setAttributesFromOriginal(mention, original);
+	    	//annotationsToRemoveFromCas.add(original);
+	    	break;
+    		
+	    	case CONST.NE_TYPE_ID_FINDING: ; // aka sign/symptom
+	    	//org.apache.ctakes.typesystem.type.textsem.SignSymptomMention
+	    	//org.apache.ctakes.typesystem.type.textsem.EventMention
+	    	mention = new SignSymptomMention(jcas);
+	    	mapToMentions.put(original, mention);
+	    	setAttributesFromOriginal(mention, original);
+	    	annotationsToRemoveFromCas.add(original);
+	    	break;
+    		
+	    	case CONST.NE_TYPE_ID_PROCEDURE: ;
+	    	//org.apache.ctakes.typesystem.type.textsem.ProcedureMention
+	    	//org.apache.ctakes.typesystem.type.textsem.EventMention
+	    	mention = new ProcedureMention(jcas);
+	    	mapToMentions.put(original, mention);
+	    	setAttributesFromOriginal(mention, original);
+	    	annotationsToRemoveFromCas.add(original);
+	    	break;
+    		
+	    	default: ;
+	    	// Some other type of IdentifiedAnnotation such as TimeMention, Modifier, DateMention,
RomanNumeralAnnotation, etc
+	    	// For each those we do nothing in this annotator.
+
+	    }
+	}
+	
+	
+	// Fill in template slots from relations etc
+	logger.info("TODO finish writing code to fill in template slots");
+	
+	FSIndex<FeatureStructure> relationArgs = jcas.getFSIndexRepository().getIndex("_org.apache.ctakes.typesystem.type.relation.RelationArgument_GeneratedIndex");
// TODO do we need this?
+	FSIndex<FeatureStructure> binaryTextRelations = jcas.getFSIndexRepository().getIndex("_org.apache.ctakes.typesystem.type.relation.BinaryTextRelation_GeneratedIndex");
+	int i = 0;
+	if (binaryTextRelations != null) { 
+	    for (FeatureStructure binaryTextRelationFS: binaryTextRelations) {
+		i++;
+		//logger.info("binaryTextRelationFS = " + binaryTextRelationFS);
+		BinaryTextRelation binaryTextRelation = (BinaryTextRelation) binaryTextRelationFS;
+		LocationOfTextRelation locationOfTextRelation = null;
+		DegreeOfTextRelation degreeOfTextRelation = null;
+		if (binaryTextRelation instanceof LocationOfTextRelation) {
+			locationOfTextRelation = (LocationOfTextRelation) binaryTextRelationFS;
+		} else if (binaryTextRelation instanceof DegreeOfTextRelation) {
+			degreeOfTextRelation = (DegreeOfTextRelation) binaryTextRelationFS;
+		}
+		RelationArgument arg1 = binaryTextRelation.getArg1(); // an EntityMention  OR  location
+		RelationArgument arg2 = binaryTextRelation.getArg2(); // a Modifier  OR   what is located
at location
+		String relation = binaryTextRelation.getCategory(); // "degree_of", "location_of"
+
+		if (relation.equals("degree_of")) {
+		    Modifier severity = (Modifier) arg2.getArgument();
+		    // degree_of is aka severity, which applies to SignSymptomMention/SignSymptom and DiseaseDisorder
+		    // find Mention associated with arg1
+		    IdentifiedAnnotation arg1Arg = (IdentifiedAnnotation) arg1.getArgument();
+		    // set severity within the Mention to be arg2 (the Modifier)
+		    // Note at this point mapToMentions.get(entityMention) might be an entityMention instead
of an EventMention
+		    // for example rec041 in the seed set resulted in 
+		    //  ClassCastException: org.apache.ctakes.typesystem.type.textsem.AnatomicalSiteMention

+		    //  cannot be cast to org.apache.ctakes.typesystem.type.textsem.EventMention
+		    IdentifiedAnnotation ia = mapToMentions.get(arg1Arg);
+		    if (ia instanceof EntityMention) {
+                        //	if (ia instanceof AnatomicalSiteMention) {
+                        //	    AnatomicalSiteMention asm = (AnatomicalSiteMention) ia;
+                        //	    asm.setSeverity(severity);
+                        //	} 
+			EntityMention entityMention = (EntityMention) ia;
+			logger.error("Need to implement cases for handling EntityMention " + entityMention + "
within relation: " + relation);
+			logger.error("   severity " + severity + " in relation " + relation + " with/to " + entityMention);
+			logger.error("   Using covered text: severity " + severity.getCoveredText() + " in relation
" + relation + " with/to " + entityMention.getCoveredText());
+		    } else { 
+			EventMention eventMention = (EventMention) ia;
+			if (eventMention instanceof DiseaseDisorderMention) {
+			    DiseaseDisorderMention ddm = (DiseaseDisorderMention) eventMention;
+			    logger.error("Need to implement attr for " + relation + " for DiseaseDisorderMention");
// TODO 
+			} else if (eventMention instanceof SignSymptomMention) {
+			    SignSymptomMention ssm = (SignSymptomMention) eventMention;
+			    ssm.setSeverity(degreeOfTextRelation);
+			} else {
+			    logger.error("Need to implement more cases for handling EventMention " + eventMention
+ " within relation: " + relation);
+			}
+		    }
+		} else if (relation.equals("location_of")) {
+
+		    EntityMention arg2Arg = (EntityMention) arg2.getArgument(); // wrongly created as EntityMention
prior to 3.0
+		    IdentifiedAnnotation ia = mapToMentions.get(arg2Arg);
+		    
+		    if (ia instanceof EntityMention) {
+			// Note you apparently can have an AnatomicalSiteMention be the location_of an AnatomicalSiteMention
+			// from running rec041, end up with things like "Left lower extremity"  location_of "common
femoral vein"
+			// and "left renal vein" in relation location_of to anatomical site mention "renal vein"
+			// and "vein" in relation location_of to anatomical site mention "renal vein"
+			EntityMention entityMention = (EntityMention) ia;
+			IdentifiedAnnotation location = (IdentifiedAnnotation) arg1.getArgument();
+			IdentifiedAnnotation loc = (IdentifiedAnnotation)mapToMentions.get(location);
+			if (loc instanceof AnatomicalSiteMention) { 
+			    AnatomicalSiteMention asm = (AnatomicalSiteMention) loc;
+			    //asm.setBodyLocation(binaryTextRelation); // uncomment iff AnatomicalSiteMention
ends up with a bodyLocation attribute
+			} else {
+			    logger.error("Need to implement cases for handling EntityMention " + entityMention
+ " within relation: " + relation);
+			    logger.error("   loc " + loc + " in relation " + relation + " with/to " + entityMention);
+			    logger.error("   Using covered text: loc " + loc.getCoveredText() + " in relation
" + relation + " with/to " + entityMention.getCoveredText());
+			}
+			
+		    } else { 
+			EventMention eventMention = (EventMention) ia;
+
+			if (eventMention.getTypeID()==CONST.NE_TYPE_ID_DISORDER) { // TODO in 3.0 consider using
arg2 instanceof DiseaseDisorderMention?
+			    DiseaseDisorderMention ddm = (DiseaseDisorderMention) eventMention;
+			    
+			    ddm.setBodyLocation(locationOfTextRelation);
+			} else if (eventMention.getTypeID()==CONST.NE_TYPE_ID_PROCEDURE) { // TODO in 3.0 consider
using arg2 instanceof ProcedureMention?
+			    ProcedureMention pm = (ProcedureMention) eventMention;
+			    pm.setBodyLocation(locationOfTextRelation);
+			} else if (eventMention.getTypeID()==CONST.NE_TYPE_ID_FINDING) { // TODO in 3.0 consider
using arg2 instanceof SignSymptomMention?
+			    SignSymptomMention ssm = (SignSymptomMention) eventMention;
+			    ssm.setBodyLocation(locationOfTextRelation);
+			} else {
+			    logger.error("Need to implement more cases for handling EventMention " + eventMention
+ " within relation: " + relation);
+			}
+		    }
+		} else {
+		    logger.error("Need to implement more cases for relation: " + relation);
+		}
+	    }
+	}
+	logger.info("Number of BinaryTextRelations = " + i);
+	 
+	
+	if (REMOVE_ORIGINAL_MENTIONS) {
+	    // Remove the annotations we no longer need
+	    for (Annotation anno: annotationsToRemoveFromCas) {
+		jcas.removeFsFromIndexes(anno);
+	    }
+	}
+	
+	
+    }
+
+    private FSIterator<Annotation> getAllAnnotations(JCas jcas, int type) {
+	JFSIndexRepository indexes = jcas.getJFSIndexRepository();
+	FSIterator<Annotation> annotationsIter = indexes.getAnnotationIndex(type).iterator();
+        //	while (segmentItr.hasNext()) {
+        //	}
+	return annotationsIter;
+    }
+
+
+}

Propchange: ctakes/trunk/ctakes-template-filler/src/main/java/org/apache/ctakes/templatefiller/ae/TemplateFillerAnnotator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message