Package org.apache.uima.jcas

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


    AnalysisEngine a1 = AnalysisEngineFactory.createEngine(Annotator1.class);
    AnalysisEngine a2 = AnalysisEngineFactory.createEngine(Annotator2.class);
    AnalysisEngine xWriter = AnalysisEngineFactory.createEngine(XmiWriter.class,
            XmiWriter.PARAM_OUTPUT_DIRECTORY,
            "src/test/resources/org/apache/uima/fit/examples/xmi");
    JCas jCas = JCasFactory.createJCas();
    jCas.setDocumentText("betgetjetletmetnetpetsetvetwetyet");
    a1.process(jCas);
    a2.process(jCas);
    xWriter.process(jCas);
    xWriter.collectionProcessComplete();
  }
View Full Code Here

            UimaAcronymAnnotator.RES_ACRONYM_TABLE, resource));
    builder.add(createEngineDescription(UimaMeetingAnnotator.class,
            UimaMeetingAnnotator.RES_UIMA_TERM_TABLE, resource));
    AnalysisEngine engine = createEngine(builder.createAggregateDescription());

    JCas jCas = engine.newJCas();
    jCas.setDocumentText("Let's meet to talk about the CPE. The meeting is over at Yorktown 01-144");
    new Meeting(jCas, 0, 33).addToIndexes();

    engine.process(jCas);

    UimaAcronym uimaAcronym = JCasUtil.selectByIndex(jCas, UimaAcronym.class, 0);
View Full Code Here

   */
  @Test
  public void testRNA1() throws Exception {
    AnalysisEngine roomNumberAnnotatorAE = AnalysisEngineFactory
            .createEngine("org.apache.uima.fit.examples.tutorial.ex1.RoomNumberAnnotator");
    JCas jCas = roomNumberAnnotatorAE.newJCas();
    jCas.setDocumentText("The meeting is over at Yorktown 01-144");
    roomNumberAnnotatorAE.process(jCas);

    RoomNumber roomNumber = JCasUtil.selectByIndex(jCas, RoomNumber.class, 0);
    assertNotNull(roomNumber);
    assertEquals("01-144", roomNumber.getCoveredText());
View Full Code Here

  public void testRNA2() throws Exception {
    TypeSystemDescription typeSystemDescription = TypeSystemDescriptionFactory
            .createTypeSystemDescription("org.apache.uima.fit.examples.TypeSystem");
    AnalysisEngine roomNumberAnnotatorAE = AnalysisEngineFactory.createEngine(
            RoomNumberAnnotator.class, typeSystemDescription);
    JCas jCas = roomNumberAnnotatorAE.newJCas();
    jCas.setDocumentText("The meeting is over at Yorktown 01-144");
    roomNumberAnnotatorAE.process(jCas);

    RoomNumber roomNumber = JCasUtil.selectByIndex(jCas, RoomNumber.class, 0);
    assertNotNull(roomNumber);
    assertEquals("01-144", roomNumber.getCoveredText());
View Full Code Here

   */
  @Test
  public void testRNA3() throws Exception {
    AnalysisEngine roomNumberAnnotatorAE = AnalysisEngineFactory
            .createEngine(RoomNumberAnnotator.class);
    JCas jCas = roomNumberAnnotatorAE.newJCas();
    jCas.setDocumentText("The meeting is over at Yorktown 01-144");
    roomNumberAnnotatorAE.process(jCas);

    RoomNumber roomNumber = JCasUtil.selectByIndex(jCas, RoomNumber.class, 0);
    assertNotNull(roomNumber);
    assertEquals("01-144", roomNumber.getCoveredText());
View Full Code Here

  private String destinationViewName;

  @Override
  public void process(final JCas jCas) throws AnalysisEngineProcessException {
    try {
      final JCas sourceView = jCas.getView(sourceViewName);
      JCas destinationView;
      try {
        destinationView = jCas.getView(destinationViewName);
      } catch (CASRuntimeException ce) {
        destinationView = jCas.createView(destinationViewName);
      }
      destinationView.setDocumentText(sourceView.getDocumentText());
    } catch (CASException e) {
      throw new AnalysisEngineProcessException(e);
    }
  }
View Full Code Here

   * @param fileName
   *          a file name for the serialized CAS data
   */
  public static JCas createJCas(String fileName, TypeSystemDescription typeSystemDescription)
          throws UIMAException, IOException {
    JCas jCas = createJCas(typeSystemDescription);
    CasIOUtil.readJCas(jCas, new File(fileName));
    return jCas;
  }
View Full Code Here

  public void testViewAE() throws Exception {
    AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(
            Annotator4.class, typeSystemDescription);
    AnalysisEngine ae = AnalysisEngineFactory.createEngine(aed, "A");

    JCas aView = jCas.createView("A");
    tokenBuilder.buildTokens(aView, "'Verb' is a noun!?");
    ae.process(jCas);
    assertEquals("'Verb' is a noun!?", jCas.getView("A").getDocumentText());
    assertEquals("NN", JCasUtil.selectByIndex(aView, Token.class, 0).getPos());
  }
View Full Code Here

  @Test
  public void testIndexesWork() throws Exception {
    // 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
    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());
    assertEquals(2, index2.size());

    // AnalysisEngine dumpWriter = createPrimitive(CASDumpWriter.class);
View Full Code Here

TOP

Related Classes of org.apache.uima.jcas.JCas

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.