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


Java JCasBuilder.close方法代码示例

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


在下文中一共展示了JCasBuilder.close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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


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