ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seanfi...@apache.org
Subject svn commit: r1764580 - in /ctakes/trunk/ctakes-examples/src/main: java/org/apache/ctakes/examples/pipeline/ resources/org/apache/ctakes/examples/pipeline/
Date Thu, 13 Oct 2016 04:29:04 GMT
Author: seanfinan
Date: Thu Oct 13 04:29:04 2016
New Revision: 1764580

URL: http://svn.apache.org/viewvc?rev=1764580&view=rev
Log:
New Examples

Added:
    ctakes/trunk/ctakes-examples/src/main/java/org/apache/ctakes/examples/pipeline/HelloWorldCuiReadPipeRunner.java
    ctakes/trunk/ctakes-examples/src/main/java/org/apache/ctakes/examples/pipeline/HelloWorldPropsReadPipeRunner.java
    ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/AssertionDefaults.properties
    ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldAssertPropsPipeline.txt
    ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldCuiPipeline.txt
    ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldPropsPipeline.txt
    ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldTkPropsPipeline.txt

Added: ctakes/trunk/ctakes-examples/src/main/java/org/apache/ctakes/examples/pipeline/HelloWorldCuiReadPipeRunner.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-examples/src/main/java/org/apache/ctakes/examples/pipeline/HelloWorldCuiReadPipeRunner.java?rev=1764580&view=auto
==============================================================================
--- ctakes/trunk/ctakes-examples/src/main/java/org/apache/ctakes/examples/pipeline/HelloWorldCuiReadPipeRunner.java
(added)
+++ ctakes/trunk/ctakes-examples/src/main/java/org/apache/ctakes/examples/pipeline/HelloWorldCuiReadPipeRunner.java
Thu Oct 13 04:29:04 2016
@@ -0,0 +1,55 @@
+package org.apache.ctakes.examples.pipeline;
+
+
+import org.apache.ctakes.core.pipeline.CuiCollector;
+import org.apache.ctakes.core.pipeline.PipelineBuilder;
+import org.apache.ctakes.core.pipeline.PipelineReader;
+import org.apache.log4j.Logger;
+import org.apache.uima.UIMAException;
+
+import java.io.IOException;
+
+/**
+ * Build and run a pipeline using a {@link PipelineReader} and a {@link PipelineBuilder}.
+ * <p>
+ * Example of a running a pipeline programatically w/o uima xml descriptor xml files
+ * Adds the default Tokenization pipeline and adding the Example HelloWorld Annotator
+ *
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 10/10/2016
+ */
+final public class HelloWorldCuiReadPipeRunner {
+
+   static private final Logger LOGGER = Logger.getLogger( "HelloWorldReadPipeRunner" );
+
+   static private final String PIPELINE_FILE_PATH = "org/apache/ctakes/examples/pipeline/HelloWorldCuiPipeline.txt";
+
+   static private final String DOC_TEXT = "Hello World!  I have allergies to nuts, bee stings,
and shark bites.";
+
+   private HelloWorldCuiReadPipeRunner() {
+   }
+
+   /**
+    * @param args an output directory for xmi files or none if xmi files are not wanted
+    */
+   public static void main( final String... args ) {
+      try {
+         // Add a simple pre-defined existing pipeline for Tokenization from file
+         final PipelineReader reader = new PipelineReader( PIPELINE_FILE_PATH );
+         PipelineBuilder builder = reader.getBuilder();
+         if ( args.length > 0 ) {
+            // Example to save the Aggregate descriptor to an xml file for external use such
as the UIMA CVD
+            builder.writeXMIs( args[ 0 ] );
+         }
+         // Run the pipeline with specified text
+         builder.run( DOC_TEXT );
+      } catch ( IOException | UIMAException multE ) {
+         LOGGER.error( multE.getMessage() );
+      }
+      // Log the IdentifiedAnnotation objects
+      LOGGER.info( "\n" + CuiCollector.getInstance().toString() );
+   }
+
+
+}

