本文整理汇总了Java中org.apache.uima.fit.factory.CollectionReaderFactory.createReader方法的典型用法代码示例。如果您正苦于以下问题:Java CollectionReaderFactory.createReader方法的具体用法?Java CollectionReaderFactory.createReader怎么用?Java CollectionReaderFactory.createReader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.uima.fit.factory.CollectionReaderFactory
的用法示例。
在下文中一共展示了CollectionReaderFactory.createReader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
示例2: 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());
}
示例3: 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");
}
示例4: getCollectionReader
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入方法依赖的package包/类
public static CollectionReader getCollectionReader(
List<File> dataDirectories,
Set<String> selectedFileNames) throws ResourceInitializationException {
// workaround UimaFIT limitation
List<String> dirsList = new ArrayList<String>();
for (File dir : dataDirectories) {
dirsList.add(dir.getPath());
}
String[] dirs = dirsList.toArray(new String[dirsList.size()]);
String[] names = selectedFileNames == null
? null
: selectedFileNames.toArray(new String[selectedFileNames.size()]);
return CollectionReaderFactory.createReader(
TempEval2010CollectionReader.class,
null,
PARAM_DATA_DIRECTORIES,
dirs,
PARAM_SELECTED_FILE_NAMES,
names);
}
示例5: testHasNextLooping
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入方法依赖的package包/类
@Test
public void testHasNextLooping() throws Exception{
DummyBaleenCollectionReader cr = (DummyBaleenCollectionReader) CollectionReaderFactory.createReader(DummyBaleenCollectionReader.class);
// Create a thread which will kill the manager as soon as its started
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// Do nothing
}
}
}).start();
while(cr.hasNext()){
JCas jCas = JCasSingleton.getJCasInstance();
cr.getNext(jCas.getCas());
}
cr.destroy();
}
示例6: testDescriptor
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入方法依赖的package包/类
@Test
public void testDescriptor() throws UIMAException {
try {
CollectionReaderFactory.createReader(XReader.class);
Assert.fail("expected exception with no file or directory specified");
} catch (ResourceInitializationException e) {
}
CollectionReader reader = CollectionReaderFactory.createReader(
XReader.class,
FilesCollectionReader.PARAM_ROOT_FILE,
outputDirectory.getPath());
Object fileOrDirectory = reader.getConfigParameterValue(FilesCollectionReader.PARAM_ROOT_FILE);
Assert.assertEquals(outputDirectory.getPath(), fileOrDirectory);
}
示例7: testDescriptor
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入方法依赖的package包/类
@Test
public void testDescriptor() throws UIMAException {
try {
CollectionReaderFactory.createReader(FilesCollectionReader.class);
fail("expected exception with no file or directory specified");
} catch (ResourceInitializationException e) {
}
CollectionReader reader = CollectionReaderFactory.createReader(
FilesCollectionReader.class,
FilesCollectionReader.PARAM_ROOT_FILE,
this.inputDir);
Object fileOrDirectory = reader.getConfigParameterValue(FilesCollectionReader.PARAM_ROOT_FILE);
assertEquals(this.inputDir, fileOrDirectory);
Object viewName = reader.getConfigParameterValue(FilesCollectionReader.PARAM_VIEW_NAME);
assertEquals(CAS.NAME_DEFAULT_SOFA, viewName);
Object encoding = reader.getConfigParameterValue(FilesCollectionReader.PARAM_ENCODING);
assertEquals(null, encoding);
Object language = reader.getConfigParameterValue(FilesCollectionReader.PARAM_LANGUAGE);
assertEquals(null, language);
}
示例8: testCount
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入方法依赖的package包/类
@Test
public void testCount() throws Exception {
CollectionReader cr = CollectionReaderFactory.createReader(
BioNLPGeniaEventsCollectionReader.class,
BlueUima.PARAM_INPUT_DIRECTORY, TEST_DIR);
int i = 0;
while (cr.hasNext()) {
CAS cas = CasCreationUtils.createCas(cr
.getProcessingResourceMetaData());
cr.getNext(cas);
LOG.debug(To.string("cas nr " + i, cas.getJCas()));
i++;
}
cr.close();
assertEquals(3, i);
}
示例9: test
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
CollectionReader cr = CollectionReaderFactory.createReader(
BioNLPGeniaEventsCollectionReader.class);
int i = 0;
while (cr.hasNext()) {
CAS cas = CasCreationUtils.createCas(cr
.getProcessingResourceMetaData());
cr.getNext(cas);
// if (createHtml)
// viewer.createHtml(cas.getJCas(), cas.getTypeSystem(),
// styleMapFile, new File("target/" + i));
i++;
}
cr.close();
assertEquals(259, i);
}
示例10: testTestCorpus
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入方法依赖的package包/类
@Test
public void testTestCorpus() throws Exception {
CollectionReader cr = CollectionReaderFactory.createReader(
Biocreative2GeneCollectionReader.class, BlueUima.PARAM_MODE,
"test");
CAS cas = CasCreationUtils
.createCas(cr.getProcessingResourceMetaData());
cr.getNext(cas);
Collection<BioEntityMention> genes = JCasUtil.select(cas.getJCas(),
BioEntityMention.class);
assertEquals(2, genes.size());
cr.close();
}
示例11: main
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
// A collection reader that reads text files
CollectionReader reader = CollectionReaderFactory.createReader(FilesCollectionReader.class,
null, FilesCollectionReader.PARAM_ROOT_FILE, args[0]);
AggregateBuilder builder = new AggregateBuilder();
builder.add(XmiWriter.getDescription(new File(args[1])));
SimplePipeline.runPipeline(reader, builder.createAggregateDescription());
}
示例12: getCollectionReader
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入方法依赖的package包/类
@Override
protected CollectionReader getCollectionReader(List<File> files) throws Exception {
File current = new File("src/main/resources/gender");
List<String> relativeFilenames = new LinkedList<String>();
for (File f : files) {
relativeFilenames.add(f.getName());
}
return CollectionReaderFactory.createReader(XReader.class, XReader.PARAM_FILE_NAMES, relativeFilenames,
XReader.PARAM_ROOT_FILE, current, XReader.PARAM_XML_SCHEME, XReader.XMI);
}
示例13: getCollectionReader
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入方法依赖的package包/类
public static CollectionReader getCollectionReader(String conll2005DataFile)
throws ResourceInitializationException {
return CollectionReaderFactory.createReader(
Conll2005GoldReader.class,
PARAM_CONLL2005_DATA_FILE,
conll2005DataFile);
}
示例14: testDescriptor
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入方法依赖的package包/类
@Test
public void testDescriptor() throws UIMAException {
try {
CollectionReaderFactory.createReader(Conll2005GoldReader.class);
Assert.fail("expected error for missing CoNLL 2005 data file");
} catch (ResourceInitializationException e) {
}
CollectionReader reader = CollectionReaderFactory.createReader(
Conll2005GoldReader.class,
Conll2005GoldReader.PARAM_CONLL2005_DATA_FILE,
this.oneSentencePath);
Object dataFileName = reader.getConfigParameterValue(Conll2005GoldReader.PARAM_CONLL2005_DATA_FILE);
Assert.assertEquals(this.oneSentencePath, dataFileName);
}
示例15: read
import org.apache.uima.fit.factory.CollectionReaderFactory; //导入方法依赖的package包/类
public void read()
throws Exception
{
CollectionReader xmiReader = CollectionReaderFactory.createReader(XmiReader.class,
ResourceCollectionReaderBase.PARAM_SOURCE_LOCATION, testFolder.getRoot().getPath(),
ResourceCollectionReaderBase.PARAM_PATTERNS,
new String[] { ResourceCollectionReaderBase.INCLUDE_PREFIX + "*.xmi" });
CAS cas = CasCreationUtils.createCas(createTypeSystemDescription(), null, null);
xmiReader.getNext(cas);
String refText = readFileToString(new File("src/test/resources/texts/latin.txt"));
assertEquals(refText, cas.getDocumentText());
assertEquals("latin", cas.getDocumentLanguage());
}