Package org.apache.uima.analysis_engine

Examples of org.apache.uima.analysis_engine.TextAnalysisEngine


      TaeDescription testDescriptor = UIMAFramework.getXMLParser().parseTaeDescription(
              new XMLInputSource(JUnitExtension
                      .getFile("TextAnalysisEngineImplTest/TestPrimitiveTae1.xml")));

      // check default setting
      TextAnalysisEngine taeDefault = UIMAFramework.produceTAE(testDescriptor);
      CAS cas = taeDefault.newCAS();
      int heapSize = ((CASImpl) cas).getHeap().getCurrentTempSize();
      int bufSize = ((CASImpl)cas).getHeap().heap.length;
      //System.out.println("Heap size: " + heapSize + ", buffer size: " + bufSize);      
      Assert.assertTrue(bufSize < CASImpl.DEFAULT_RESET_HEAP_SIZE);
      assertTrue(heapSize <= bufSize);
View Full Code Here


      TaeDescription testDescriptor = UIMAFramework.getXMLParser().parseTaeDescription(
              new XMLInputSource(JUnitExtension
                      .getFile("TextAnalysisEngineImplTest/TestPrimitiveTae1.xml")));

      // check default setting
      TextAnalysisEngine taeDefault = UIMAFramework.produceTAE(testDescriptor);
      CAS tcasDefault = taeDefault.newCAS();
      int heapSize = ((CASImpl) tcasDefault).getHeap().heap.length;
      Assert.assertEquals(expectedHeapSizeDefault, heapSize);

      // check override
      Map<String, Object> params = new HashMap<String, Object>();
      params.put(Resource.PARAM_PERFORMANCE_TUNING_SETTINGS, newProps);
      TextAnalysisEngine taeOverride = UIMAFramework.produceTAE(testDescriptor, params);
      CAS tcasOverride = taeOverride.newCAS();
      heapSize = ((CASImpl) tcasOverride).getHeap().heap.length;
      Assert.assertEquals(100000, heapSize);
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
View Full Code Here

      TaeDescription testDescriptor = UIMAFramework.getXMLParser().parseTaeDescription(
              new XMLInputSource(JUnitExtension
                      .getFile("TextAnalysisEngineImplTest/TestPrimitiveTae1.xml")));

      // check default setting
      TextAnalysisEngine taeDefault = UIMAFramework.produceTAE(testDescriptor);
      CAS cas = taeDefault.newCAS();
      int heapSize = ((CASImpl) cas).getHeap().getHeapSize();
      int bufSize = ((CASImpl)cas).getHeap().heap.length;
      //System.out.println("Heap size: " + heapSize + ", buffer size: " + bufSize);      
      Assert.assertTrue(bufSize < CASImpl.DEFAULT_RESET_HEAP_SIZE);
      assertTrue(heapSize <= bufSize);
