You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2020/03/24 10:38:35 UTC

[uima-uimafit] 01/01: Merge branch 'master-v2'

This is an automated email from the ASF dual-hosted git repository.

rec pushed a commit to branch merge/master-v2-to-master
in repository https://gitbox.apache.org/repos/asf/uima-uimafit.git

commit fe82a17571fd3bd79a37ffad29f7405c301ed28e
Merge: b21df4e a90e934
Author: Richard Eckart de Castilho <re...@apache.org>
AuthorDate: Tue Mar 24 11:37:11 2020 +0100

    Merge branch 'master-v2'
    
    * master-v2:
      [UIMA-6207] Allow setting number of threads in CpePipeline
      [UIMA-6206] Parameter values with certain non-XML 1.0 characters not supported
      [UIMA-6204] createReaderDescription does not discover type priorities
    
    # Conflicts:
    #	uimafit-core/src/test/java/org/apache/uima/fit/factory/TypePrioritiesFactoryTest.java
    #	uimafit-cpe/src/main/java/org/apache/uima/fit/cpe/CpePipeline.java

 .../uima/fit/factory/CollectionReaderFactory.java  | 13 +++--
 .../fit/factory/AnalysisEngineFactoryTest.java     | 45 +++++++++++++----
 .../fit/factory/CollectionReaderFactoryTest.java   | 59 ++++++++++++++++++----
 .../fit/factory/TypePrioritiesFactoryTest.java     |  9 ++--
 .../java/org/apache/uima/fit/cpe/CpeBuilder.java   | 16 ++++--
 .../java/org/apache/uima/fit/cpe/CpePipeline.java  | 38 +++++++++++++-
 6 files changed, 150 insertions(+), 30 deletions(-)

diff --cc uimafit-core/src/test/java/org/apache/uima/fit/factory/TypePrioritiesFactoryTest.java
index e50a6d7,97e0eaf..8d2978a
--- a/uimafit-core/src/test/java/org/apache/uima/fit/factory/TypePrioritiesFactoryTest.java
+++ b/uimafit-core/src/test/java/org/apache/uima/fit/factory/TypePrioritiesFactoryTest.java
@@@ -42,31 -44,20 +43,33 @@@ public class TypePrioritiesFactoryTest 
  
      CasCreationUtils.createCas(createTypeSystemDescription(), prio, null);
  
 -    assertEquals(1, prio.getPriorityLists().length);
 -    assertEquals(1, prio.getPriorityLists()[0].getTypes().length);
 -    assertEquals("uima.tcas.Annotation", prio.getPriorityLists()[0].getTypes()[0]);
 +    assertThat(prio.getPriorityLists()).hasSize(1);
 +    assertThat(prio.getPriorityLists()[0].getTypes()).containsExactly(CAS.TYPE_NAME_ANNOTATION);
    }
    
 +  @Test
 +  public void testCreateTypePrioritiesFromClasses() throws Exception {
 +    TypePriorities prio = createTypePriorities(Annotation.class);
 +
 +    CasCreationUtils.createCas(createTypeSystemDescription(), prio, null);
  
 +    assertThat(prio.getPriorityLists()).hasSize(1);
 +    assertThat(prio.getPriorityLists()[0].getTypes()).containsExactly(CAS.TYPE_NAME_ANNOTATION);
 +  }
 +  
 +  @Test(expected = IllegalArgumentException.class)
 +  public void testCreateTypePrioritiesFromBadClasses() throws Exception {
 +    TypePriorities prio = createTypePriorities((Class) Integer.class);
 +  }
 +  
    @Test
    public void testAutoDetectTypePriorities() throws Exception {
 -    TypePriorities typePriorities = createTypePriorities();
 +    TypePriorities prio = createTypePriorities();
  
-     assertThat(prio.getPriorityLists()).hasSize(1);
-     assertThat(prio.getPriorityLists()[0].getTypes()).containsExactly(Sentence.class.getName(),
-             Token.class.getName());
 -    TypePriorityList[] typePrioritiesLists = typePriorities.getPriorityLists();
++    TypePriorityList[] typePrioritiesLists = prio.getPriorityLists();
+     assertThat(typePrioritiesLists.length).isEqualTo(1);
+     assertThat(typePrioritiesLists[0].getTypes())
+         .as("Type priorities auto-detection")
+         .containsExactly(Sentence.class.getName(), Token.class.getName());
    }
  }
