当前位置: 首页>>代码示例>>Java>>正文


Java SimplePipeline类代码示例

本文整理汇总了Java中org.apache.uima.fit.pipeline.SimplePipeline的典型用法代码示例。如果您正苦于以下问题:Java SimplePipeline类的具体用法?Java SimplePipeline怎么用?Java SimplePipeline使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SimplePipeline类属于org.apache.uima.fit.pipeline包,在下文中一共展示了SimplePipeline类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.uima.fit.pipeline.SimplePipeline; //导入依赖的package包/类
public static void main(String[] args) throws ResourceInitializationException, UIMAException, IOException {
	SimplePipeline.runPipeline(
			CollectionReaderFactory.createReaderDescription(TextgridTEIUrlReader.class,
					TextgridTEIUrlReader.PARAM_INPUT, "http://www.textgridrep.org/textgrid:tx4z.0",
					TextgridTEIUrlReader.PARAM_CLEANUP, true),
			AnalysisEngineFactory.createEngineDescription(XmiWriter.class, XmiWriter.PARAM_USE_DOCUMENT_ID, true,
					XmiWriter.PARAM_TARGET_LOCATION, "src/test/resources/SpeakerAssignmentRules/"));

	SimplePipeline.runPipeline(
			CollectionReaderFactory.createReaderDescription(TextgridTEIUrlReader.class,
					TextgridTEIUrlReader.PARAM_INPUT, "http://www.textgridrep.org/textgrid:w3zd.0",
					TextgridTEIUrlReader.PARAM_CLEANUP, true),
			AnalysisEngineFactory.createEngineDescription(XmiWriter.class, XmiWriter.PARAM_USE_DOCUMENT_ID, true,
					XmiWriter.PARAM_TARGET_LOCATION, "src/test/resources/SpeakerAssignmentRules/"));

	new File("src/test/resources/SpeakerAssignmentRules/typesystem.xml").delete();
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:18,代码来源:TestSpeakerAssignmentRules.java

示例2: main

import org.apache.uima.fit.pipeline.SimplePipeline; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

//        TypeSystemDescription tsd = TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath("../desc/TypeSystem.xml");
        JCas jcas = JCasFactory.createJCas();
        jcas.setDocumentText("Patient is a 30-year-old man named Leroy Butler from Green Bay, WI.");
        AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(MistAnalysisEngine.class,
                MistAnalysisEngine.PARAM_MODEL_PATH,
                "SHARP/model/model");
        SimplePipeline.runPipeline(jcas, aed);
        for(Annotation annot : JCasUtil.select(jcas, Annotation.class)){
            System.out.println("Found annotation: " + annot.getCoveredText());
        }
        JCas deidView = jcas.getView(MistAnalysisEngine.DEID_VIEW_NAME);
        System.out.println("Deidentified version:");
        System.out.println(deidView.getDocumentText());
    }
 
开发者ID:tmills,项目名称:ctakes-docker,代码行数:17,代码来源:TestMistAnalysisEngine.java

示例3: exportToHTML

