Package org.apache.uima.fit.type

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


    // 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
    Sentence sentence2 = new Sentence(jcas, 3, 4);
    sentence2.addToIndexes();
    sentence2.addToIndexes();

    FSIndex<FeatureStructure> index1 = jcas.getFSIndexRepository().getIndex("index1");
    FSIndex<FeatureStructure> index2 = jcas.getFSIndexRepository().getIndex("index2");

    assertEquals(3, index1.size());
View Full Code Here


  public static class Annotator extends JCasAnnotator_ImplBase {

    @Override
    public void process(JCas jCas) throws AnalysisEngineProcessException {
      String text = jCas.getDocumentText();
      Sentence sentence = new Sentence(jCas, 0, text.length());
      sentence.addToIndexes();
    }
View Full Code Here

                    "A B C D E F G H I J K L M N O P Q R S T U");

    FSIndex<Annotation> sentenceIndex = jCas.getAnnotationIndex(Sentence.type);
    assertEquals(2, sentenceIndex.size());
    FSIterator<Annotation> sentences = sentenceIndex.iterator();
    Sentence sentence = (Sentence) sentences.next();
    assertEquals("What if we built a rocket ship made of cheese?", sentence.getCoveredText());
    sentence = (Sentence) sentences.next();
    assertEquals("We could fly it to the moon for repairs.", sentence.getCoveredText());

    FSIndex<Annotation> tokenIndex = jCas.getAnnotationIndex(Token.type);
    assertEquals(21, tokenIndex.size());
    Token token = JCasUtil.selectByIndex(jCas, Token.class, 0);
    testToken(token, "What", 0, 4, "A", null);
View Full Code Here

    testToken(token, "If", 0, 2, null, null);
    token = JCasUtil.selectByIndex(jCas, Token.class, 12);
    testToken(token, "rider.", 63, 69, null, null);
    FSIndex<Annotation> sentenceIndex = jCas.getAnnotationIndex(Sentence.type);
    assertEquals(1, sentenceIndex.size());
    Sentence sentence = JCasUtil.selectByIndex(jCas, Sentence.class, 0);
    assertEquals(text, sentence.getCoveredText());
  }
View Full Code Here

    // 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
    Sentence sentence2 = new Sentence(jcas, 3, 4);
    sentence2.addToIndexes();
    sentence2.addToIndexes();

    FSIndex<FeatureStructure> index1 = jcas.getFSIndexRepository().getIndex("index1");
    FSIndex<FeatureStructure> index2 = jcas.getFSIndexRepository().getIndex("index2");

    assertEquals(3, index1.size());
View Full Code Here

  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());

    UIMAException ue = null;
    try {
      AnnotationFactory.createAnnotation(null, 0, 10, Sentence.class);
    } catch (UIMAException e) {
View Full Code Here

  /**
   * Test what happens if there is actually nothing overlapping with the Token.
   */
  @Test
  public void testSelectCoveredNoOverlap() {
    new Sentence(jCas, 3, 31).addToIndexes();
    new Sentence(jCas, 21, 21).addToIndexes();
    new Sentence(jCas, 24, 44).addToIndexes();
    new Sentence(jCas, 30, 45).addToIndexes();
    new Sentence(jCas, 32, 43).addToIndexes();
    new Sentence(jCas, 47, 61).addToIndexes();
    new Sentence(jCas, 48, 77).addToIndexes();
    new Sentence(jCas, 65, 82).addToIndexes();
    new Sentence(jCas, 68, 80).addToIndexes();
    new Sentence(jCas, 72, 65).addToIndexes();

    new Token(jCas, 73, 96).addToIndexes();

    for (Token t : select(jCas, Token.class)) {
      // The naive approach is assumed to be correct
View Full Code Here

    Token t1 = new Token(jCas, 45, 57);
    t1.addToIndexes();
    Token t2 = new Token(jCas, 52, 52);
    t2.addToIndexes();

    new Sentence(jCas, 52, 52).addToIndexes();

    List<Sentence> stem1 = selectBetween(jCas, Sentence.class, t1, t2);
    assertTrue(stem1.isEmpty());
  }
View Full Code Here

  }

  private Token add(JCas jcas, int begin, int end) {
    Token t = new Token(jcas, begin, end);
    t.addToIndexes();
    new Sentence(jcas, begin, end).addToIndexes();
    return t;
  }
View Full Code Here

    Token d = new Token(this.jCas, 6, 7);
    Token e = new Token(this.jCas, 8, 9);
    for (Token token : Arrays.asList(a, b, c, d, e)) {
      token.addToIndexes();
    }
    Sentence sentence = new Sentence(this.jCas, 2, 5);
    sentence.addToIndexes();

    List<Token> preceding = selectPreceding(this.jCas, Token.class, sentence, 1);
    assertEquals(Arrays.asList("A"), JCasUtil.toText(preceding));
    assertEquals(Arrays.asList(a), preceding);
    preceding = selectPreceding(this.jCas, Token.class, sentence, 2);
View Full Code Here

TOP

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

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.