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


Java JCasFactory类代码示例

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


JCasFactory类属于org.apache.uima.fit.factory包,在下文中一共展示了JCasFactory类的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());
    }
 
开发者ID:tmills,项目名称:ctakes-docker,代码行数:17,代码来源:TestMistAnalysisEngine.java

示例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);
    }
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:20,代码来源:StandaloneArgument.java

示例3: 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);
}
 
开发者ID:oaqa,项目名称:bioasq,代码行数:20,代码来源:ConceptProvider.java

示例4: 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;
}
 
开发者ID:oaqa,项目名称:bioasq,代码行数:18,代码来源:ImprovedLuceneInMemorySentenceRetrievalExecutor.java

示例5: main

import org.apache.uima.fit.factory.JCasFactory; //导入依赖的package包/类
public static void main(String[] args) throws UIMAException {
  JCas jcas = JCasFactory.createJCas();
  AtomicQueryConcept rheumatoidArthritisConcept = createAtomicQueryConcept(jcas, "Title",
          KEYWORD_TYPE, "Rheumatoid Arthritis", "Rheumatoid Arthritis");
  AtomicQueryConcept genderConcept = createAtomicQueryConcept(jcas, "Title", KEYWORD_TYPE,
          "gender", "gender");
  AtomicQueryConcept maleConcept = createAtomicQueryConcept(jcas, "Title", KEYWORD_TYPE, "male",
          "male");
  AtomicQueryConcept femaleConcept = createAtomicQueryConcept(jcas, "Title", KEYWORD_TYPE,
          "female", "female");
  ComplexQueryConcept orConcept = createComplexQueryConcept(jcas, KEYWORD_TYPE,
          createQueryOperator(jcas, TIE), genderConcept, maleConcept, femaleConcept);
  ComplexQueryConcept andConcept = createComplexQueryConcept(jcas, KEYWORD_TYPE,
          createQueryOperator(jcas, REQUIRED), rheumatoidArthritisConcept, orConcept);
  AbstractQuery aquery = createAbstractQuery(jcas, andConcept);
  BagOfPhraseQueryStringConstructor bopQueryStringConstructor = new BagOfPhraseQueryStringConstructor();
  System.out.println("Bag of phrases: " + bopQueryStringConstructor.construct(aquery));
  PubMedQueryStringConstructor pubmedQueryStringConstructor = new PubMedQueryStringConstructor();
  System.out.println("PubMed: " + pubmedQueryStringConstructor.construct(aquery));
}
 
开发者ID:oaqa,项目名称:bioasq,代码行数:21,代码来源:PubMedQueryStringConstructorExample.java

示例6: test

import org.apache.uima.fit.factory.JCasFactory; //导入依赖的package包/类
@Test
public void test() throws IOException, UIMAException {
	final JCas jCas = JCasFactory.createJCas();
	assertTrue(reader.doHasNext());
	reader.doGetNext(jCas);

	assertEquals("Some example\ntext.", jCas.getDocumentText());

	jCas.reset();
	assertTrue(reader.doHasNext());
	reader.doGetNext(jCas);

	assertEquals("Another example", jCas.getDocumentText());

	jCas.reset();
	assertFalse(reader.doHasNext());
}
 
开发者ID:tenode,项目名称:baleen-extras,代码行数:18,代码来源:ReuterReaderTest.java

示例7: 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");
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:17,代码来源:TestMapBackFeature.java

示例8: TestGetFullUtterances

import org.apache.uima.fit.factory.JCasFactory; //导入依赖的package包/类
@Test
public void TestGetFullUtterances() throws Exception {
	JCas jcas = JCasFactory.createJCas();
	jcas.setDocumentText("Lorem ipsum dolor sit amet, consetetur sadipscing");
	AnnotationFactory.createAnnotation(jcas, 0, 5, Utterance.class);
	AnnotationFactory.createAnnotation(jcas, 6, 7, Utterance.class);
	AnnotationFactory.createAnnotation(jcas, 8, 10, Utterance.class);

	Iterator<Utterance> iter = DramaUtil.selectFullUtterances(jcas).iterator();
	assertFalse(iter.hasNext());

	Speaker s1 = AnnotationFactory.createAnnotation(jcas, 0, 1, Speaker.class);
	Speaker s2 = AnnotationFactory.createAnnotation(jcas, 8, 9, Speaker.class);
	iter = DramaUtil.selectFullUtterances(jcas).iterator();
	assertFalse(iter.hasNext());

	s1.setFigure(AnnotationFactory.createAnnotation(jcas, 0, 0, Figure.class));
	s2.setFigure(AnnotationFactory.createAnnotation(jcas, 0, 0, Figure.class));
	iter = DramaUtil.selectFullUtterances(jcas).iterator();
	assertTrue(iter.hasNext());
	iter.next();
	assertTrue(iter.hasNext());
	iter.next();
	assertFalse(iter.hasNext());

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

示例9: 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));
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:26,代码来源:TestDramaUtil.java

示例10: setUp

