Package org.apache.uima.collection

Examples of org.apache.uima.collection.CollectionProcessingEngine


   * @return CollectionProcessingEngine - initialized cpe
   */
  private CollectionProcessingEngine setupCpm(int documentCount, String exceptionName,
          int exceptionSequence, String functionName) {
    CpeDescription cpeDesc = null;
    CollectionProcessingEngine cpe = null;

    try {
      String colReaderBase = JUnitExtension.getFile(
              "CpmTests" + FS + "ErrorTestCollectionReader.xml").getAbsolutePath();
      String taeBase = JUnitExtension.getFile("CpmTests" + FS + "ErrorTestAnnotator.xml")
View Full Code Here


      params.put(Resource.PARAM_PERFORMANCE_TUNING_SETTINGS, newProps);

      CpeDescription cpeDesc = UIMAFramework.getXMLParser().parseCpeDescription(
    new XMLInputSource(JUnitExtension
        .getFile("CollectionProcessingEngineImplTest/performanceTuningSettingsTestCpe.xml")));
      CollectionProcessingEngine cpe = UIMAFramework.produceCollectionProcessingEngine(cpeDesc,
    params);
      cpe.process();
      // Need to give CPE time to do its work. The following should work, but
      // doesn't
      // while (cpe.isProcessing())
      // {
      // Thread.sleep(1000);
View Full Code Here

      ResourceManager rm = UIMAFramework.newDefaultResourceManager();
      rm.setDataPath(TEST_DATAPATH);
      CpeDescription cpeDesc = UIMAFramework.getXMLParser().parseCpeDescription(
    new XMLInputSource(JUnitExtension
        .getFile("CollectionProcessingEngineImplTest/externalResourceTestCpe.xml")));
      CollectionProcessingEngine cpe = UIMAFramework.produceCollectionProcessingEngine(cpeDesc, rm,
    null);
      CollectionReader colRdr = (CollectionReader) cpe.getCollectionReader();
      assertNotNull(colRdr.getUimaContext().getResourceObject("TestFileResource"));
      CasInitializer casIni = colRdr.getCasInitializer();
      assertNotNull(casIni.getUimaContext().getResourceObject("TestFileLanguageResource",
    new String[] { "en" }));
      AnalysisEngine ae = (AnalysisEngine) cpe.getCasProcessors()[0];
      assertNotNull(ae.getUimaContext().getResourceObject("TestResourceObject"));
      assertNotNull(ae.getUimaContext().getResourceObject("TestLanguageResourceObject",
    new String[] { "en" }));
    } catch (Exception e) {
      JUnitExtension.handleException(e);
View Full Code Here

 
  public void testCasMultiplierTypeSystem() throws Throwable {
    CpeDescription cpeDesc = UIMAFramework.getXMLParser()
            .parseCpeDescription(new XMLInputSource(
                    JUnitExtension.getFile("CollectionProcessingEngineImplTest/cpeWithWrappedCasMultiplier.xml")));
    CollectionProcessingEngine cpe = UIMAFramework.produceCollectionProcessingEngine(cpeDesc);
    // create and register a status callback listener
    TestStatusCallbackListener listener = new TestStatusCallbackListener();
    cpe.addStatusCallbackListener(listener);

    // run CPM
    cpe.process();

    // wait until CPM has finished
    while (!listener.isFinished()) {
      Thread.sleep(5);
    }
View Full Code Here

  public void testCpmStopSingleThread() throws Exception {
    int documentCount = 100000; // hopefully enough that we won't finish before we abort
    int threadCount = 1;

    // setup CPM to process 100 documents
    CollectionProcessingEngine cpe = setupCpm(documentCount, threadCount, false);

    // create and register a status callback listener
    TestStatusCallbackListener listener = new TestStatusCallbackListener();
    cpe.addStatusCallbackListener(listener);

    // run CPM
    cpe.process();

    // sleep a bit
    Thread.sleep(1000);

    // stop CPM
    cpe.stop();

    // wait until CPM has aborted
    while (!listener.isAborted()) {
      Thread.sleep(5);
    }
View Full Code Here

  public void testCpmStopMultipleThreads() throws Exception {
    int documentCount = 100000; // hopefully enough that we won't finish before we abort
    int threadCount = 5;

    // setup CPM to process 100 documents
    CollectionProcessingEngine cpe = setupCpm(documentCount, threadCount, false);

    // create and register a status callback listener
    TestStatusCallbackListener listener = new TestStatusCallbackListener();
    cpe.addStatusCallbackListener(listener);

    // run CPM
    cpe.process();

    // sleep a bit
    Thread.sleep(1000);

    // stop CPM
    cpe.stop();

    // wait until CPM has aborted
    while (!listener.isAborted()) {
      Thread.sleep(5);
    }
View Full Code Here

  public void testCpmStopSlowAnnotator() throws Exception {
    int documentCount = 1000; // hopefully enough that we won't finish before we abort
    int threadCount = 1;

    // setup CPM to process 100 documents
    final CollectionProcessingEngine cpe = setupCpm(documentCount, threadCount, true);

    // register status callback listener
    final TestStatusCallbackListener listener = new TestStatusCallbackListener();
    cpe.addStatusCallbackListener(listener);

    // run CPM
    cpe.process();

    // sleep a bit
    Thread.sleep(1000);

    // stop CPM
    cpe.stop();

    // wait until CPM has aborted
    while (!listener.isAborted()) {
      Thread.sleep(5);
    }
View Full Code Here

  public void testCpmStopImmediate() throws Exception {
    int documentCount = 100000; // hopefully enough that we won't finish before we abort
    int threadCount = 1;

    // setup CPM to process 100 documents
    CollectionProcessingEngine cpe = setupCpm(documentCount, threadCount, false);

    // create and register a status callback listener
    TestStatusCallbackListener listener = new TestStatusCallbackListener();
    cpe.addStatusCallbackListener(listener);

    // run CPM
    cpe.process();

    // stop CPM immediately
    cpe.stop();

    // wait until CPM has aborted
    while (!listener.isAborted()) {
      Thread.sleep(5);
    }
View Full Code Here

   * @return CollectionProcessingEngine - initialized cpe
   */
  private CollectionProcessingEngine setupCpm(int documentCount, int threadCount,
          boolean useSlowAnnotator) throws Exception {
    CpeDescription cpeDesc = null;
    CollectionProcessingEngine cpe = null;

    String colReaderBase = JUnitExtension.getFile("CpmTests" + separator
            + "ErrorTestCollectionReader.xml").getAbsolutePath();
    String taeBase = JUnitExtension.getFile("CpmTests" + separator + "ErrorTestAnnotator.xml").getAbsolutePath();
    String casConsumerBase = JUnitExtension.getFile("CpmTests" + separator
View Full Code Here

    // process 100 documents and multiple threads
    int documentCount = 100;
    int threadCount = 5;

    // setup CPM to process 100 documents
    CollectionProcessingEngine cpe = setupCpm(documentCount, threadCount);

    // create and register a status callback listener
    TestStatusCallbackListener listener = new TestStatusCallbackListener() {
      TypeSystem sts = null;
      public void entityProcessComplete(CAS aCas, EntityProcessStatus aStatus) {
        super.entityProcessComplete(aCas, aStatus);
        if (sts == null) {
          sts = aCas.getTypeSystem();
        } else {
          Assert.assertTrue(sts == aCas.getTypeSystem());
        }
      }     
    };
    cpe.addStatusCallbackListener(listener);

    // run CPM
    cpe.process();

    // wait until CPM has finished
    while (!listener.isFinished()) {
      Thread.sleep(5);
    }
View Full Code Here

TOP

Related Classes of org.apache.uima.collection.CollectionProcessingEngine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.