diff --cc uimafit-cpe/src/main/java/org/apache/uima/fit/cpe/CpePipeline.java
index 9089937,056cee2..d62e916
--- a/uimafit-cpe/src/main/java/org/apache/uima/fit/cpe/CpePipeline.java
+++ b/uimafit-cpe/src/main/java/org/apache/uima/fit/cpe/CpePipeline.java
@@@ -44,8 -44,38 +46,40 @@@ public final class CpePipeline 
    }
    
    /**
+    * Run the CollectionReader and AnalysisEngines as a multi-threaded pipeline. This call uses
+    * a number of threads equal to the number of available processors (as reported by Java, so 
+    * usually boiling down to cores) minus 1 - minimum of 1.
+    * 
+    * @param readerDesc
+    *          The CollectionReader that loads the documents into the CAS.
+    * @param descs
+    *          Primitive AnalysisEngineDescriptions that process the CAS, in order. If you have a mix
+    *          of primitive and aggregate engines, then please create the AnalysisEngines yourself
+    *          and call the other runPipeline method.
+    * @throws SAXException
+    *           if there was a XML-related problem materializing the component descriptors that are
+    *           referenced from the CPE descriptor
+    * @throws IOException
+    *           if there was a I/O-related problem materializing the component descriptors that are
+    *           referenced from the CPE descriptor
+    * @throws CpeDescriptorException
+    *           if there was a problem configuring the CPE descriptor
+    * @throws UIMAException
+    *           if there was a problem initializing or running the CPE.
 -   */  public static void runPipeline(final CollectionReaderDescription readerDesc,
++   */
++  public static void runPipeline(final CollectionReaderDescription readerDesc,
+           final AnalysisEngineDescription... descs)
 -          throws UIMAException, SAXException, CpeDescriptorException, IOException {
++          throws SAXException, CpeDescriptorException, IOException, ResourceInitializationException,
++          InvalidXMLException, AnalysisEngineProcessException {
+ 
+     runPipeline(Math.max(1, getRuntime().availableProcessors() - 1), readerDesc, descs);
+   }
+ 
+   /**
     * Run the CollectionReader and AnalysisEngines as a multi-threaded pipeline.
     * 
+    * @param parallelism
+    *          Number of threads to use when running the analysis engines in the CPE.
     * @param readerDesc
     *          The CollectionReader that loads the documents into the CAS.
     * @param descs
@@@ -60,17 -90,12 +94,17 @@@
     *           referenced from the CPE descriptor
     * @throws CpeDescriptorException
     *           if there was a problem configuring the CPE descriptor
 -   * @throws UIMAException
 +   * @throws ResourceInitializationException 
 +   *           if there was a problem initializing or running the CPE.
 +   * @throws InvalidXMLException 
     *           if there was a problem initializing or running the CPE.
 +   * @throws AnalysisEngineProcessException 
 +   *           if there was a problem running the CPE.
     */
-   public static void runPipeline(final CollectionReaderDescription readerDesc,
-           final AnalysisEngineDescription... descs)
+   public static void runPipeline(final int parallelism,
+           final CollectionReaderDescription readerDesc, final AnalysisEngineDescription... descs)
 -          throws UIMAException, SAXException, CpeDescriptorException, IOException {
 +          throws SAXException, CpeDescriptorException, IOException, ResourceInitializationException,
 +          InvalidXMLException, AnalysisEngineProcessException {
      // Create AAE
      final AnalysisEngineDescription aaeDesc = createEngineDescription(descs);