import org.apache.uima.fit.pipeline.SimplePipeline; //导入依赖的package包/类
public static void exportToHTML(File inputFile, File outputFile)
        throws Exception
{
    File intermediateXMIsFile = File.createTempFile("temp", ".xmi.tar.gz");

    SingleXMLToXMIExporter.exportToXMIs(inputFile, intermediateXMIsFile);

    SimplePipeline.runPipeline(
            CollectionReaderFactory.createReaderDescription(
                    CompressedXmiReader.class,
                    CompressedXmiReader.PARAM_SOURCE_LOCATION, intermediateXMIsFile
            ),
            AnalysisEngineFactory.createEngineDescription(ArgumentsToHTMLExporter.class,
                    ArgumentsToHTMLExporter.PARAM_OUTPUT_FILE, outputFile),
            AnalysisEngineFactory.createEngineDescription(
                    ArgumentDumpWriter.class
            )
    );

    Files.delete(intermediateXMIsFile.toPath());
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:22,代码来源:Step09AnnotatedDataHTMLExporter.java

示例4: main

import org.apache.uima.fit.pipeline.SimplePipeline; //导入依赖的package包/类
public static void main(String[] args)
        throws Exception
{
    String in = "/tmp/temp-in";
    String out = "/tmp/out2.tar.gz";
    // test it
    SimplePipeline.runPipeline(CollectionReaderFactory.createReaderDescription(
            XmiReader.class,
            XmiReader.PARAM_SOURCE_LOCATION, in,
            XmiReader.PARAM_PATTERNS, XmiReader.INCLUDE_PREFIX + "*.xmi"
            ),
            AnalysisEngineFactory.createEngineDescription(
                    NoOpAnnotator.class
            ),
            AnalysisEngineFactory.createEngineDescription(
                    CompressedXmiWriter.class,
                    CompressedXmiWriter.PARAM_OUTPUT_FILE, out
            )
    );

}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:22,代码来源:CompressedXmiWriter.java

示例5: main

import org.apache.uima.fit.pipeline.SimplePipeline; //导入依赖的package包/类
public static void main(String[] args) throws UIMAException, IOException {

		Logger.getRootLogger().setLevel(Level.INFO);

		if (args.length > 0)
			textFolder = args[0];

		// read preprocessed documents
		CollectionReaderDescription reader = CollectionReaderFactory.createReaderDescription(BinaryCasReader.class,
				BinaryCasReader.PARAM_SOURCE_LOCATION, textFolder, BinaryCasReader.PARAM_PATTERNS, textPattern,
				BinaryCasReader.PARAM_LANGUAGE, "en");

		// find Open IE tuples
		AnalysisEngineDescription openIE = AnalysisEngineFactory.createEngineDescription(OpenIEAnnotator.class);

		// write annotated data to file
		AnalysisEngineDescription writer = AnalysisEngineFactory.createEngineDescription(BinaryCasWriter.class,
				BinaryCasWriter.PARAM_TARGET_LOCATION, textFolder, BinaryCasWriter.PARAM_STRIP_EXTENSION, true,
				BinaryCasWriter.PARAM_FILENAME_EXTENSION, ".oie.bin6", BinaryCasWriter.PARAM_OVERWRITE, true);

		// run pipeline
		SimplePipeline.runPipeline(reader, openIE, writer);
	}
 
开发者ID:UKPLab,项目名称:ijcnlp2017-cmaps,代码行数:24,代码来源:PipelineOpenIE.java

示例6: run

import org.apache.uima.fit.pipeline.SimplePipeline; //导入依赖的package包/类
public void run()
    throws Exception
{
    String modelFolder = "target/theModel";
    // train the model we will use later
    trainModel(modelFolder);

    CollectionReaderDescription reader = CollectionReaderFactory.createReaderDescription(
            TextReader.class, TextReader.PARAM_SOURCE_LOCATION,
            "src/main/resources/raw/rawText.txt", TextReader.PARAM_LANGUAGE, "en");

    AnalysisEngineDescription seg = AnalysisEngineFactory
            .createEngineDescription(BreakIteratorSegmenter.class);
    AnalysisEngineDescription tagger = AnalysisEngineFactory.createEngineDescription(
            FlexTagUima.class, FlexTagUima.PARAM_LANGUAGE, "en",
            FlexTagUima.PARAM_MODEL_LOCATION, modelFolder);

    // a helper class which simply iterates each token and prints the predicted POS tag
    AnalysisEngineDescription printer = AnalysisEngineFactory
            .createEngineDescription(OutputPrinter.class);

    SimplePipeline.runPipeline(reader, seg, tagger, printer);
}
 
开发者ID:Horsmann,项目名称:FlexTag,代码行数:24,代码来源:ExampleUseModelUima.java

示例7: runMetaCollection

import org.apache.uima.fit.pipeline.SimplePipeline; //导入依赖的package包/类
private void runMetaCollection(File luceneFolder)
    throws Exception
{

    Object[] parameters = new Object[] { LuceneUniGramMetaCollector.PARAM_UNIQUE_EXTRACTOR_NAME,
            EXTRACTOR_NAME,
            TokenContext.PARAM_SOURCE_LOCATION, luceneFolder.toString(),
            LuceneUniGramMetaCollector.PARAM_TARGET_LOCATION, luceneFolder.toString()
            };

    List<Object> parameterList = new ArrayList<Object>(Arrays.asList(parameters));

    CollectionReaderDescription reader = CollectionReaderFactory.createReaderDescription(
            TestReaderSingleLabel.class, TestReaderSingleLabel.PARAM_LANGUAGE, "en",
            TestReaderSingleLabel.PARAM_SOURCE_LOCATION, "src/test/resources/text/input.txt");

    AnalysisEngineDescription segmenter = AnalysisEngineFactory
            .createEngineDescription(BreakIteratorSegmenter.class);

    AnalysisEngineDescription metaCollector = AnalysisEngineFactory
            .createEngineDescription(LuceneUniGramMetaCollector.class, parameterList.toArray());

    // run meta collector
    SimplePipeline.runPipeline(reader, segmenter, metaCollector);
}
 
开发者ID:Horsmann,项目名称:FlexTag,代码行数:26,代码来源:LuceneNgramUnitTest.java

示例8: train

import org.apache.uima.fit.pipeline.SimplePipeline; //导入依赖的package包/类
@Override
public void train(CollectionReader collectionReader, File outputDirectory) throws Exception {
  AggregateBuilder builder = new AggregateBuilder();
  builder.add(UriToDocumentTextAnnotator.getDescription());
  builder.add(SentenceAnnotator.getDescription());
  builder.add(TokenAnnotator.getDescription());
  builder.add(PosTaggerAnnotator.getDescription());
  builder.add(DefaultSnowballStemmer.getDescription("English"));
  builder.add(AnalysisEngineFactory.createEngineDescription(GoldQuestionCategoryAnnotator.class));
  AnalysisEngineDescription documentClassificationAnnotator = AnalysisEngineFactory.createEngineDescription(
      QuestionCategoryAnnotator.class, CleartkAnnotator.PARAM_IS_TRAINING, true,
      DirectoryDataWriterFactory.PARAM_OUTPUT_DIRECTORY, outputDirectory,
      DefaultDataWriterFactory.PARAM_DATA_WRITER_CLASS_NAME, LibSvmStringOutcomeDataWriter.class.getName());
  builder.add(documentClassificationAnnotator);
  SimplePipeline.runPipeline(collectionReader, builder.createAggregateDescription());
  System.err.println("Train model and write model.jar file.");
  HideOutput hider = new HideOutput();
  Train.main(outputDirectory, this.trainingArguments.toArray(new String[this.trainingArguments.size()]));
  hider.restoreOutput();
}
 
开发者ID:utk4rsh,项目名称:question-classifier,代码行数:21,代码来源:QuestionCategoryEvaluation.java

示例9: main

import org.apache.uima.fit.pipeline.SimplePipeline; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  Options options = CliFactory.parseArguments(Options.class, args);
  CollectionReader reader = UriCollectionReader.getCollectionReaderFromDirectory(options.getTestDirectory(),
      UriCollectionReader.RejectSystemFiles.class, UriCollectionReader.RejectSystemDirectories.class);
  AggregateBuilder builder = new AggregateBuilder();
  builder.add(UriToDocumentTextAnnotator.getDescription());
  builder.add(SentenceAnnotator.getDescription());
  builder.add(TokenAnnotator.getDescription());
  builder.add(PosTaggerAnnotator.getDescription());
  builder.add(DefaultSnowballStemmer.getDescription("English"));
  builder.add(AnalysisEngineFactory.createEngineDescription(QuestionCategoryAnnotator.class,
      CleartkAnnotator.PARAM_IS_TRAINING, false, GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
      JarClassifierBuilder.getModelJarFile(options.getModelsDirectory())));
  SimplePipeline.runPipeline(reader, builder.createAggregateDescription(),
      AnalysisEngineFactory.createEngineDescription(PrintClassificationsAnnotator.class));
}
 
