本文整理汇总了Java中org.apache.uima.fit.factory.AnalysisEngineFactory.createEngine方法的典型用法代码示例。如果您正苦于以下问题:Java AnalysisEngineFactory.createEngine方法的具体用法?Java AnalysisEngineFactory.createEngine怎么用?Java AnalysisEngineFactory.createEngine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.uima.fit.factory.AnalysisEngineFactory
的用法示例。
在下文中一共展示了AnalysisEngineFactory.createEngine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beforeTest
import org.apache.uima.fit.factory.AnalysisEngineFactory; //导入方法依赖的package包/类
@Override
public void beforeTest() throws UIMAException {
super.beforeTest();
final ExternalResourceDescription tokensDesc = ExternalResourceFactory.createExternalResourceDescription(
"lexica",
ClearNlpLexica.class);
final AnalysisEngineDescription tokeniserDesc = AnalysisEngineFactory.createEngineDescription(
ClearNlpTokeniser.class,
"lexica",
tokensDesc);
tokeniserAe = AnalysisEngineFactory.createEngine(tokeniserDesc);
final AnalysisEngineDescription parserDesc = AnalysisEngineFactory.createEngineDescription(ClearNlpParser.class,
"lexica",
tokensDesc);
ae = AnalysisEngineFactory.createEngine(parserDesc);
}
示例2: setUp
import org.apache.uima.fit.factory.AnalysisEngineFactory; //导入方法依赖的package包/类
@Before
public void setUp() throws ResourceInitializationException, ResourceAccessException {
// Create a description of an external resource - a fongo instance, in the same way we would
// have created a shared mongo resource
final ExternalResourceDescription erd = ExternalResourceFactory.createExternalResourceDescription(
SharedFongoResource.class, "fongo.collection", "test", "fongo.data", "[]");
// Create the analysis engine
final AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(MongoPatternSaver.class,
MongoPatternSaver.KEY_MONGO, erd,
"collection", "test");
ae = AnalysisEngineFactory.createEngine(aed);
ae.initialize(new CustomResourceSpecifier_impl(), Collections.emptyMap());
sfr = (SharedFongoResource) ae.getUimaContext()
.getResourceObject(MongoPatternSaver.KEY_MONGO);
}
示例3: createDictionaryAnnotatorEngine
import org.apache.uima.fit.factory.AnalysisEngineFactory; //导入方法依赖的package包/类
private static AnalysisEngine createDictionaryAnnotatorEngine() throws Exception {
AggregateBuilder builder = new AggregateBuilder();
builder.add(AnalysisEngineFactory.createEngineDescription(SimpleTokenizer.class,
UimaUtil.SENTENCE_TYPE_PARAMETER, Sentence.class.getName(),
UimaUtil.TOKEN_TYPE_PARAMETER, Token.class.getName()));
builder.add(AnalysisEngineFactory.createEngineDescription(DictionaryAnnotator.class,
DictionaryAnnotator.PARAM_DICTIONARY_LOCATION, "classpath:benchmark-dictionary.csv",
DictionaryAnnotator.PARAM_TOKENIZER_CLASS, SimpleOpenNlpTokenizer.class.getName(),
DictionaryAnnotator.PARAM_ANNOTATION_TYPE, DictionaryEntry.class.getName(),
DictionaryAnnotator.PARAM_CSV_SEPARATOR, ";",
DictionaryAnnotator.PARAM_DICTIONARY_CASE_SENSITIVE, true,
DictionaryAnnotator.PARAM_DICTIONARY_ACCENT_SENSITIVE, true));
AnalysisEngine engine = AnalysisEngineFactory.createEngine(builder.createAggregateDescription());
return engine;
}
示例4: process
import org.apache.uima.fit.factory.AnalysisEngineFactory; //导入方法依赖的package包/类
private JCas process(AnalysisEngineDescription dictionaryDescription, String text) {
try {
AggregateBuilder builder = new AggregateBuilder();
builder.add(AnalysisEngineFactory.createEngineDescription(SimpleTokenizer.class,
UimaUtil.SENTENCE_TYPE_PARAMETER, "uima.tcas.DocumentAnnotation",
UimaUtil.TOKEN_TYPE_PARAMETER, Token.class.getName()));
builder.add(dictionaryDescription);
AnalysisEngine engine = AnalysisEngineFactory.createEngine(builder.createAggregateDescription());
JCas jcas = engine.newJCas();
jcas.setDocumentText(text);
engine.process(jcas);
return jcas;
} catch (Exception e) {
throw new RuntimeException("Failed to create UIMA engine", e);
}
}
示例5: testCaseInsensitive
import org.apache.uima.fit.factory.AnalysisEngineFactory; //导入方法依赖的package包/类
@Test
public void testCaseInsensitive() throws Exception{
AnalysisEngine regexAE = AnalysisEngineFactory.createEngine(Custom.class, Custom.PARAM_TYPE, UK_GOV_DSTL_BALEEN_TYPES_COMMON_PERSON, Custom.PARAM_PATTERN, DIGIT_REGEX, Custom.PARAM_CASE_SENSITIVE, false);
jCas.setDocumentText(TEXT);
regexAE.process(jCas);
assertEquals(2, JCasUtil.select(jCas, Person.class).size());
Person p1 = JCasUtil.selectByIndex(jCas, Person.class, 0);
assertNotNull(p1);
assertEquals(P123, p1.getCoveredText());
assertEquals(P123, p1.getValue());
Person p2 = JCasUtil.selectByIndex(jCas, Person.class, 1);
assertNotNull(p2);
assertEquals(P456, p2.getCoveredText());
assertEquals(P456, p2.getValue());
regexAE.destroy();
}
示例6: testLineBreak
import org.apache.uima.fit.factory.AnalysisEngineFactory; //导入方法依赖的package包/类
@Test
public void testLineBreak() throws UIMAException, IOException {
AnalysisEngine consumer = AnalysisEngineFactory.createEngine(Html5.class, TypeSystemSingleton.getTypeSystemDescriptionInstance(), Html5.PARAM_OUTPUT_FOLDER,
outputFolder.getPath());
DocumentAnnotation da = (DocumentAnnotation) jCas.getDocumentAnnotationFs();
da.setSourceUri("multiline.txt");
jCas.setDocumentText("His name was James\n\nBond.");
Person p = new Person(jCas, 13, 24);
p.addToIndexes();
consumer.process(jCas);
File f = new File(outputFolder, "multiline.txt.html");
assertTrue(f.exists());
assertTrue(Files.toString(f, StandardCharsets.UTF_8).contains("data-referent=\"\">James\n\nBond</span>"));
}
示例7: test
import org.apache.uima.fit.factory.AnalysisEngineFactory; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
AnalysisEngine engine = AnalysisEngineFactory.createEngine(PosTagger.getDescription("en"));
this.tokenBuilder.buildTokens(
this.jCas,
"The brown fox jumped quickly over the lazy dog.",
"The brown fox jumped quickly over the lazy dog .");
engine.process(this.jCas);
List<String> expected = Arrays.asList("DT JJ NN VBD RB IN DT JJ NN .".split(" "));
List<String> actual = new ArrayList<String>();
for (Token token : JCasUtil.select(this.jCas, Token.class)) {
actual.add(token.getPos());
}
Assert.assertEquals(expected, actual);
}
示例8: testOutputEmpty
import org.apache.uima.fit.factory.AnalysisEngineFactory; //导入方法依赖的package包/类
@Test
public void testOutputEmpty() throws Exception {
final AnalysisEngine consumer =
AnalysisEngineFactory.createEngine(StructuralHtml.class, Html5.PARAM_OUTPUT_FOLDER,
outputFolder.getPath(), StructuralHtml.PARAM_OUTPUT_EMPTY_TAGS, true);
final DocumentAnnotation da = (DocumentAnnotation) jCas.getDocumentAnnotationFs();
da.setSourceUri("test.txt");
jCas.setDocumentText("Example document: ''");
final Paragraph d = new Paragraph(jCas);
d.setBegin(19);
d.setEnd(19);
d.addToIndexes();
consumer.process(jCas);
final File f = new File(outputFolder, "test.txt.html");
assertTrue(f.exists());
System.out.println(Jsoup.parse(f, "UTF-8").html());
assertEquals(Jsoup.parse(f, "UTF-8").html().replaceAll("\\s*", ""),
EXPECTED_EMPTY.replaceAll("\\s*", ""));
}
示例9: testCoNLL2005WriterDescriptor
import org.apache.uima.fit.factory.AnalysisEngineFactory; //导入方法依赖的package包/类
@Test
public void testCoNLL2005WriterDescriptor() throws UIMAException {
try {
AnalysisEngineFactory.createEngine(Conll2005Writer.class);
Assert.fail("expected exception without output file parameter");
} catch (ResourceInitializationException e) {
}
File outputFile = new File(outputDirectory, "dev-set-result.txt");
AnalysisEngine engine = AnalysisEngineFactory.createEngine(
Conll2005Writer.class,
Conll2005Writer.PARAM_OUTPUT_FILE,
outputFile.getPath());
engine.collectionProcessComplete();
}
示例10: testCaseSensitive
import org.apache.uima.fit.factory.AnalysisEngineFactory; //导入方法依赖的package包/类
@Test
public void testCaseSensitive() throws Exception{
ExternalResourceDescription erd = ExternalResourceFactory.createExternalResourceDescription(FILE_GAZETTEER, SharedFileResource.class);
AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(File.class, FILE_GAZETTEER, erd, FILE_NAME, getClass().getResource(GAZETTEER_TXT).getPath(), TYPE, LOCATION, "caseSensitive", true);
AnalysisEngine ae = AnalysisEngineFactory.createEngine(aed);
jCas.setDocumentText("This text mentions New York and Paris in upper case and new york in lower case");
ae.process(jCas);
// should match "new york" and "Paris", but not "New York"
assertEquals(2, JCasUtil.select(jCas, Location.class).size());
Location l1 = JCasUtil.selectByIndex(jCas, Location.class, 0);
Location l2 = JCasUtil.selectByIndex(jCas, Location.class, 1);
assertEquals("Paris", l1.getValue());
assertEquals("new york", l2.getValue());
ae.destroy();
}
示例11: testWindowClassNames
import org.apache.uima.fit.factory.AnalysisEngineFactory; //导入方法依赖的package包/类
@Test
public void testWindowClassNames() throws Exception {
String text = "I bought a lamp. I love lamp. Lamps are great!";
this.jCas.setDocumentText(text);
Sentence window = new Sentence(this.jCas, 0, 30);
window.addToIndexes();
AnalysisEngineDescription desc = SentenceAnnotator.getDescription();
ConfigurationParameterFactory.addConfigurationParameter(
desc,
SentenceAnnotator.PARAM_WINDOW_CLASS_NAMES,
new String[] { "org.cleartk.token.type.Sentence" });
AnalysisEngine engine = AnalysisEngineFactory.createEngine(desc);
engine.process(this.jCas);
engine.collectionProcessComplete();
Collection<Sentence> sentences = JCasUtil.select(this.jCas, Sentence.class);
Iterator<Sentence> sentenceIter = sentences.iterator();
assertEquals(3, sentences.size());
assertEquals(window, sentenceIter.next());
assertEquals("I bought a lamp.", sentenceIter.next().getCoveredText());
assertEquals("I love lamp.", sentenceIter.next().getCoveredText());
}
示例12: testNoExistingReferentsMerge
import org.apache.uima.fit.factory.AnalysisEngineFactory; //导入方法依赖的package包/类
@Test
public void testNoExistingReferentsMerge() throws Exception{
AnalysisEngine ae = AnalysisEngineFactory.createEngine(CorefBrackets.class, CorefBrackets.PARAM_MERGE_REFERENTS, true);
jCas.setDocumentText("James (Jimmy) visited Thomas and Ben");
Person p1 = new Person(jCas, 0, 5);
p1.addToIndexes();
Person p2 = new Person(jCas, 7, 12);
p2.addToIndexes();
Person p3 = new Person(jCas, 22, 28);
p3.addToIndexes();
Person p4 = new Person(jCas, 33, 36);
p4.addToIndexes();
ae.process(jCas);
assertNotNull(p1.getReferent());
assertEquals(p1.getReferent(), p2.getReferent());
assertNotEquals(p1.getReferent(), p3.getReferent());
assertNotEquals(p1.getReferent(), p4.getReferent());
assertNull(p3.getReferent());
assertNull(p4.getReferent());
}
示例13: testDescriptor
import org.apache.uima.fit.factory.AnalysisEngineFactory; //导入方法依赖的package包/类
@Test
public void testDescriptor() throws UIMAException {
try {
AnalysisEngineFactory.createEngine(TreebankAligningAnnotator.class);
Assert.fail("expected exception with TreebankDirectory unspecified");
} catch (ResourceInitializationException e) {
}
String treebankPath = "data/treebank/wsj";
AnalysisEngine engine = AnalysisEngineFactory.createEngine(
TreebankAligningAnnotator.class,
TreebankAligningAnnotator.PARAM_TREEBANK_DIRECTORY_NAME,
treebankPath);
Object treebankDirectory = engine.getConfigParameterValue(TreebankAligningAnnotator.PARAM_TREEBANK_DIRECTORY_NAME);
Assert.assertEquals(treebankPath, treebankDirectory);
engine.collectionProcessComplete();
}
示例14: CrfClassifier
import org.apache.uima.fit.factory.AnalysisEngineFactory; //导入方法依赖的package包/类
/**
* Constructor, creates an AnalysisEngine with a CRF classifier.
* @param modelDirectory the directory where the model is located
*/
public CrfClassifier(String modelDirectory) {
try {
classifier = AnalysisEngineFactory.createEngine(AspectAnnotator.class,
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
modelDirectory + "model.jar");
} catch (ResourceInitializationException e) {
e.printStackTrace();
}
}
示例15: beforeTest
import org.apache.uima.fit.factory.AnalysisEngineFactory; //导入方法依赖的package包/类
@Override
public void beforeTest() throws UIMAException {
super.beforeTest();
final ExternalResourceDescription tokensDesc = ExternalResourceFactory.createExternalResourceDescription(
"lexica",
ClearNlpLexica.class);
final AnalysisEngineDescription desc = AnalysisEngineFactory.createEngineDescription(ClearNlpTokeniser.class,
"lexica",
tokensDesc);
ae = AnalysisEngineFactory.createEngine(desc);
}