Package org.apache.uima.analysis_engine

Examples of org.apache.uima.analysis_engine.AnalysisEngine.process()


  public void testImportAllPackagesWithAliasFromTypeSystem() throws Exception {
    AnalysisEngine ae = createAE(NAMESPACE + "/" + NAME + "ImportAllPackagesWithAliasFromTypeSystem", true);
    try {
      CAS cas = ae.newCAS();
      cas.setDocumentText("First Second");
      ae.process(cas);

      assertEquals(Arrays.asList("First"), selectText(cas, "org.apache.uima.ruta.other3.Type1"));
      assertEquals(Arrays.asList("Second"), selectText(cas, "org.apache.uima.ruta.other4.Type2"));
    } finally {
      ae.destroy();
View Full Code Here


  public void testImportAllPackagesFromTypeSystemWithAmbiguousShortNames() throws Exception {
    AnalysisEngine ae = createAE(NAMESPACE + "/" + NAME + "ImportAllPackagesFromTypeSystemWithAmbiguousShortNames", true);
    try {
      CAS cas = ae.newCAS();
      cas.setDocumentText("First Second");
      ae.process(cas);

      fail("Engine should fail because Type1 and Type2 are ambiguous");
    } catch (AnalysisEngineProcessException e) {
      if (e.getCause() instanceof IllegalArgumentException) {
        // success, Type1 and Type2 are ambiguous and this exception should be raised.
View Full Code Here

    ae.setConfigParameterValue("onlyContent", false);
    ae.reconfigure();
    cas.reset();
    cas.setDocumentText(html);
    ae.process(cas);
    ai = cas.getAnnotationIndex(tagType);
    iterator = ai.iterator();
    assertEquals(7, ai.size());
    AnnotationFS a = iterator.next();
    assertEquals("HTML", a.getType().getShortName());
View Full Code Here

   
    ae.setConfigParameterValue("onlyContent", true);
    ae.reconfigure();
    cas.reset();
    cas.setDocumentText(html);
    ae.process(cas);
    ai = cas.getAnnotationIndex(tagType);
    iterator = ai.iterator();
    assertEquals(4, ai.size());
    a = iterator.next();
    assertEquals("HTML", a.getType().getShortName());
View Full Code Here

      cas = RutaTestUtils.process(namespace + "/" + scriptName + RutaEngine.SCRIPT_FILE_EXTENSION, namespace + "/test.html", 50);
    } catch (Exception e) {
      e.printStackTrace();
      assert (false);
    }
    ae.process(cas);
   
    CAS modifiedView = cas.getView(viewName);
    String text = modifiedView.getDocumentText();
   
    assertEquals("start of bodynormal BOLDend of body" , text);
View Full Code Here

    ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);
    AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);
    CAS cas = ae.newCAS();
    CAS mCas = cas.createView("global1");
    mCas.setDocumentText("Peter is tired.");
    ae.process(mCas);

    Type cwswType = cas.getTypeSystem().getType("Simple.CwSw");
    CAS lastCas = cas.getView("global3");
    AnnotationIndex<AnnotationFS> ai = lastCas.getAnnotationIndex(cwswType);
    assertEquals(1, ai.size());
View Full Code Here

    CAS cas;
    AnalysisEngine ae = createAE(NAMESPACE + "/" + NAME + "UndeclaredTypeSystem", true);
    try {
      cas = ae.newCAS();
      cas.setDocumentText("Word");
      ae.process(cas);
      fail("MyType should not be resolved in the ruta script because it is not imported.");
    } catch (AnalysisEngineProcessException e) {
      // success, the usage of MyType raised an exception because its type system is not imported.
    } finally {
      if (ae != null) {
View Full Code Here

    String script = NAMESPACE + "/" + NAME + "UndeclaredTypeSystem";
    AnalysisEngine ae = createAE(script, false);
    try {
      cas = ae.newCAS();
      cas.setDocumentText("Word");
      ae.process(cas);
    } finally {
      if (ae != null) {
        ae.destroy();
      }
    }
View Full Code Here

    String script = NAMESPACE + "/" + NAME + "DeclaredTypeSystem";
    AnalysisEngine ae = createAE(script, true);
    try {
      cas = ae.newCAS();
      cas.setDocumentText("Word");
      ae.process(cas);
    } finally {
      if (ae != null) {
        ae.destroy();
      }
    }
View Full Code Here

    ae.reconfigure();
    if (cas == null) {
      cas = ae.newCAS();
      cas.setDocumentText(FileUtils.file2String(textFile, "UTF-8"));
    }
    ae.process(cas);

    ae.destroy();
    return cas;
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.