View Full Code Here

    TextAnalysisEnginePool pool = null;
    try {
      // create pool
      pool = new TextAnalysisEnginePool("taePool", 3, mSimpleDesc);

      TextAnalysisEngine tae = pool.getTAE();
      AnalysisEngineMetaData md = tae.getAnalysisEngineMetaData();
      Assert.assertNotNull(md);
      Assert.assertEquals("Simple Test", md.getName());
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    } finally {
View Full Code Here

              new NameValuePair[] { new NameValuePair_impl("StringParam", "Test1") });

      // create pool
      TextAnalysisEnginePool pool = new TextAnalysisEnginePool("taePool", 3, primitiveDesc);

      TextAnalysisEngine tae = pool.getTAE();
      try {
        // check value of string param (TestAnnotator saves it in a static field)
        assertEquals("Test1", TestAnnotator.stringParamValue);

        // reconfigure
        tae.setConfigParameterValue("StringParam", "Test2");
        tae.reconfigure();

        //test again
        assertEquals("Test2", TestAnnotator.stringParamValue);

        // check pool metadata
        pool.getMetaData().setUUID(tae.getMetaData().getUUID());
        Assert.assertEquals(tae.getMetaData(), pool.getMetaData());
      } finally {
        pool.releaseTAE(tae);
      }
    } catch (Exception e) {
      JUnitExtension.handleException(e);
View Full Code Here

   * @param aTaeDesc
   *          description of TextAnalysisEngine to test
   */
  protected void _testProcess(TextAnalysisEnginePool aPool, int i)
          throws UIMAException {
    TextAnalysisEngine tae = aPool.getTAE(0);
    try {
      // Test each form of the process method. When TestAnnotator executes, it
      // stores in static fields the document text and the ResultSpecification.
      // We use thse to make sure the information propogates correctly to the annotator.

      // process(CAS)
      CAS tcas = tae.newCAS();
      tcas.setDocumentText("new test");
      tae.process(tcas);
      tcas.reset();

      // process(CAS,ResultSpecification)
      ResultSpecification resultSpec = new ResultSpecification_impl();
      resultSpec.addResultType("NamedEntity", true);

      tcas.setDocumentText("testing...");
      tae.process(tcas, resultSpec);
      tcas.reset();
    } finally {
      aPool.releaseTAE(tae);
    }
  }
View Full Code Here

   * @param aTaeDesc
   *          description of TextAnalysisEngine to test
   */
  protected void _testProcess(TaeDescription aTaeDesc) throws UIMAException {
    // create and initialize TextAnalysisEngine
    TextAnalysisEngine tae = UIMAFramework.produceTAE(aTaeDesc);

    // Test each form of the process method. When TestAnnotator executes, it
    // stores in static fields the document text and the ResultSpecification.
    // We use thse to make sure the information propogates correctly to the annotator.

    // process(CAS)
    CAS tcas = tae.newCAS();
    tcas.setDocumentText("new test");
    tae.process(tcas);
    assertEquals("new test", TestAnnotator.lastDocument);
    tcas.reset();

    // process(CAS,ResultSpecification)
    ResultSpecification resultSpec = new ResultSpecification_impl();
    resultSpec.addResultType("NamedEntity", true);

    tcas.setDocumentText("testing...");
    tae.process(tcas, resultSpec);
    assertEquals("testing...", TestAnnotator.lastDocument);
    assertEquals(resultSpec, TestAnnotator.lastResultSpec);
    tcas.reset();
    tae.destroy();
  }
View Full Code Here

    try {
      XMLInputSource in = new XMLInputSource(JUnitExtension
              .getFile("ConfigurableResourceImplTest/AnnotatorWithConfigurationGroups.xml"));
      AnalysisEngineDescription desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(
              in);
      TextAnalysisEngine test = UIMAFramework.produceTAE(desc);

      // test default fallback
      String str3 = (String) test.getConfigParameterValue("StringParam");
      Assert.assertEquals("en", str3);

      // The below was commented out because it has a dependency on the jedii_cpe_impl module
      // //XMLInputSource in = new
      // XMLInputSource("CasConsumerWithDefaultFallbackConfiguration.xml");
View Full Code Here

      TaeDescription testDescriptor = UIMAFramework.getXMLParser().parseTaeDescription(
              new XMLInputSource(JUnitExtension
                      .getFile("TextAnalysisEngineImplTest/TestPrimitiveTae1.xml")));

      // check default setting
      TextAnalysisEngine taeDefault = UIMAFramework.produceTAE(testDescriptor);
      CAS cas = taeDefault.newCAS();
      int heapSize = ((CASImpl) cas).heap.getCurrentTempSize();
      // System.out.println("Heap size: " + heapSize + ", buffer size: " + ((CASImpl)
      // cas).heap.heap.length);
      Assert.assertTrue(heapSize < CASImpl.DEFAULT_RESET_HEAP_SIZE);
      assertTrue(heapSize <= ((CASImpl) cas).heap.heap.length);
View Full Code Here

      TaeDescription testDescriptor = UIMAFramework.getXMLParser().parseTaeDescription(
              new XMLInputSource(JUnitExtension
                      .getFile("TextAnalysisEngineImplTest/TestPrimitiveTae1.xml")));

      // check default setting
      TextAnalysisEngine taeDefault = UIMAFramework.produceTAE(testDescriptor);
      CAS tcasDefault = taeDefault.newCAS();
      int heapSize = ((CASImpl) tcasDefault).getHeap().heap.length;
      Assert.assertEquals(expectedHeapSizeDefault, heapSize);

      // check override
      HashMap params = new HashMap();
      params.put(Resource.PARAM_PERFORMANCE_TUNING_SETTINGS, newProps);
      TextAnalysisEngine taeOverride = UIMAFramework.produceTAE(testDescriptor, params);
      CAS tcasOverride = taeOverride.newCAS();
      heapSize = ((CASImpl) tcasOverride).getHeap().heap.length;
      Assert.assertEquals(100000, heapSize);
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
View Full Code Here

TOP

Related Classes of org.apache.uima.analysis_engine.TextAnalysisEngine

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.