ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seanfi...@apache.org
Subject svn commit: r1778462 - in /ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline: PipelineBuilder.java PiperFileReader.java
Date Thu, 12 Jan 2017 20:30:37 GMT
Author: seanfinan
Date: Thu Jan 12 20:30:37 2017
New Revision: 1778462

URL: http://svn.apache.org/viewvc?rev=1778462&view=rev
Log:
Add an ae or cc to the end of a pipeline.  Good for cleanup when a pipeline is meant to be
extended.

Modified:
    ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/PipelineBuilder.java
    ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/PiperFileReader.java

Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/PipelineBuilder.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/PipelineBuilder.java?rev=1778462&r1=1778461&r2=1778462&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/PipelineBuilder.java
(original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/PipelineBuilder.java
Thu Jan 12 20:30:37 2017
@@ -34,14 +34,17 @@ final public class PipelineBuilder {
 
    static private final Logger LOGGER = Logger.getLogger( "PipelineBuilder" );
 
-
+   private CollectionReader _reader;
    private final List<String> _aeNameList;
    private final List<AnalysisEngineDescription> _descList;
-   private CollectionReader _reader;
+   private final List<String> _aeEndNameList;
+   private final List<AnalysisEngineDescription> _descEndList;
 
    public PipelineBuilder() {
       _aeNameList = new ArrayList<>();
       _descList = new ArrayList<>();
+      _aeEndNameList = new ArrayList<>();
+      _descEndList = new ArrayList<>();
    }
 
    /**
@@ -144,11 +147,28 @@ final public class PipelineBuilder {
    }
 
    /**
+    * Adds an ae or cc component t othe very end of the pipeline.  Use of this method is
order-specific.
+    *
+    * @param component  ae or cc component class to add to the end of the pipeline
+    * @param parameters ae or cc parameter name value pairs.  May be empty.
+    * @return this PipelineBuilder
+    * @throws ResourceInitializationException if the component cannot be created
+    */
+   public PipelineBuilder addLast( final Class<? extends AnalysisComponent> component,
+                                   final Object... parameters ) throws ResourceInitializationException
{
+      _aeEndNameList.add( component.getName() );
+      _descEndList.add( PropertyAeFactory.getInstance().createDescription( component, parameters
) );
+      return this;
+   }
+
+   /**
     *
     * @return an ordered list of the annotation engines in the pipeline
     */
    public List<String> getAeNames() {
-      return Collections.unmodifiableList( _aeNameList );
+      final List<String> allNames = new ArrayList<>( _aeNameList );
+      allNames.addAll( _aeEndNameList );
+      return Collections.unmodifiableList( allNames );
    }
 
    /**
@@ -214,6 +234,7 @@ final public class PipelineBuilder {
       }
       final AggregateBuilder builder = new AggregateBuilder();
       _descList.forEach( builder::add );
+      _descEndList.forEach( builder::add );
       final AnalysisEngineDescription desc = builder.createAggregateDescription();
       SimplePipeline.runPipeline( _reader, desc );
       return this;
@@ -237,6 +258,7 @@ final public class PipelineBuilder {
       jcas.setDocumentText( text );
       final AggregateBuilder builder = new AggregateBuilder();
       _descList.forEach( builder::add );
+      _descEndList.forEach( builder::add );
       final AnalysisEngineDescription desc = builder.createAggregateDescription();
       SimplePipeline.runPipeline( jcas, desc );
       return this;

Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/PiperFileReader.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/PiperFileReader.java?rev=1778462&r1=1778461&r2=1778462&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/PiperFileReader.java
(original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/pipeline/PiperFileReader.java
Thu Jan 12 20:30:37 2017
@@ -229,7 +229,16 @@ final public class PiperFileReader {
                _builder.addDescription( description );
             }
             break;
-
+         case "addLast":
+            if ( hasParameters( parameter ) ) {
+               final String[] component_parameters = splitFromParameters( parameter );
+               final String component = component_parameters[ 0 ];
+               final Object[] parameters = splitParameters( component_parameters[ 1 ] );
+               _builder.addLast( getComponentClass( component ), parameters );
+            } else {
+               _builder.addLast( getComponentClass( parameter ) );
+            }
+            break;
          case "collectCuis":
             _builder.collectCuis();
             break;



Mime
View raw message