import org.apache.uima.fit.factory.JCasFactory; //导入依赖的package包/类
@Before
public void setUp()
        throws Exception
{
    jCas = JCasFactory.createJCas();
    jCas.setDocumentLanguage("en");
    jCas.setDocumentText("This is a test.");

    // Add some annotations
    tokenThis = new Token(jCas, 0, 4);
    tokenThis.addToIndexes();
    tokenIs = new Token(jCas, 5, 7);
    tokenIs.addToIndexes();
    tokenA = new Token(jCas, 8, 9);
    tokenA.addToIndexes();
    tokenTest = new Token(jCas, 10, 14);
    tokenTest.addToIndexes();
    tokenDot = new Token(jCas, 14, 15);
    tokenDot.addToIndexes();
}
 
开发者ID:dkpro,项目名称:dkpro-argumentation,代码行数:21,代码来源:JCasUtil2Test.java

示例11: doInitialize

import org.apache.uima.fit.factory.JCasFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void doInitialize(UimaContext aContext) throws ResourceInitializationException {
	try {
		gazetteer = configureGazetteer();
	} catch (BaleenException be) {
		throw new ResourceInitializationException(be);
	}

	buildTrie();

	try {
		entityType = (Class<? extends Annotation>) TypeUtils.getType(type, JCasFactory.createJCas(TypeSystemSingleton.getTypeSystemDescriptionInstance()));
		if (entityType == null) {
			getMonitor().warn("Type {} not found, Entity will be used instead", type);
			entityType = Entity.class;
		}
	} catch (UIMAException e) {
		throw new ResourceInitializationException(e);
	}
}
 
开发者ID:dstl,项目名称:baleen,代码行数:22,代码来源:AbstractAhoCorasickAnnotator.java

示例12: doInitialize

import org.apache.uima.fit.factory.JCasFactory; //导入依赖的package包/类
@Override
public void doInitialize(UimaContext aContext) throws ResourceInitializationException {
	patternGroup = ConfigUtils.stringToInteger(patternGroupString, 0);
	confidence = ConfigUtils.stringToFloat(confidenceString, 1.0f);
	
	if(caseSensitive){
		p = Pattern.compile(pattern);
		getMonitor().debug("The regular expression is \"{}\"", p.pattern());
	}else{
		p = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
	}
	try{
		et = TypeUtils.getEntityClass(type, JCasFactory.createJCas(TypeSystemSingleton.getTypeSystemDescriptionInstance()));
	}catch(UIMAException | BaleenException e){
		throw new ResourceInitializationException(e);
	}
}
 
开发者ID:dstl,项目名称:baleen,代码行数:18,代码来源:Custom.java

示例13: doInitialize

import org.apache.uima.fit.factory.JCasFactory; //导入依赖的package包/类
@Override
public void doInitialize(final UimaContext aContext) throws ResourceInitializationException {
	confidence = ConfigUtils.stringToFloat(confidenceString, 1.0f);

	if (!caseSensitive) {
		pattern = "(?i)" + pattern;
	}
	p = Pattern.compile(pattern);
	getMonitor().debug("The regular expression is \"{}\"", p.pattern());
	try {
		final Class<? extends Entity> et = TypeUtils.getEntityClass(type,
				JCasFactory.createJCas(TypeSystemSingleton.getTypeSystemDescriptionInstance()));
		constructor = et.getConstructor(JCas.class);
	} catch (UIMAException | BaleenException | NoSuchMethodException | SecurityException e) {
		throw new ResourceInitializationException(e);
	}
}
 
开发者ID:dstl,项目名称:baleen,代码行数:18,代码来源:TableEntity.java

示例14: testTwoSentencesWithNoSpaceInBetween

import org.apache.uima.fit.factory.JCasFactory; //导入依赖的package包/类
@Test
public void testTwoSentencesWithNoSpaceInBetween() throws Exception
{
    TypeSystemDescription global = TypeSystemDescriptionFactory.createTypeSystemDescription();
    TypeSystemDescription local = TypeSystemDescriptionFactory
            .createTypeSystemDescriptionFromPath(
                    "src/test/resources/desc/type/webannoTestTypes.xml");
   
    TypeSystemDescription merged = CasCreationUtils.mergeTypeSystems(asList(global, local));
    
    JCas jcas = JCasFactory.createJCas(merged);
    
    DocumentMetaData.create(jcas).setDocumentId("doc");
    jcas.setDocumentText("onetwo");
    new Token(jcas, 0, 3).addToIndexes();
    new Sentence(jcas, 0, 3).addToIndexes();
    new Token(jcas, 3, 6).addToIndexes();
    new Sentence(jcas, 3, 6).addToIndexes();
    
    writeAndAssertEquals(jcas);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:22,代码来源:WebAnnoTsv3WriterTestBase.java

示例15: cases

import org.apache.uima.fit.factory.JCasFactory; //导入依赖的package包/类
@Override
public Stream<JCas> cases() {
	return pathWalker(
			getRootDirectory(), 
			getPattern(), 
			path -> {
				try {
					JCas jCas = JCasFactory.createJCas();
					CAS cas = jCas.getCas();
					if(getExtension().equals(XMICorpus.XMI_EXTENSION)) {
						XmiCasDeserializer.deserialize(new FileInputStream(path.toFile()), cas);
					} else if(getExtension().equals(XMICorpus.JSON_EXTENSION)) {
						JsonCasDeserializer.deserialize(new FileInputStream(path.toFile()), cas);
					} else
						throw new IllegalArgumentException("Expected a XMI or JSON " + XMICorpus.class.getSimpleName());
					return jCas;
				} catch (Exception e) {
					throw new TermSuiteException(e);
				}
			});	
	
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:23,代码来源:XMICorpus.java


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