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


Java JCasBuilder类代码示例

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


JCasBuilder类属于org.apache.uima.fit.factory包,在下文中一共展示了JCasBuilder类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import org.apache.uima.fit.factory.JCasBuilder; //导入依赖的package包/类
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
	JCas newView;
	try {
		newView = jcas.createView(viewName);
	} catch (CASException e) {
		e.printStackTrace();
		throw new AnalysisEngineProcessException(e);
	}

	JCasBuilder builder = new JCasBuilder(newView);

	for (Annotation a : JCasUtil.select(jcas, annotationClass)) {
		int relativ = -a.getBegin() + builder.getPosition();
		Origin o = builder.add(a.getCoveredText(), Origin.class);
		o.setOffset(a.getBegin());

		for (Class<Annotation> subClass : subAnnotations) {
			for (Annotation sub : JCasUtil.selectCovered(subClass, a)) {
				int tgtBegin = sub.getBegin() + relativ, tgtEnd = sub.getEnd() + relativ;
				Annotation tgt = AnnotationFactory.createAnnotation(newView, sub.getBegin() + relativ,
						sub.getEnd() + relativ, subClass);

				for (Feature feature : sub.getType().getFeatures()) {
					if (feature.getRange().isPrimitive())
						tgt.setFeatureValueFromString(feature, sub.getFeatureValueAsString(feature));
				}
				tgt.setBegin(tgtBegin);
				tgt.setEnd(tgtEnd);
			}
		}
	}
	builder.close();
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:35,代码来源:PrepareClearTk.java

示例2: process

import org.apache.uima.fit.factory.JCasBuilder; //导入依赖的package包/类
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
	JCas utteranceCas = null;
	try {
		// create the new view
		utteranceCas =
				jcas.createView(D.SOFA_UTTERANCES);
		utteranceCas.setDocumentLanguage(jcas.getDocumentLanguage());
	} catch (CASException e1) {
		throw new AnalysisEngineProcessException(e1);
	}

	// fill the jcas utterance-wise
	JCasBuilder b = new JCasBuilder(utteranceCas);
	for (Utterance utterance : JCasUtil.select(jcas, Utterance.class)) {
		for (Speech speech : JCasUtil
				.selectCovered(Speech.class, utterance)) {
			b.add(speech.getCoveredText(), Origin.class).setOffset(
					speech.getBegin());
			b.add(" ");
		}
		b.add("\n\n");
	}
	b.close();

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

示例3: testIsSameSentence

import org.apache.uima.fit.factory.JCasBuilder; //导入依赖的package包/类
@Test
public void testIsSameSentence()
    throws Exception
{
    JCas jcas = JCasFactory.createJCas();
    
    JCasBuilder jb = new JCasBuilder(jcas);
    Sentence s1 = jb.add("Sentence 1.", Sentence.class);
    jb.add(" ");
    Sentence s2 = jb.add("Sentence 2.", Sentence.class);
    jb.close();

    assertTrue(isSameSentence(jcas, s2.getBegin(), s2.getEnd()));
    assertTrue(isSameSentence(jcas, s2.getEnd(), s2.getBegin()));

    assertTrue(isSameSentence(jcas, s1.getBegin() + 1, s1.getEnd() - 1));
    assertTrue(isSameSentence(jcas, s1.getEnd() - 1, s1.getBegin() + 1));
    
    assertTrue(isSameSentence(jcas, s1.getBegin(), s1.getEnd()));
    assertTrue(isSameSentence(jcas, s1.getEnd(), s1.getBegin()));

    assertFalse(isSameSentence(jcas, s2.getBegin(), s1.getBegin()));
    assertFalse(isSameSentence(jcas, s1.getBegin(), s2.getBegin()));

    assertTrue(isSameSentence(jcas, 0, 0));
}
 
开发者ID:webanno,项目名称:webanno,代码行数:27,代码来源:BratAjaxCasUtilTest.java

示例4: getCas1

