ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seanfi...@apache.org
Subject svn commit: r1830586 - in /ctakes/trunk: ctakes-core/src/main/java/org/apache/ctakes/core/patient/ ctakes-coreference/src/main/java/org/apache/ctakes/coreference/ae/
Date Mon, 30 Apr 2018 13:09:28 GMT
Author: seanfinan
Date: Mon Apr 30 13:09:27 2018
New Revision: 1830586

URL: http://svn.apache.org/viewvc?rev=1830586&view=rev
Log:
Add capability to register coref engine with both default and training version.

Modified:
    ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/patient/AbstractPatientConsumer.java
    ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/patient/PatientNoteStore.java
    ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/ae/MentionClusterCoreferenceAnnotator.java
    ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/ae/PatientMentionClusterCoreferencer.java

Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/patient/AbstractPatientConsumer.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/patient/AbstractPatientConsumer.java?rev=1830586&r1=1830585&r2=1830586&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/patient/AbstractPatientConsumer.java
(original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/patient/AbstractPatientConsumer.java
Mon Apr 30 13:09:27 2018
@@ -4,10 +4,12 @@ import org.apache.ctakes.core.ae.NamedEn
 import org.apache.ctakes.core.pipeline.PipeBitInfo;
 import org.apache.ctakes.core.util.SourceMetadataUtil;
 import org.apache.log4j.Logger;
+import org.apache.uima.UimaContext;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
 import org.apache.uima.fit.descriptor.ConfigurationParameter;
 import org.apache.uima.jcas.JCas;
+import org.apache.uima.resource.ResourceInitializationException;
 
 import java.util.Collection;
 
@@ -24,7 +26,8 @@ import java.util.Collection;
  */
 @PipeBitInfo(
       name = "AbstractPatientConsumer",
-      description = "Abstract Engine to take action on a patient level instead of document
level.", role = PipeBitInfo.Role.ANNOTATOR
+      description = "Abstract Engine to take action on a patient level instead of document
level.",
+      role = PipeBitInfo.Role.ANNOTATOR
 )
 abstract public class AbstractPatientConsumer extends JCasAnnotator_ImplBase implements NamedEngine
{
 
@@ -43,6 +46,14 @@ abstract public class AbstractPatientCon
    protected AbstractPatientConsumer( final String aeName, final String action ) {
       _action = action;
       _logger = Logger.getLogger( aeName );
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void initialize( final UimaContext context ) throws ResourceInitializationException
{
+      super.initialize( context );
       PatientNoteStore.getInstance().registerEngine( getEngineName() );
    }
 

Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/patient/PatientNoteStore.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/patient/PatientNoteStore.java?rev=1830586&r1=1830585&r2=1830586&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/patient/PatientNoteStore.java
(original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/patient/PatientNoteStore.java
Mon Apr 30 13:09:27 2018
@@ -1,6 +1,7 @@
 package org.apache.ctakes.core.patient;
 
 
+import org.apache.ctakes.core.ae.NamedEngine;
 import org.apache.ctakes.core.util.DocumentIDAnnotationUtil;
 import org.apache.ctakes.core.util.SourceMetadataUtil;
 import org.apache.ctakes.typesystem.type.structured.DocumentIdPrefix;
@@ -36,10 +37,15 @@ public enum PatientNoteStore {
 
    static private final String GENERIC_PATIENT = "Generic";
 
+   // Collection of annotation engines (by some id) that consume patients
    private final Collection<String> _registeredEngines;
+   // Map of Patient Name (id) to registered engines that have already consumed the patient
    private final Map<String, Collection<String>> _enginesRun;
+   // Map of patient id to patient jcas
    private final Map<String, JCas> _patientMap;
+   // Map of Patient Name (id) to ViewInfo objects - metadata for jCas views
    private final Map<String, Collection<ViewInfo>> _patientViewInfos;
+   // Map of Patient Name (id) to document count for that patient.  Required to remove cached
patient after last pop()
    private final Map<String, Integer> _wantedDocCounts;
 
    /**
@@ -55,19 +61,30 @@ public enum PatientNoteStore {
 
    /////////////////    Get available patient, document, view names   ///////////////
 
+   /**
+    * @param engineName name of engine that consumes patients
+    */
    synchronized public void registerEngine( final String engineName ) {
       _registeredEngines.add( engineName );
    }
 
    /**
+    *
+    * @param namedEngine engine that consumes patients
+    */
+   synchronized public void registerEngine( final NamedEngine namedEngine ) {
+      registerEngine( namedEngine.getEngineName() );
+   }
+
+   /**
     * @deprecated use pop methods
     * @return identifiers for all stored patients
     */
    @Deprecated
    synchronized public Collection<String> getStoredPatientIds() {
       return _patientMap.keySet().stream()
-            .sorted()
-            .collect( Collectors.toList() );
+                        .sorted()
+                        .collect( Collectors.toList() );
    }
 
    /**

Modified: ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/ae/MentionClusterCoreferenceAnnotator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/ae/MentionClusterCoreferenceAnnotator.java?rev=1830586&r1=1830585&r2=1830586&view=diff
==============================================================================
--- ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/ae/MentionClusterCoreferenceAnnotator.java
(original)
+++ ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/ae/MentionClusterCoreferenceAnnotator.java
Mon Apr 30 13:09:27 2018
@@ -1,5 +1,6 @@
 package org.apache.ctakes.coreference.ae;
 
+import org.apache.ctakes.core.ae.NamedEngine;
 import org.apache.ctakes.core.patient.PatientViewUtil;
 import org.apache.ctakes.core.pipeline.PipeBitInfo;
 import org.apache.ctakes.core.util.DotLogger;
@@ -12,7 +13,6 @@ import org.apache.ctakes.coreference.uti
 import org.apache.ctakes.dependency.parser.util.DependencyUtility;
 import org.apache.ctakes.relationextractor.ae.features.RelationFeaturesExtractor;
 import org.apache.ctakes.relationextractor.eval.RelationExtractorEvaluation.HashableArguments;
-import org.apache.ctakes.temporal.utils.PatientViewsUtil;
 import org.apache.ctakes.typesystem.type.refsem.*;
 import org.apache.ctakes.typesystem.type.relation.CollectionTextRelation;
 import org.apache.ctakes.typesystem.type.relation.CollectionTextRelationIdentifiedAnnotationRelation;
@@ -25,7 +25,6 @@ import org.apache.log4j.Logger;
 import org.apache.uima.UimaContext;
 import org.apache.uima.analysis_engine.AnalysisEngineDescription;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
-import org.apache.uima.cas.CASException;
 import org.apache.uima.fit.descriptor.ConfigurationParameter;
 import org.apache.uima.fit.factory.AnalysisEngineFactory;
 import org.apache.uima.fit.util.JCasUtil;
@@ -57,7 +56,7 @@ import static org.apache.ctakes.corefere
         dependencies = { BASE_TOKEN, SENTENCE, SECTION, IDENTIFIED_ANNOTATION, MARKABLE },
         products = { COREFERENCE_RELATION }
 )
-public class MentionClusterCoreferenceAnnotator extends CleartkAnnotator<String> {
+public class MentionClusterCoreferenceAnnotator extends CleartkAnnotator<String> implements
NamedEngine {
   static private final Logger LOGGER = Logger.getLogger( MentionClusterCoreferenceAnnotator.class.getSimpleName()
);
 
   public static final String NO_RELATION_CATEGORY = "-NONE-";
@@ -135,6 +134,18 @@ public class MentionClusterCoreferenceAn
 
 //  private Set<String> markableStrings = null;
 
+   /**
+    * @return the simple name f this class or that name with "_Training" appending if the
annotator is for training.
+    */
+   @Override
+   public String getEngineName() {
+      final String simpleName = getClass().getSimpleName();
+      if ( isTraining() ) {
+         return simpleName + "_Training";
+      }
+      return simpleName;
+   }
+
   protected List<RelationFeaturesExtractor<CollectionTextRelation,IdentifiedAnnotation>>
getFeatureExtractors() {
     List<RelationFeaturesExtractor<CollectionTextRelation,IdentifiedAnnotation>>
extractors = new ArrayList<>();
     extractors.add(new MentionClusterAgreementFeaturesExtractor());

Modified: ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/ae/PatientMentionClusterCoreferencer.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/ae/PatientMentionClusterCoreferencer.java?rev=1830586&r1=1830585&r2=1830586&view=diff
==============================================================================
--- ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/ae/PatientMentionClusterCoreferencer.java
(original)
+++ ctakes/trunk/ctakes-coreference/src/main/java/org/apache/ctakes/coreference/ae/PatientMentionClusterCoreferencer.java
Mon Apr 30 13:09:27 2018
@@ -32,8 +32,16 @@ public class PatientMentionClusterCorefe
     */
    @Override
    public void initialize( final UimaContext context ) throws ResourceInitializationException
{
-      super.initialize( context );
       _delegate.initialize( context );
+      super.initialize( context );
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public String getEngineName() {
+      return _delegate.getEngineName();
    }
 
    /**



Mime
View raw message