Added: ctakes/trunk/ctakes-examples/src/main/java/org/apache/ctakes/examples/pipeline/HelloWorldPropsReadPipeRunner.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-examples/src/main/java/org/apache/ctakes/examples/pipeline/HelloWorldPropsReadPipeRunner.java?rev=1764580&view=auto
==============================================================================
--- ctakes/trunk/ctakes-examples/src/main/java/org/apache/ctakes/examples/pipeline/HelloWorldPropsReadPipeRunner.java
(added)
+++ ctakes/trunk/ctakes-examples/src/main/java/org/apache/ctakes/examples/pipeline/HelloWorldPropsReadPipeRunner.java
Thu Oct 13 04:29:04 2016
@@ -0,0 +1,58 @@
+package org.apache.ctakes.examples.pipeline;
+
+
+import org.apache.ctakes.core.pipeline.EntityCollector;
+import org.apache.ctakes.core.pipeline.PipelineBuilder;
+import org.apache.ctakes.core.pipeline.PipelineReader;
+import org.apache.log4j.Logger;
+import org.apache.uima.UIMAException;
+
+import java.io.IOException;
+
+/**
+ * Build and run a pipeline using a {@link PipelineReader} and a {@link PipelineBuilder}.
+ * <p>
+ * Example of a running a pipeline programatically w/o uima xml descriptor xml files
+ * Adds the default Tokenization pipeline and adding the Example HelloWorld Annotator
+ *
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 10/10/2016
+ */
+final public class HelloWorldPropsReadPipeRunner {
+
+   static private final Logger LOGGER = Logger.getLogger( "HelloWorldReadPipeRunner" );
+
+   static private final String PROPS_PIPELINE_FILE_PATH
+         = "org/apache/ctakes/examples/pipeline/HelloWorldAssertPropsPipeline.txt";
+
+   static private final String DOC_TEXT
+         = "Hello World!  I feel no pain.  My father takes aspirin.  My sister might have
a headache.";
+
+   private HelloWorldPropsReadPipeRunner() {
+   }
+
+   /**
+    * @param args an output directory for xmi files or none if xmi files are not wanted
+    */
+   public static void main( final String... args ) {
+      try {
+         // Add a simple pre-defined existing pipeline for Tokenization from file
+         final PipelineReader reader = new PipelineReader( PROPS_PIPELINE_FILE_PATH );
+         // Add the property extraction pipeline
+         PipelineBuilder builder = reader.getBuilder();
+         if ( args.length > 0 ) {
+            // Example to save the Aggregate descriptor to an xml file for external use such
as the UIMA CVD
+            builder.writeXMIs( args[ 0 ] );
+         }
+         // Run the pipeline with specified text
+         builder.run( DOC_TEXT );
+      } catch ( IOException | UIMAException multE ) {
+         LOGGER.error( multE.getMessage() );
+      }
+      // Log the IdentifiedAnnotation objects
+      LOGGER.info( "\n" + EntityCollector.getInstance().toString() );
+   }
+
+
+}

Added: ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/AssertionDefaults.properties
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/AssertionDefaults.properties?rev=1764580&view=auto
==============================================================================
--- ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/AssertionDefaults.properties
(added)
+++ ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/AssertionDefaults.properties
Thu Oct 13 04:29:04 2016
@@ -0,0 +1,6 @@
+# Parameters for AssertionAnalysisEngine and ConceptConverterAnalysisEngine
+assertionModelResourceImpl=file:org/apache/ctakes/assertion/models/i2b2.model
+scopeModelResourceImpl=file:org/apache/ctakes/assertion/models/scope.model
+cueModelResourceImpl=file:org/apache/ctakes/assertion/models/cue.model
+enabledFeaturesResourceImpl=file:org/apache/ctakes/assertion/models/featureFile11b
+posModelResourceImpl=file:org/apache/ctakes/assertion/models/pos.model

