Package org.apache.uima.fit.type

Examples of org.apache.uima.fit.type.Token


      fail("Found annotation that has not yet been created");
    } catch (IllegalArgumentException e) {
      // OK
    }

    new Token(jcas, 0, 1).addToIndexes();

    selectSingle(jcas, Token.class);

    new Token(jcas, 1, 2).addToIndexes();

    try {
      selectSingle(jcas, Token.class);
      fail("selectSingle must fail if there is more than one annotation of the type");
    } catch (IllegalArgumentException e) {
View Full Code Here


      } catch (CASException e) {
        throw new AnalysisEngineProcessException(e);
      }

      view.setDocumentText("some text");
      Token token = new Token(view, 0, 4);
      token.addToIndexes();
    }
View Full Code Here

  public static class SofaUnawareAnnotator extends JCasAnnotator_ImplBase {

    @Override
    public void process(JCas jCas) throws AnalysisEngineProcessException {
      jCas.setDocumentText("some text");
      Token token = new Token(jCas, 0, 4);
      token.addToIndexes();
    }
View Full Code Here

    // Index should be added the descriptor and thus end up in the CAS generated from the
    // analysis engine.
    AnalysisEngine desc = createEngine(IndexTestComponent.class);
    JCas jcas = desc.newJCas();

    Token token1 = new Token(jcas, 1, 2);
    token1.addToIndexes();

    // index1 is a sorted index, so when adding a token twice, both remain in the index
    Token token2 = new Token(jcas, 3, 4);
    token2.addToIndexes();
    token2.addToIndexes();

    Sentence sentence1 = new Sentence(jcas, 1, 2);
    sentence1.addToIndexes();

    // index2 is a set index, so even when adding a sentence twice, only one remains in the index
View Full Code Here

    JCasIterator jCasIterator = new JCasIterator(reader, typeSystemDescription);
    jCas = jCasIterator.next();
    assertNotNull(jCas);
    assertEquals("Me and all my friends are non-conformists.", jCas.getDocumentText());
    Token token = JCasUtil.selectByIndex(jCas, Token.class, 2);
    assertEquals("all", token.getCoveredText());
    assertEquals("A", token.getPos());
    assertEquals("all", token.getStem());

    reader = CollectionReaderFactory.createReader(
            "org.apache.uima.fit.factory.testCrs.SingleFileXReader",
            SingleFileXReader.PARAM_FILE_NAME, "src/test/resources/data/docs/test.xmi",
            SingleFileXReader.PARAM_XML_SCHEME, SingleFileXReader.XMI);

    jCasIterator = new JCasIterator(reader, typeSystemDescription);
    jCas = jCasIterator.next();
    assertNotNull(jCas);
    assertEquals("Me and all my friends are non-conformists.", jCas.getDocumentText());
    token = JCasUtil.selectByIndex(jCas, Token.class, 9);
    assertEquals(".", token.getCoveredText());
    assertEquals(".", token.getPos());
    assertEquals(".", token.getStem());

    reader = CollectionReaderFactory.createReaderFromPath(
            "src/test/resources/org/apache/uima/fit/factory/testCrs/SingleFileXReader.xml",
            SingleFileXReader.PARAM_FILE_NAME, "src/test/resources/data/docs/test.xmi",
            SingleFileXReader.PARAM_XML_SCHEME, SingleFileXReader.XMI);

    jCasIterator = new JCasIterator(reader, typeSystemDescription);
    jCas = jCasIterator.next();
    assertNotNull(jCas);
    assertEquals("Me and all my friends are non-conformists.", jCas.getDocumentText());
    token = JCasUtil.selectByIndex(jCas, Token.class, 4);
    assertEquals("friends", token.getCoveredText());
    assertEquals("F", token.getPos());
    assertEquals("friend", token.getStem());

  }
View Full Code Here

  @Override
  public void process(JCas jCas) throws AnalysisEngineProcessException {
    FSIterator<Annotation> tokens = jCas.getAnnotationIndex(Token.type).iterator();
    while (tokens.hasNext()) {
      Token token = (Token) tokens.next();
      token.setPos("NN");
    }
  }
View Full Code Here

public class AnnotationFactoryTest extends ComponentTestBase {

  @Test
  public void testCreateAnnotation() throws UIMAException {
    Token token = AnnotationFactory.createAnnotation(jCas, 0, 10, Token.class);
    assertEquals(0, token.getBegin());
    assertEquals(10, token.getEnd());

    Sentence sentence = AnnotationFactory.createAnnotation(jCas, 0, 10, Sentence.class);
    assertEquals(0, sentence.getBegin());
    assertEquals(10, sentence.getEnd());
View Full Code Here

  @Override
  public void process(JCas jCas) throws AnalysisEngineProcessException {
    FSIterator<Annotation> tokens = jCas.getAnnotationIndex(Token.type).iterator();
    while (tokens.hasNext()) {
      Token token = (Token) tokens.next();
      token.setPos("NN");
    }
  }
View Full Code Here

      } catch (CASException e) {
        throw new AnalysisEngineProcessException(e);
      }

      view.setDocumentText("some text");
      Token token = new Token(view, 0, 4);
      token.addToIndexes();
    }
View Full Code Here

  public static class SofaUnawareAnnotator extends JCasAnnotator_ImplBase {

    @Override
    public void process(JCas jCas) throws AnalysisEngineProcessException {
      jCas.setDocumentText("some text");
      Token token = new Token(jCas, 0, 4);
      token.addToIndexes();
    }
View Full Code Here

TOP

Related Classes of org.apache.uima.fit.type.Token

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.