Package org.apache.uima.fit.pipeline

Examples of org.apache.uima.fit.pipeline.JCasIterator


    CollectionReader reader = CollectionReaderFactory.createReader(
            SingleFileXReader.class, typeSystemDescription, SingleFileXReader.PARAM_FILE_NAME,
            "src/test/resources/data/docs/test.xmi", SingleFileXReader.PARAM_XML_SCHEME,
            SingleFileXReader.XMI);

    JCasIterator jCasIterator = new JCasIterator(reader);
    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());
View Full Code Here


    CollectionReader reader = CollectionReaderFactory.createReader(
            SingleFileXReader.class, typeSystemDescription, SingleFileXReader.PARAM_FILE_NAME,
            "src/test/resources/data/docs/test.xmi", SingleFileXReader.PARAM_XML_SCHEME,
            SingleFileXReader.XMI);

    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());
View Full Code Here

    Progress[] progress = cr.getProgress();
    assertEquals(1, progress.length);
    assertEquals(0, progress[0].getCompleted());
    assertTrue(cr.hasNext());

    new JCasIterator(cr).next();
    progress = cr.getProgress();
    assertEquals(1, progress.length);
    assertEquals(1, progress[0].getCompleted());

    cr.close();

    cr = CollectionReaderFactory.createReader(SingleFileXReader.class,
            typeSystemDescription, SingleFileXReader.PARAM_XML_SCHEME, "XCAS",
            SingleFileXReader.PARAM_FILE_NAME, "test/data/docs/test.xcas");
    UnsupportedOperationException uoe = null;
    try {
      new JCasIterator(cr).remove();
    } catch (UnsupportedOperationException e) {
      uoe = e;
    }
    assertNotNull(uoe);
    cr.close();

    HideOutput hideOutput = new HideOutput();
    cr = CollectionReaderFactory.createReader(SingleFileXReader.class,
            typeSystemDescription, SingleFileXReader.PARAM_XML_SCHEME, "XCAS",
            SingleFileXReader.PARAM_FILE_NAME, "test/data/docs/bad.xcas");
    RuntimeException re = null;
    try {
      new JCasIterator(cr).next();
    } catch (RuntimeException e) {
      re = e;
    }
    assertNotNull(re);
    hideOutput.restoreOutput();

    cr = CollectionReaderFactory.createReader(SingleFileXReader.class,
            typeSystemDescription, SingleFileXReader.PARAM_XML_SCHEME, "XMI",
            SingleFileXReader.PARAM_FILE_NAME, "test/data/docs/dne.xmi");
    re = null;
    try {
      JCasIterator jCases = new JCasIterator(cr);
      assertTrue(jCases.hasNext());
      jCases.next();
    } catch (RuntimeException e) {
      re = e;
    }
    assertNotNull(re);
View Full Code Here

TOP

Related Classes of org.apache.uima.fit.pipeline.JCasIterator

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.