Added: ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldAssertPropsPipeline.txt
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldAssertPropsPipeline.txt?rev=1764580&view=auto
==============================================================================
--- ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldAssertPropsPipeline.txt
(added)
+++ ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldAssertPropsPipeline.txt
Thu Oct 13 04:29:04 2016
@@ -0,0 +1,20 @@
+// This file contains commands and parameters to run the ctakes-examples "Hello World" pipeline
+// with Entity Property output
+
+// Load a simple token processing pipeline from another file
+load org/apache/ctakes/examples/pipeline/HelloWorldPipeline.txt
+
+// Assertion engines require dependencies
+addDescription ClearNLPDependencyParserAE
+
+// Use the assertion mini pipeline
+// load parameters used by the following engines
+loadParameters org/apache/ctakes/examples/pipeline/AssertionDefaults.properties
+// the engines ...
+add medfacts.AssertionAnalysisEngine
+add medfacts.ConceptConverterAnalysisEngine
+add attributes.SubjectAttributeAnalysisEngine
+add attributes.GenericAttributeAnalysisEngine
+
+// Collect discovered Entity information for post-run access
+collectEntities

Added: ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldCuiPipeline.txt
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldCuiPipeline.txt?rev=1764580&view=auto
==============================================================================
--- ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldCuiPipeline.txt
(added)
+++ ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldCuiPipeline.txt
Thu Oct 13 04:29:04 2016
@@ -0,0 +1,16 @@
+// This file contains commands and parameters to run the ctakes-examples "Hello World" pipeline
+// with UMLS Concept Unique Identifiers (CUI) output
+
+// Equivalent of ClinicalPipelineFactory.getTokenProcessingPipeline()
+add SimpleSegmentAnnotator
+add SentenceDetector
+add TokenizerAnnotatorPTB
+add ContextDependentTokenizerAnnotator
+// The POSTagger has a -complex- startup, but it can create its own description to handle
it
+addDescription POSTagger
+
+// Default fast dictionary lookup
+add DefaultJCasTermAnnotator
+
+// Collect discovered UMLS Concept Unique Identifiers (CUI) for post-run information
+collectCuis

Added: ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldPropsPipeline.txt
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldPropsPipeline.txt?rev=1764580&view=auto
==============================================================================
--- ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldPropsPipeline.txt
(added)
+++ ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldPropsPipeline.txt
Thu Oct 13 04:29:04 2016
@@ -0,0 +1,14 @@
+// This file contains commands and parameters to run the ctakes-examples "Hello World" pipeline
+// with Entity Property output
+
+// Load a simple token processing pipeline from another file
+load org/apache/ctakes/examples/pipeline/HelloWorldPipeline.txt
+
+// Add the context annotator for simple annotation properties
+// The default call sets it to detect negation
+add ContextAnnotator
+// It can also detect Status if you change some parameters from the defaults
+add ContextAnnotator ContextAnalyzerClass=org.apache.ctakes.necontexts.status.StatusContextAnalyzer
ContextHitConsumerClass=org.apache.ctakes.necontexts.status.StatusContextHitConsumer MaxLeftScopeSize=10
MaxRightScopeSize=10
+
+// Collect discovered Entity information for post-run access
+collectEntities

Added: ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldTkPropsPipeline.txt
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldTkPropsPipeline.txt?rev=1764580&view=auto
==============================================================================
--- ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldTkPropsPipeline.txt
(added)
+++ ctakes/trunk/ctakes-examples/src/main/resources/org/apache/ctakes/examples/pipeline/HelloWorldTkPropsPipeline.txt
Thu Oct 13 04:29:04 2016
@@ -0,0 +1,23 @@
+// This file contains commands and parameters to run the ctakes-examples "Hello World" pipeline
+// with Entity Property output
+
+// Load a simple token processing pipeline from another file
+load org/apache/ctakes/examples/pipeline/HelloWorldPipeline.txt
+
+// I don't think that the chunker is strictly necessary, but here it is ...
+add Chunker
+addDescription adjuster.ChunkAdjuster NP,NP 1
+addDescription adjuster.ChunkAdjuster NP,PP,NP 2
+
+addDescription ClearNLPDependencyParserAE
+// Add the cleartk package for future class lookups
+addPackage org.apache.ctakes.assertion.medfacts.cleartk
+addDescription PolarityCleartkAnalysisEngine
+addDescription UncertaintyCleartkAnalysisEngine
+addDescription HistoryCleartkAnalysisEngine
+addDescription ConditionalCleartkAnalysisEngine
+addDescription GenericCleartkAnalysisEngine
+addDescription SubjectCleartkAnalysisEngine
+
+// Collect discovered Entity information for post-run access
+collectEntities



Mime
View raw message