Package org.apache.uima.collection

Examples of org.apache.uima.collection.CollectionReader


  public static void main(String[] args) throws Exception {
   
    Options options = CliFactory.parseArguments(Options.class, args);

    List<File> trainFiles = Arrays.asList(options.getInputDirectory().listFiles());
    CollectionReader collectionReader = getCollectionReader(trainFiles);
   
    AnalysisEngine annotationConsumer = AnalysisEngineFactory.createPrimitive(
        EventWriter.class,
        "UmlsSemanticType",
        options.getUmlsSemanticType(),
View Full Code Here


        fail("Unable to find file:"+"descriptors/collection_reader/FileSystemCollectionReader.xml"+ "in classloader");
      }
      File collectionReaderDescriptor = new File(filename);
      CollectionReaderDescription collectionReaderDescription = UIMAFramework.getXMLParser()
        .parseCollectionReaderDescription(new XMLInputSource(collectionReaderDescriptor));
      CollectionReader collectionReader = UIMAFramework
        .produceCollectionReader(collectionReaderDescription);
      eeUimaEngine.setCollectionReader(collectionReader);
      initialize(eeUimaEngine, appCtx);
      waitUntilInitialized();
      runCrTest(eeUimaEngine, 7);
View Full Code Here

      } else {
        testFiles = Arrays.asList(options.testDirectory.listFiles());
      }
     
      if (!options.testOnly && !options.evalOnly) {
        CollectionReader trainCollectionReader = evaluation.getCollectionReader(trainFiles);
        evaluation.train(trainCollectionReader, modelsDir);
      }
     
      if (!options.trainOnly) {
        if (testFiles==null || testFiles.size()==0) {
          throw new RuntimeException("testFiles = " + testFiles + " testFiles.size() = " + (testFiles==null ? "null": testFiles.size())) ;
        }
        logger.debug("testFiles.size() = " + testFiles.size());
        CollectionReader testCollectionReader = evaluation.getCollectionReader(testFiles);
        Map<String, AnnotationStatisticsCompact> stats = evaluation.test(testCollectionReader, modelsDir);

        AssertionEvaluation.printScore(stats,  modelsDir!=null? modelsDir.getAbsolutePath() : "no_model");
      }
    }
View Full Code Here

    // Collection Reader
    System.out.println("Initializing Collection Reader");
    ResourceSpecifier colReaderSpecifier = UIMAFramework.getXMLParser()
            .parseCollectionReaderDescription(new XMLInputSource(args[0]));
    CollectionReader collectionReader = UIMAFramework.produceCollectionReader(colReaderSpecifier);

    // AnalysisEngine
    System.out.println("Initializing AnalysisEngine");
    ResourceSpecifier aeSpecifier = UIMAFramework.getXMLParser().parseResourceSpecifier(
            new XMLInputSource(args[1]));
View Full Code Here

  }

  private static JCas getJcas(File f) {
    List<File> list = new ArrayList<File>();
    list.add(f);
    CollectionReader cr;
    AggregateBuilder builder;
   
    try {
      cr = getCollectionReader(list);
      builder = new AggregateBuilder();

      // uimafit find available type systems on classpath
      TypeSystemDescription typeSystemDescription = TypeSystemDescriptionFactory.createTypeSystemDescription();

      AnalysisEngineDescription noOp = AnalysisEngineFactory.createPrimitiveDescription(NoOpAnnotator.class, typeSystemDescription);
      builder.add(noOp);
    } catch (ResourceInitializationException e) {
      throw new RuntimeException(e);
    }

    try {
      //SimplePipeline.runPipeline(cr, builder.createAggregate());
      AnalysisEngine engine = builder.createAggregate();

      final List<ResourceMetaData> metaData = new ArrayList<ResourceMetaData>();
      metaData.add(cr.getMetaData());
      metaData.add(engine.getMetaData());
     
      final CAS cas;
      cas = CasCreationUtils.createCas(metaData);
     
      if (cr.hasNext()) { // assumes just one document to process
        cr.getNext(cas);
        engine.process(cas); // SimplePipeline.runPipeline(cas, engine);
      }

      engine.collectionProcessComplete();
View Full Code Here

    //String documentText = "Text of document to test goes here, such as the following. No edema, some soreness, denies pain.";
    //InputStream inStream = InputStreamCollectionReader.convertToByteArrayInputStream(documentText);
    //CollectionReader collectionReader = InputStreamCollectionReader.getCollectionReader(inStream);
   
    CollectionReader collectionReader = FilesCollectionReader.getCollectionReader(AssertionConst.CORPUS_WO_GOLD_STD_TO_RUN_THROUGH_CTAKES);

    System.out.println("Reading from directory: " + AssertionConst.CORPUS_WO_GOLD_STD_TO_RUN_THROUGH_CTAKES);
    System.out.println("Outputting to directory: " + AssertionConst.evalOutputDir);
   
    AnalysisEngineDescription pipelineIncludingUmlsDictionaries = AnalysisEngineFactory.createAnalysisEngineDescription(
View Full Code Here

      String[] paths = new String[trainFiles.size()];
      for (int i = 0; i < paths.length; ++i) {
        paths[i] = trainFiles.get(i).getPath();
      }
      CollectionReader reader = CollectionReaderFactory.createCollectionReader(
              XMIReader.class,
              XMIReader.PARAM_FILES,
              paths);
        
      JCasIterable casIter = new JCasIterable(reader);
View Full Code Here

      } else {
        testFiles = Arrays.asList(options.testDirectory.listFiles());
      }
     
      if (!options.testOnly && !options.evalOnly) {
        CollectionReader trainCollectionReader = evaluation.getCollectionReader(trainFiles);
        evaluation.train(trainCollectionReader, modelsDir);
      }
     
      if (!options.trainOnly) {
        if (testFiles==null || testFiles.size()==0) {
          throw new RuntimeException("testFiles = " + testFiles + " testFiles.size() = " + (testFiles==null ? "null": testFiles.size())) ;
        }
        logger.debug("testFiles.size() = " + testFiles.size());
        CollectionReader testCollectionReader = evaluation.getCollectionReader(testFiles);
        Map<String, AnnotationStatisticsCompact> stats = evaluation.test(testCollectionReader, modelsDir);

        AssertionEvaluation.printScore(stats,  modelsDir.getAbsolutePath());
      }
    }
View Full Code Here

  @Test
  public void TestClearNLPPipeLine() throws Exception {
   
    TypeSystemDescription typeSystem = TypeSystemDescriptionFactory.createTypeSystemDescription();
   
    CollectionReader reader1 = CollectionReaderFactory.createCollectionReader(
        FilesCollectionReader.class,
        typeSystem,
        FilesCollectionReader.PARAM_ROOT_FILE,
        INPUT_FILE
        );
View Full Code Here

    if(args.length < 2){
      System.err.println("Requires 2 arguments: <input file> <output file>");
      System.exit(-1);
    }
   
    CollectionReader reader = CollectionReaderFactory.createCollectionReader(LinesFromFileCollectionReader.class,
        LinesFromFileCollectionReader.PARAM_INPUT_FILE_NAME,
        args[0]);
    PrintWriter out = new PrintWriter(args[1]);
    AnalysisEngine ae = AnalysisEngineFactory.createPrimitive(ParserEvaluationAnnotator.class, new Object[]{});
   
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.