import org.apache.uima.fit.factory.JCasBuilder; //导入依赖的package包/类
@SuppressWarnings("unused")
private void getCas1(JCasBuilder aBuilder, JCas aJCas)
{
    Token token1 = aBuilder.add("Hallo", Token.class);
    POS pos1 = new POS(aJCas, token1.getBegin(), token1.getEnd());
    pos1.setPosValue("I");
    pos1.addToIndexes();
    token1.setPos(pos1);
    Token token2 = aBuilder.add("Welt", Token.class);
    POS pos2 = new POS(aJCas, token2.getBegin(), token2.getEnd());
    pos2.setPosValue("N");
    pos2.addToIndexes();
    token2.setPos(pos2);
    Token token3 = aBuilder.add("!", Token.class);
    POS pos3 = new POS(aJCas, token3.getBegin(), token3.getEnd());
    pos3.setPosValue("SENT");
    token3.setPos(pos3);
    pos3.addToIndexes();
}
 
开发者ID:webanno,项目名称:webanno,代码行数:20,代码来源:TestCasDiff.java

示例5: getCas2

import org.apache.uima.fit.factory.JCasBuilder; //导入依赖的package包/类
@SuppressWarnings("unused")
private void getCas2(JCasBuilder aBuilder, JCas aJCas)
{
    Token token1 = aBuilder.add("Hallo", Token.class);
    POS pos1 = new POS(aJCas, token1.getBegin(), token1.getEnd());
    pos1.setPosValue("O");
    pos1.addToIndexes();
    token1.setPos(pos1);
    Token token2 = aBuilder.add("Welt", Token.class);
    POS pos2 = new POS(aJCas, token2.getBegin(), token2.getEnd());
    pos2.setPosValue("N");
    pos2.addToIndexes();
    token2.setPos(pos2);
    Token token3 = aBuilder.add("!", Token.class);
    POS pos3 = new POS(aJCas, token3.getBegin(), token3.getEnd());
    pos3.setPosValue("SENT");
    token3.setPos(pos3);
    pos3.addToIndexes();
}
 
开发者ID:webanno,项目名称:webanno,代码行数:20,代码来源:TestCasDiff.java

示例6: convert

import org.apache.uima.fit.factory.JCasBuilder; //导入依赖的package包/类
private void convert(JCas aJCas, CrowdsourceTextSequence crowdsourceTextSequence)
    throws IOException
{
    JCasBuilder doc = new JCasBuilder(aJCas);

    int sentenceBegin = doc.getPosition();
    int sentenceEnd = sentenceBegin;
    List<Token> tokens = new ArrayList<Token>();
        
        // Tokens, NER-IOB
    for (CrowdsourceSequenceUnit sequenceUnit: crowdsourceTextSequence.getCrowdsourceSequenceUnits()) {
        String word = sequenceUnit.getText();
        // Read token
        Token token = doc.add(word, Token.class);
        sentenceEnd = token.getEnd();
        doc.add(" ");
        
        TextClassificationUnit unit = new TextClassificationUnit(aJCas, token.getBegin(), token.getEnd());
        unit.setSuffix("unit" + sequenceUnit.getId() + "_" + sequenceUnit.getText());
        unit.addToIndexes();
        
        TextClassificationOutcome outcome = new TextClassificationOutcome(aJCas, token.getBegin(), token.getEnd());
        outcome.setOutcome(sequenceUnit.useThisLabel);
        outcome.addToIndexes();
    
        tokens.add(token);
    }

    // Sentence
    Sentence sentence = new Sentence(aJCas, sentenceBegin, sentenceEnd);
    sentence.addToIndexes();
    
    TextClassificationSequence sequence = new TextClassificationSequence(aJCas, sentenceBegin, sentenceEnd);
    sequence.addToIndexes();

    // Once sentence per line.
    doc.add("\n");

    doc.close();
}
 
开发者ID:UKPLab,项目名称:emnlp2015-crowdsourcing,代码行数:41,代码来源:PosReaderBase.java

示例7: Visitor

import org.apache.uima.fit.factory.JCasBuilder; //导入依赖的package包/类
public Visitor(JCas jcas) {
	builder = new JCasBuilder(jcas);
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:4,代码来源:Visitor.java


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