本文整理汇总了Java中org.apache.uima.fit.factory.JCasFactory.createJCas方法的典型用法代码示例。如果您正苦于以下问题:Java JCasFactory.createJCas方法的具体用法?Java JCasFactory.createJCas怎么用?Java JCasFactory.createJCas使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.uima.fit.factory.JCasFactory
的用法示例。
在下文中一共展示了JCasFactory.createJCas方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.apache.uima.fit.factory.JCasFactory; //导入方法依赖的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());
}
示例2: getJCas
import org.apache.uima.fit.factory.JCasFactory; //导入方法依赖的package包/类
public JCas getJCas()
throws RuntimeException
{
if (base64JCas == null) {
return null;
}
try {
byte[] bytes = new BASE64Decoder()
.decodeBuffer(new ByteArrayInputStream(base64JCas.getBytes("utf-8")));
JCas jCas = JCasFactory.createJCas();
XmiCasDeserializer.deserialize(new ByteArrayInputStream(bytes), jCas.getCas());
return jCas;
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
示例3: testGetDisplayId
import org.apache.uima.fit.factory.JCasFactory; //导入方法依赖的package包/类
@Test
public void testGetDisplayId() throws Exception {
JCas jcas = JCasFactory.createJCas();
jcas.setDocumentText("Lorem ipsum dolor sit amet, consetetur sadipscing");
Drama drama;
drama = new Drama(jcas);
drama.addToIndexes();
drama.setDocumentTitle("The dog barks");
drama.setDocumentId("test");
DramaUtil.createFeatureStructure(jcas, Author.class).setName("No author");
assertEquals("Na_Tdb_test", DramaUtil.getDisplayId(jcas));
drama.setDocumentTitle("The dog barks2");
assertEquals("Na_Tdb_test", DramaUtil.getDisplayId(jcas));
drama.setDocumentTitle("Romeo und Julia");
assertEquals("Na_RuJ_test", DramaUtil.getDisplayId(jcas));
drama.setDocumentTitle("");
assertEquals("test", DramaUtil.getDisplayId(jcas));
drama.setDocumentTitle(null);
assertEquals("test", DramaUtil.getDisplayId(jcas));
}
示例4: getConcepts
import org.apache.uima.fit.factory.JCasFactory; //导入方法依赖的package包/类
default List<Concept> getConcepts(List<String> texts, String viewNamePrefix)
throws AnalysisEngineProcessException {
JCas jcas;
try {
jcas = JCasFactory.createJCas();
} catch (UIMAException e) {
throw new AnalysisEngineProcessException(e);
}
List<JCas> views = texts.stream().map(text -> {
String uuid = UUID.randomUUID().toString();
JCas view = ViewType.createView(jcas, viewNamePrefix, uuid, text);
InputElement ie = new InputElement(view, 0, text.length());
ie.setDataset("N/A");
ie.setQuuid(UUID.randomUUID().toString());
ie.addToIndexes();
return view;
} ).collect(Collectors.toList());
return getConcepts(views);
}
示例5: sentenceAnalysis
import org.apache.uima.fit.factory.JCasFactory; //导入方法依赖的package包/类
private HashMap<String, String> sentenceAnalysis(String sentence) {
HashMap<String, String> dependency = new HashMap<String, String>();
try {
JCas snippetJcas = JCasFactory.createJCas();
snippetJcas.setDocumentText(sentence);
List<Token> tokens = parserProvider.parseDependency(snippetJcas);
for (Token tok : tokens) {
if (tok.getHead() == null)
continue;
dependency.put(tok.getLemmaForm(), tok.getHead().getLemmaForm());
}
snippetJcas.release();
} catch (UIMAException err) {
err.printStackTrace();
}
return dependency;
}
示例6: setUp
import org.apache.uima.fit.factory.JCasFactory; //导入方法依赖的package包/类
@Before
public void setUp() throws UIMAException {
jcas = JCasFactory.createJCas();
DocumentMetaData.create(jcas).setDocumentId("test");
jcas.setDocumentText(
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut");
AnnotationFactory.createAnnotation(jcas, 0, 5, POS.class);
AnnotationFactory.createAnnotation(jcas, 6, 11, POS.class);
AnnotationFactory.createAnnotation(jcas, 12, 17, POS.class);
view = jcas.createView(viewName);
view.setDocumentText("dolor sit amet\n\nsadipscing");
AnnotationFactory.createAnnotation(view, 0, 14, Origin.class).setOffset(12);
AnnotationFactory.createAnnotation(view, 17, 26, Origin.class).setOffset(39);
AnnotationFactory.createAnnotation(view, 0, 5, POS.class).setPosValue("1");
}
示例7: testNeedsSynonym
import org.apache.uima.fit.factory.JCasFactory; //导入方法依赖的package包/类
@Test
public void testNeedsSynonym() throws Exception {
for (String layer : new String[] { "layer5", "bla", "L4", "LayerI2",
"LayerI V" }) {
System.out.println("\nTESTING[" + layer + "]");
JCas jCas = JCasFactory.createJCas();
jCas.setDocumentText(layer);
String script = "" + "PACKAGE org.apache.uima.ruta.type.tag;\n" //
+ "RETAINTYPE(SPACE);DECLARE Neurotransmitter(STRING ontologyId);\n"
+ "ONTO(\"hbp_layer_ontology2.robo\", Neurotransmitter, \"ontologyId\");";
Ruta.apply(jCas.getCas(), script, parameters);
Collection<TOP> nt = select(jCas, "Neurotransmitter");
assertEquals("for " + layer, 1, nt.size());
Annotation next = (Annotation) nt.iterator().next();
assertEquals(layer, next.getCoveredText());
}
}
示例8: extractDesignDecisionsAsList
import org.apache.uima.fit.factory.JCasFactory; //导入方法依赖的package包/类
/**
* Extracts design decisions from a DXMI file.
*
* @param dxmiFile the dxmi filename from where the design decisions will be extracted
* @return the design decisions list extracted from the dxmiFile
*/
public static List<Entity> extractDesignDecisionsAsList(String dxmiFile) {
List<Entity> ret = new ArrayList<Entity>();
JCas jCas;
try {
File tempFile = File.createTempFile("annotations", ".xmi");
FileUtils.copyFile(new File(dxmiFile), tempFile);
jCas = JCasFactory.createJCas(tempFile.getAbsolutePath(),CARCHA_TYPE_SYSTEM);
tempFile.delete();
} catch (Exception e) {
logger.error("There was an error with the DXMI file", e);
return null;
}
for (DesignDecision dd : JCasUtil.select(jCas, DesignDecision.class)) {
Entity entity = new Entity(dd.getCoveredText(), dd.getTypex(), NodeType.DD);
ret.add(entity);
}
return ret;
}
示例9: testObo
import org.apache.uima.fit.factory.JCasFactory; //导入方法依赖的package包/类
@Test
public void testObo() throws Exception {
for (String extension : new String[] { "obo", "robo" }) {
JCas jCas = JCasFactory.createJCas();
jCas.setDocumentText("A serotoninergic and glutamate neuron");
String script = "" + "PACKAGE org.apache.uima.ruta.type.tag;\n" //
+ "RETAINTYPE(SPACE);\n" //
+ "DECLARE Neurotransmitter(STRING ontologyId);\n"
+ "ONTO(\"hbp_neurotransmitter_ontology." + extension
+ "\", Neurotransmitter, \"ontologyId\");";
Ruta.apply(jCas.getCas(), script, parameters);
Collection<TOP> nt = select(jCas, "Neurotransmitter");
assertEquals(2, nt.size());
// for (TOP n : nt) { System.out.println(n); }
TOP serotonine = nt.iterator().next();
assertEquals("HBP_NEUROTRANSMITTER:0000001",
serotonine.getFeatureValueAsString(serotonine.getType()
.getFeatureByBaseName("ontologyId")));
}
}
示例10: simpleCopyToDiffExistingAnnoWithNoStackingTest
import org.apache.uima.fit.factory.JCasFactory; //导入方法依赖的package包/类
@Test
public void simpleCopyToDiffExistingAnnoWithNoStackingTest()
throws Exception
{
JCas jcas = JCasFactory.createJCas();
Type type = jcas.getTypeSystem().getType(POS.class.getTypeName());
AnnotationFS clickedFs = createPOSAnno(jcas, type, "NN", 0, 0);
JCas mergeCAs = JCasFactory.createJCas();
AnnotationFS existingFs = mergeCAs.getCas().createAnnotation(type, 0, 0);
Feature posValue = type.getFeatureByBaseName("PosValue");
existingFs.setStringValue(posValue, "NE");
mergeCAs.addFsToIndexes(existingFs);
MergeCas.addSpanAnnotation(new AnnotatorStateImpl(Mode.CURATION), annotationSchemaService,
posLayer, mergeCAs, clickedFs, false);
assertEquals(1, CasUtil.selectCovered(mergeCAs.getCas(), type, 0, 0).size());
}
示例11: main
import org.apache.uima.fit.factory.JCasFactory; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
JCas jcas = JCasFactory.createJCas();
jcas.setDocumentText("The quick brown fox jumps over a lazy dog.");
jcas.setDocumentLanguage("en");
AnalysisEngine pipeline = createEngine(createEngineDescription(
createEngineDescription(OpenNlpSegmenter.class),
createEngineDescription(OpenNlpPosTagger.class)));
pipeline.process(jcas);
for (Token token : select(jcas, Token.class)) {
System.out.printf("%s\t%s%n", token.getCoveredText(), token.getPos().getPosValue());
}
}
示例12: initializeJCas
import org.apache.uima.fit.factory.JCasFactory; //导入方法依赖的package包/类
private static JCas initializeJCas(StandaloneArgument argument)
throws UIMAException
{
JCas jCas = JCasFactory.createJCas();
jCas.setDocumentLanguage("en");
jCas.setDocumentText(argument.getText());
DocumentMetaData documentMetaData = DocumentMetaData.create(jCas);
documentMetaData.setDocumentId(argument.getId());
documentMetaData.setDocumentTitle(argument.getDebateMetaData().getTitle());
documentMetaData.addToIndexes();
return jCas;
}
示例13: setUp
import org.apache.uima.fit.factory.JCasFactory; //导入方法依赖的package包/类
@Before
public void setUp()
throws Exception
{
jCas = JCasFactory.createJCas();
jCas.setDocumentText("s0t0 s0t2 s1t0 s2t0 s2t0 s3t0");
jCas.setDocumentLanguage("en");
Sentence s0 = new Sentence(jCas, 0, 9);
s0.addToIndexes();
Sentence s1 = new Sentence(jCas, 10, 14);
s1.addToIndexes();
Sentence s2 = new Sentence(jCas, 15, 24);
s2.addToIndexes();
Sentence s3 = new Sentence(jCas, 25, 29);
s3.addToIndexes();
Premise p1 = new Premise(jCas, 0, 14);
p1.addToIndexes();
Premise p2 = new Premise(jCas, 25, 29);
p2.addToIndexes();
System.out.println("'" + s0.getCoveredText() + "'");
System.out.println("'" + s1.getCoveredText() + "'");
System.out.println("'" + s2.getCoveredText() + "'");
System.out.println("'" + s3.getCoveredText() + "'");
System.out.println("p1: '" + p1.getCoveredText() + "'");
System.out.println("p2: '" + p2.getCoveredText() + "'");
}
示例14: search
import org.apache.uima.fit.factory.JCasFactory; //导入方法依赖的package包/类
default Optional<Concept> search(String string) throws AnalysisEngineProcessException {
JCas jcas;
try {
jcas = JCasFactory.createJCas();
} catch (UIMAException e) {
throw new AnalysisEngineProcessException(e);
}
return search(jcas, string);
}
示例15: setUp
import org.apache.uima.fit.factory.JCasFactory; //导入方法依赖的package包/类
@Before
public void setUp() throws UIMAException, SAXException, IOException {
TypeSystemDescription tsd = TypeSystemDescriptionFactory.createTypeSystemDescription();
jcas = JCasFactory.createJCas(tsd);
XmiCasDeserializer.deserialize(getClass().getResourceAsStream("/rfxf.0.xmi"), jcas.getCas(), true);
jcas.setDocumentLanguage("de");
desc = D.getWrappedSegmenterDescription(LanguageToolSegmenter.class);
}