本文整理汇总了Java中org.apache.uima.fit.factory.CollectionReaderFactory类的典型用法代码示例。如果您正苦于以下问题:Java CollectionReaderFactory类的具体用法?Java CollectionReaderFactory怎么用?Java CollectionReaderFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CollectionReaderFactory类属于org.apache.uima.fit.factory包,在下文中一共展示了CollectionReaderFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入依赖的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();
}
示例2: exportToHTML
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入依赖的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
示例3: main
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入依赖的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
)
);
}
示例4: main
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入依赖的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);
}
示例5: run
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入依赖的package包/类
public void run()
throws Exception
{
String language = "en";
String trainCorpora = DemoConstants.TRAIN_FOLDER_CROSS_VALIDATION;
String trainFileSuffix = "*.txt";
CollectionReaderDescription crd = CollectionReaderFactory.createReaderDescription(
LineTokenTagReader.class, LineTokenTagReader.PARAM_LANGUAGE, language,
LineTokenTagReader.PARAM_SOURCE_LOCATION, trainCorpora,
LineTokenTagReader.PARAM_PATTERNS, trainFileSuffix);
FlexTagCrossValidation flex = new FlexTagCrossValidation(crd, 2);
if (System.getProperty("DKPRO_HOME") == null) {
flex.setDKProHomeFolder("target/home");
}
flex.setExperimentName("WekaCrossValidationDemo");
flex.setFeatures(TcFeatureFactory.create(LuceneCharacterNGram.class));
List<Object> configuration = asList(new Object[] { J48.class.getName() });
flex.setClassifier(Classifier.WEKA, configuration);
flex.addReport(CvWekafAvgKnownUnknownAccuracyReport.class);
flex.execute();
}
示例6: trainModel
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入依赖的package包/类
private static void trainModel(String folder)
throws Exception
{
String language = "en";
String corpora = DemoConstants.TRAIN_FOLDER;
String fileSuffix = "*.txt";
CollectionReaderDescription trainReader = CollectionReaderFactory.createReaderDescription(
LineTokenTagReader.class, LineTokenTagReader.PARAM_LANGUAGE, language,
LineTokenTagReader.PARAM_SOURCE_LOCATION, corpora,
LineTokenTagReader.PARAM_PATTERNS, fileSuffix);
FlexTagTrainSaveModel flex = new FlexTagTrainSaveModel(trainReader, new File(folder));
flex.setFeatures(TcFeatureFactory.create(BrownCluster.class,
BrownCluster.PARAM_RESOURCE_LOCATION, DemoConstants.BROWN_CLUSTER));
if (System.getProperty("DKPRO_HOME") == null) {
flex.setDKProHomeFolder("target/home");
}
flex.setExperimentName("ExampleUseModelDemo");
flex.execute();
}
示例7: run
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入依赖的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);
}
示例8: trainModel
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入依赖的package包/类
private static void trainModel(String folder)
throws Exception
{
String language = "en";
String corpora = DemoConstants.TRAIN_FOLDER;
String fileSuffix = "*.txt";
CollectionReaderDescription trainReader = CollectionReaderFactory.createReaderDescription(
LineTokenTagReader.class, LineTokenTagReader.PARAM_LANGUAGE, language,
LineTokenTagReader.PARAM_SOURCE_LOCATION, corpora,
LineTokenTagReader.PARAM_PATTERNS, fileSuffix);
FlexTagTrainSaveModel flex = new FlexTagTrainSaveModel(trainReader, new File(folder));
if (System.getProperty("DKPRO_HOME") == null) {
flex.setDKProHomeFolder("target/home");
}
flex.setFeatures(DefaultFeatures.getDefaultFeatures(Classifier.CRFSUITE));
flex.setExperimentName("ExampleUseModelDemo");
flex.execute();
}
示例9: runMetaCollection
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入依赖的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);
}
示例10: main
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入依赖的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());
}
示例11: main
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入依赖的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());
}
示例12: main
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入依赖的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");
}
示例13: main
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入依赖的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" });
}
示例14: testRules1
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入依赖的package包/类
@Test
public void testRules1() throws Exception {
org.apache.uima.fit.pipeline.JCasIterator iter = SimplePipeline.iteratePipeline(
CollectionReaderFactory.createReaderDescription(XmiReader.class, XmiReader.PARAM_SOURCE_LOCATION,
"src/test/resources/SpeakerAssignmentRules/tx4z.0.xmi", XmiReader.PARAM_LENIENT, true),
AnalysisEngineFactory.createEngineDescription(FigureReferenceAnnotator.class),
AnalysisEngineFactory.createEngineDescription(SpeakerAssignmentRules.class,
SpeakerAssignmentRules.PARAM_RULE_FILE_URL,
new File("src/test/resources/SpeakerAssignmentRules/speaker-assignment-mapping.tsv").toURI()
.toURL()))
.iterator();
if (iter.hasNext()) {
JCas jcas = iter.next();
for (Speaker speaker : JCasUtil.select(jcas, Speaker.class)) {
if (speaker.getCoveredText().equalsIgnoreCase("carlos"))
assertNotNull(speaker.getCoveredText(), speaker.getFigure());
}
}
}
示例15: testRules2
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入依赖的package包/类
@Test
public void testRules2() throws Exception {
org.apache.uima.fit.pipeline.JCasIterator iter = SimplePipeline.iteratePipeline(
CollectionReaderFactory.createReaderDescription(XmiReader.class, XmiReader.PARAM_SOURCE_LOCATION,
"src/test/resources/SpeakerAssignmentRules/w3zd.0.xmi", XmiReader.PARAM_LENIENT, true),
AnalysisEngineFactory.createEngineDescription(FigureReferenceAnnotator.class),
AnalysisEngineFactory.createEngineDescription(SpeakerAssignmentRules.class,
SpeakerAssignmentRules.PARAM_RULE_FILE_URL,
new File("src/test/resources/SpeakerAssignmentRules/speaker-assignment-mapping.tsv").toURI()
.toURL()))
.iterator();
assertTrue(iter.hasNext());
JCas jcas = iter.next();
assertNotNull(jcas);
for (Speaker speaker : JCasUtil.select(jcas, Speaker.class)) {
if (speaker.getCoveredText().equalsIgnoreCase("der capitain"))
assertNotNull(speaker.getCoveredText(), speaker.getFigure());
}
}