开发者ID:utk4rsh,项目名称:question-classifier,代码行数:17,代码来源:App.java

示例10: main

import org.apache.uima.fit.pipeline.SimplePipeline; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  if (args.length != 3) {
    System.out.println("arguments: " //
            + "path to XML descriptor for pipeline, " //
            + "folder with text files, " //
            + "folder to output xmi files");
    System.exit(-1);
  }

  // A collection reader that reads text files
  CollectionReader reader = CollectionReaderFactory.createReader(FilesCollectionReader.class,
          null, FilesCollectionReader.PARAM_ROOT_FILE, args[1]);

  AggregateBuilder builder = new AggregateBuilder();
  AnalysisEngineDescription descriptor = (AnalysisEngineDescription) createResourceCreationSpecifier(
          new XMLInputSource(RunPipelineXmi.class.getClassLoader().getResourceAsStream(args[0]),
                  new File(".")), new Object[0]);
  builder.add(descriptor);
  builder.add(XmiWriter.getDescription(new File(args[2])));
  
  SimplePipeline.runPipeline(reader, builder.createAggregateDescription());
}
 
开发者ID:IE4OpenData,项目名称:Octroy,代码行数:23,代码来源:RunPipelineXmi.java

示例11: main

import org.apache.uima.fit.pipeline.SimplePipeline; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  if (args.length != 3) {
    System.out.println("arguments: " //
            + "path to XML descriptor for pipeline, " //
            + "folder with text files, " //
            + "path to output tsv file");
    System.exit(-1);
  }

  // A collection reader that reads text files
  CollectionReader reader = CollectionReaderFactory.createReader(FilesCollectionReader.class,
          null, FilesCollectionReader.PARAM_ROOT_FILE, args[1]);

  AggregateBuilder builder = new AggregateBuilder();
  AnalysisEngineDescription descriptor = (AnalysisEngineDescription) createResourceCreationSpecifier(
          new XMLInputSource(RunPipelineTsv.class.getClassLoader().getResourceAsStream(args[0]),
                  new File(".")), new Object[0]);
  builder.add(descriptor);
  builder.add(TsvWriter.getDescription(new File(args[2])));

  SimplePipeline.runPipeline(reader, builder.createAggregateDescription());
}
 
