Examples of JCas


Examples of org.apache.uima.jcas.JCas

   *
   */
  public static JCas executeAE(AnalysisEngine ae, String docText)
          throws AnalysisEngineProcessException, ResourceInitializationException {
    // create a JCas, given an Analysis Engine (ae)
    JCas jcas = ae.newJCas();

    // analyze a document
    jcas.setDocumentText(docText);
    ProcessTrace pt = ae.process(jcas);

    // analyze results
    for (ProcessTraceEvent e : pt.getEvents()) {
      if (e != null && e.getResultMessage() != null && e.getResultMessage().contains("error")) {
View Full Code Here

Examples of org.apache.uima.jcas.JCas

        if (!after) {
          result.moveToPrevious();
        }
      }
    } else {
      JCas jcas = null;
      try {
        jcas = cas.getJCas();
      } catch (CASException e) {
        e.printStackTrace();
      }
View Full Code Here

Examples of org.apache.uima.jcas.JCas

  private AnnotationFS getPrefixAnnotation(RuleMatch ruleMatch, RutaStream stream) {
    AnnotationFS lastMatchedAnnotation = ruleMatch.getLastMatchedAnnotation(this, true, null,
            parent, stream);
    if (lastMatchedAnnotation.getBegin() == 0) {
      JCas jCas = stream.getJCas();
      AnnotationFS dummy = new RutaFrame(jCas, 0, 0);
      return dummy;
    }
    return stream.getEndAnchor(lastMatchedAnnotation.getBegin());
  }
View Full Code Here

Examples of org.apache.uima.jcas.JCas

  public void testMissingFeatureInCas() throws Exception {
    try {
      // jcasCasMisMatch(CASTestSetup.BAD_MISSING_FEATURE_IN_CAS, CASException.JCAS_INIT_ERROR);
      CAS localCas;
      TypeSystem ts;
      JCas localJcas = null;
      boolean errFound = false;
      try {
        localCas = CASInitializer.initCas(new CASTestSetup(CASTestSetup.BAD_MISSING_FEATURE_IN_CAS));
        ts = this.cas.getTypeSystem();
        try {
View Full Code Here

Examples of org.apache.uima.jcas.JCas

  public void jcasCasMisMatch(int testId, String expectedErr) throws Exception {
    try {
      CAS localCas;
      TypeSystem ts;
      JCas localJcas;
      boolean errFound = false;
      try {
        localCas = CASInitializer.initCas(new CASTestSetup(testId));
        ts = this.cas.getTypeSystem();
        try {
View Full Code Here

Examples of org.apache.uima.jcas.JCas

  public void test2CASs() throws Exception {
    try {
      try {
        CAS cas2 = CASInitializer.initCas(new CASTestSetup());
        TypeSystem ts2 = cas2.getTypeSystem();
        JCas jcas2 = cas2.getJCas();
        assertTrue(jcas.getType(Annotation.type) != jcas2.getType(Annotation.type));
      } catch (Exception e) {
        checkOkMissingImport(e);
      }
    } catch (Exception e) {
      JUnitExtension.handleException(e);
View Full Code Here

Examples of org.apache.uima.jcas.JCas

    }
  }
 
  public void testUndefinedType() throws Exception {
    //create jcas with no type system
    JCas jcas = CasCreationUtils.createCas(new TypeSystemDescription_impl(), null, null).getJCas();
    jcas.setDocumentText("This is a test.");
    try {
      //this should throw an exception
      jcas.getType(Sentence.type);
      fail();
    } catch(CASRuntimeException e) {
    }
    //check that this does not leave JCAS in an inconsistent state
    //(a check for bug UIMA-738)
    Iterator<Annotation> iter = jcas.getAnnotationIndex().iterator();
    assertTrue(iter.hasNext());
    Annotation annot = iter.next();
    assertEquals("This is a test.", annot.getCoveredText());
  }
View Full Code Here

Examples of org.apache.uima.jcas.JCas

   * @return a JCas instance. Returns <code>null</code> if none are available within the specified
   *         timeout period.
   */
  public synchronized JCas getJCas(long aTimeout) {
    long startTime = new Date().getTime();
    JCas cas;
    while ((cas = getJCas()) == null) {
      try {
        wait(aTimeout);
      } catch (InterruptedException e) {
      }
View Full Code Here

Examples of org.apache.uima.jcas.JCas

          throws ResourceInitializationException {
    // fill the pool
    ArrayList<ProcessingResourceMetaData> mdList = new ArrayList<ProcessingResourceMetaData>();
    mdList.add(aMetaData);
    for (int i = 0; i < mNumInstances; i++) {
      JCas c;
      try {
        c = CasCreationUtils.createCas(mdList).getJCas();
      } catch (CASException e) {
        throw new ResourceInitializationException(e);
      }
View Full Code Here

Examples of org.apache.uima.jcas.JCas

    assertFalse(iter.hasNext())
    this.cas.setCurrentComponentInfo(null);
   
    //repeat with JCas
    this.cas.reset();
    JCas jcas = this.cas.getJCas();
    JCas jview1 = jcas.createView("View1");
    JCas jview2 = jcas.createView("View2");
    Iterator<JCas> jCasIter = jcas.getViewIterator();
    assertEquals(jcas, jCasIter.next());
    assertEquals(jview1, jCasIter.next());
    assertEquals(jview2, jCasIter.next());
    assertFalse(jCasIter.hasNext());
   
    JCas jviewE1 = jcas.createView("EnglishDocument");
    JCas jviewE2 = jcas.createView("EnglishDocument.2");
    jCasIter = jcas.getViewIterator("EnglishDocument");
    assertEquals(jviewE1, jCasIter.next());
    assertEquals(jviewE2, jCasIter.next());
    assertFalse(jCasIter.hasNext());
   
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.