Package org.apache.uima.collection

Examples of org.apache.uima.collection.CollectionReader


  @Test
  public void test() throws Exception {
    File file = folder.newFile("test.txt");
    FileUtils.write(file, "Aaa Bbbb Cc Dddd eeee ff .", "UTF-8");

    CollectionReader reader = createReader(SingleTextReader.class,
            SingleTextReader.PARAM_FILE, file.getPath());

    CAS cas = CasCreationUtils.createCas(reader.getProcessingResourceMetaData());
    reader.getNext(cas);
    reader.close();

    assertEquals(FileUtils.readFileToString(file, "UTF-8"), cas.getDocumentText());
  }
View Full Code Here


  @Test
  public void test() throws Exception {
    File file = folder.newFile("test.txt");
    FileUtils.write(file, "Aaa Bbbb Cc Dddd eeee ff .", "UTF-8");

    CollectionReader reader = createReader(SingleTextReader.class,
            SingleTextReader.PARAM_FILE, file.getPath());

    CAS cas = CasCreationUtils.createCas(reader.getProcessingResourceMetaData());
    reader.getNext(cas);
    reader.close();

    assertEquals(FileUtils.readFileToString(file, "UTF-8"), cas.getDocumentText());
  }
View Full Code Here

public class CollectionReaderFactoryTest extends ComponentTestBase {

  @Test
  public void testCreateCollectionReader() throws UIMAException, IOException {

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

/**
*/
public class CollectionReaderFactoryExternalResourceTest {
  @Test
  public void testAutoExternalResourceBinding() throws UIMAException, IOException {
    CollectionReader reader = createReader(
            TestReader.class,
            TestReader.PARAM_RESOURCE,
            createExternalResourceDescription(TestExternalResource.class,
                    TestExternalResource.PARAM_VALUE, TestExternalResource.EXPECTED_VALUE));

    reader.hasNext();
  }
View Full Code Here

    } catch (ResourceInitializationException e) {
      rie = e;
    }
    assertNotNull(rie);

    CollectionReader cr = CollectionReaderFactory.createReader(SingleFileXReader.class,
            typeSystemDescription, SingleFileXReader.PARAM_XML_SCHEME, "XCAS",
            SingleFileXReader.PARAM_FILE_NAME, "src/test/resources/data/docs/test.xcas");
    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");
View Full Code Here

    {
        xmlIn = new XMLInputSource(this.pkgBrowser.getInstallationDescriptor()
                .getMainComponentDesc());
        ResourceSpecifier crSpecifier = UIMAFramework.getXMLParser().parseResourceSpecifier(xmlIn);
   
        CollectionReader cr = UIMAFramework.produceCollectionReader(crSpecifier,
                getResourceManager(this.pkgBrowser), null);
   
        // create Test status object
        TestStatus status = new TestStatus();
   
View Full Code Here

public class DBCollectionReaderTest {

  @Test
  public void test() throws IOException,
      SAXException, CpeDescriptorException, UIMAException, CASRuntimeException, CASAdminException {
    CollectionReader colReader = TestUtils.getFractureDemoCollectionReader();
    int count = 0;
    JCas jcas = JCasFactory.createJCasFromPath("src/main/resources/org/apache/ctakes/ytex/types/TypeSystem.xml");
    while(colReader.hasNext()) {
      count++;
      colReader.getNext(jcas.getCas());
      Assert.assertTrue("document should have a dockey", jcas.getAnnotationIndex(DocKey.type).iterator().hasNext());
      jcas.reset();
    }
    Assert.assertTrue("should have read some documents", count > 0);
  }
View Full Code Here

    Options options = CliFactory.parseArguments(Options.class, args);

    List<Integer> patientSets = options.getPatients().getList();
    List<Integer> trainItems = THYMEData.getTrainPatientSets(patientSets);
    List<File> trainFiles = Utils.getFilesFor(trainItems, options.getInputDirectory());
    CollectionReader collectionReader = Utils.getCollectionReader(trainFiles);

    AnalysisEngine annotationConsumer = AnalysisEngineFactory.createPrimitive(
        AnalyseRelationArgumentDuration.class,
        "OutputFile",
        options.getOutputFile());
View Full Code Here

        needsXMIs = true;
        break;
      }
    }
    if (needsXMIs) {
      CollectionReader reader = this.getCollectionReader(patientSets);
      AnalysisEngine engine = this.getXMIWritingPreprocessorAggregateBuilder().createAggregate();
      SimplePipeline.runPipeline(reader, engine);
    }
    this.xmiExists = true;
  }
View Full Code Here

    CmdLineParser parser = new CmdLineParser(options);
    parser.parseArgument(args);
   
   
    List<File> trainFiles = Arrays.asList(options.inputDirectory.listFiles());
    CollectionReader collectionReader = getCollectionReader(trainFiles);
   
    AnalysisEngine temporalDurationExtractor = AnalysisEngineFactory.createPrimitive(
        TemporalDurationExtractor.class,
        "OutputFile",
        options.outputFile);
View Full Code Here

TOP

Related Classes of org.apache.uima.collection.CollectionReader

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.