开发者ID:IE4OpenData,项目名称:Octroy,代码行数:23,代码来源:RunPipelineTsv.java

示例12: main

import org.apache.uima.fit.pipeline.SimplePipeline; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	// A collection reader that reads XMIs
	CollectionReader reader = CollectionReaderFactory.createReader(XReader.class, null, XReader.PARAM_ROOT_FILE,
			args[0]);

	// The pipeline of annotators
	AggregateBuilder builder = new AggregateBuilder();

	// other annotators, if needed
	builder.add(UIMAFramework.getXMLParser().parseAnalysisEngineDescription(
			new XMLInputSource("src/main/resources/org/ie4opendata/octroy/SimpleFrenchTokenAndSentenceAnnotator.xml")));

	// Use this to get the parameters for the descriptor
	//System.out.println(ReasonAnnotator.getClassifierDescription("org/ie4opendata/octroy/reason/model.jar"));
	//System.exit(0);
	// The reason classifier annotator, configured to write training data
	builder.add(ReasonAnnotator.getWriterDescription("src/main/resources/org/ie4opendata/octroy/reason"));

	// Run the pipeline of annotators on each of the CASes produced by the reader
	SimplePipeline.runPipeline(reader, builder.createAggregateDescription());

	// Train a classifier on the training data, and package it into a .jar file
	Train.main("src/main/resources/org/ie4opendata/octroy/reason");
}
 
开发者ID:IE4OpenData,项目名称:Octroy,代码行数:25,代码来源:ReasonTrainer.java

示例13: train

import org.apache.uima.fit.pipeline.SimplePipeline; //导入依赖的package包/类
@Override
protected void train(CollectionReader collectionReader, File directory) throws Exception {
	String tmpView = "DP";

	AggregateBuilder b = new AggregateBuilder();

	b.add(AnalysisEngineFactory.createEngineDescription(PrepareClearTk.class, PrepareClearTk.PARAM_VIEW_NAME,
			tmpView, PrepareClearTk.PARAM_ANNOTATION_TYPE, DramatisPersonae.class,
			PrepareClearTk.PARAM_SUBANNOTATIONS, Arrays.asList(Figure.class)));
	b.add(AnalysisEngineFactory.createEngineDescription(BreakIteratorSegmenter.class), CAS.NAME_DEFAULT_SOFA,
			tmpView);
	b.add(AnalysisEngineFactory.createEngineDescription(ClearTkGenderAnnotator.class,
			DefaultDataWriterFactory.PARAM_DATA_WRITER_CLASS_NAME, LibSvmStringOutcomeDataWriter.class,
			DirectoryDataWriterFactory.PARAM_OUTPUT_DIRECTORY, directory), CAS.NAME_DEFAULT_SOFA, tmpView);
	b.add(AnalysisEngineFactory.createEngineDescription(XmiWriter.class, XmiWriter.PARAM_TARGET_LOCATION,
			"target/xmi"));

	SimplePipeline.runPipeline(collectionReader, b.createAggregate());

	Train.main(directory, new String[] { "-t", "0" });
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:22,代码来源:Evaluation.java

示例14: main

import org.apache.uima.fit.pipeline.SimplePipeline; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	CollectionReaderDescription reader = CollectionReaderFactory.createReaderDescription(XmiReader.class,
			XmiReader.PARAM_SOURCE_LOCATION, "src/main/resources/gender/*/*.xmi", XmiReader.PARAM_LENIENT, true);

	String tmpView = "DP";

	AggregateBuilder b = new AggregateBuilder();

	b.add(AnalysisEngineFactory.createEngineDescription(PrepareClearTk.class, PrepareClearTk.PARAM_VIEW_NAME,
			tmpView, PrepareClearTk.PARAM_ANNOTATION_TYPE, DramatisPersonae.class,
			PrepareClearTk.PARAM_SUBANNOTATIONS, Arrays.asList(Figure.class)));
	b.add(AnalysisEngineFactory.createEngineDescription(BreakIteratorSegmenter.class), CAS.NAME_DEFAULT_SOFA,
			tmpView);
	b.add(AnalysisEngineFactory.createEngineDescription(ClearTkGenderAnnotator.class,
			DefaultDataWriterFactory.PARAM_DATA_WRITER_CLASS_NAME, LibSvmStringOutcomeDataWriter.class,
			DirectoryDataWriterFactory.PARAM_OUTPUT_DIRECTORY, "target/models"), CAS.NAME_DEFAULT_SOFA, tmpView);
	b.add(AnalysisEngineFactory.createEngineDescription(XmiWriter.class, XmiWriter.PARAM_TARGET_LOCATION,
			"target/xmi"));
	SimplePipeline.runPipeline(reader, b.createAggregateDescription());

	Train.main(new File("target/models"), new String[] { "-t", "0" });
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:23,代码来源:Training.java

示例15: testMapBackFeature

import org.apache.uima.fit.pipeline.SimplePipeline; //导入依赖的package包/类
@Test
public void testMapBackFeature() {
	try {
		SimplePipeline.runPipeline(view,
				AnalysisEngineFactory.createEngineDescription(XmiWriter.class, XmiWriter.PARAM_TARGET_LOCATION,
						"target/test", XmiWriter.PARAM_USE_DOCUMENT_ID, true),
				AnalysisEngineFactory.createEngineDescription(MapBackFeature.class,
						MapBackFeature.PARAM_ANNOTATION_TYPE, POS.class, MapBackFeature.PARAM_FEATURE_NAME,
						"PosValue", MapBackFeature.PARAM_VIEW_NAME, viewName));
	} catch (AnalysisEngineProcessException | ResourceInitializationException e) {
		e.printStackTrace();
	}
	POS pos = JCasUtil.selectByIndex(jcas, POS.class, 2);
	assertEquals("1", pos.getPosValue());

}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:17,代码来源:TestMapBackFeature.java


注:本文中的org.apache.uima.fit.pipeline.SimplePipeline类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。