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


Java AnnotationIndex.size方法代码示例

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


在下文中一共展示了AnnotationIndex.size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getStringValue

import org.apache.uima.cas.text.AnnotationIndex; //导入方法依赖的package包/类
/**
 * @param cas
 * @param type
 * @param feature
 * @return feature value of the first annotation of given type from given
 * CAS. E.g., it is useful to get document metadata values. If there
 * is no such annotation method will return null.
 */
public static String getStringValue(CAS cas, Type type, Feature feature) {
    AnnotationIndex<AnnotationFS> metaIdx = cas.getAnnotationIndex(type);
    if (metaIdx.size() > 0) {
        AnnotationFS meta = metaIdx.iterator().next();
        return meta.getFeatureValueAsString(feature);
    } else {
        return null;
    }
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:18,代码来源:AnnotationUtils.java

示例2: getSingleAnnotation

import org.apache.uima.cas.text.AnnotationIndex; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static <A extends AnnotationFS> A getSingleAnnotation(JCas cas, Class<A> typeJCasClass) {
    Type annoType = CasUtil.getAnnotationType(cas.getCas(), typeJCasClass);
    AnnotationIndex<Annotation> annoIdx = cas.getAnnotationIndex(annoType);
    if (annoIdx.size() == 0) {
        return null;
    } else if (annoIdx.size() == 1) {
        return (A) annoIdx.iterator().next();
    } else {
        throw new IllegalStateException(String.format(
                "Too much (>1) annotations of type %s", annoType));
    }
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:14,代码来源:AnnotationUtils.java

示例3: countRelevantRetrievedAndTheCorrect

import org.apache.uima.cas.text.AnnotationIndex; //导入方法依赖的package包/类
/**
 * Count the number of correct results (intersection of relevant and retrieved)
 * @param aJCas
 * @param testAnnotationType
 * @param goldAnnotationType
 * @param featureNames
 * @throws Exception
 */
private void countRelevantRetrievedAndTheCorrect(JCas aJCas,Type testAnnotationType,Type goldAnnotationType,List<String> featureNames) throws Exception {
	
	/*
	AnnotationIndex<Annotation> anAnnotationIndex = aJCas.getAnnotationIndex();
	Iterator<Annotation> aAnnotationIterator = anAnnotationIndex.iterator(); 
	while (aAnnotationIterator.hasNext()) { 
		Annotation anAnnotation = (Annotation) aAnnotationIterator.next();
		System.out.println("Debug: " + anAnnotation.getClass().getName());

	}*/
				// Faire quelque chose

	
	// count the relevant 
	AnnotationIndex<Annotation> goldIndex = aJCas.getAnnotationIndex(goldAnnotationType);
	
	int goldIndexSize = 0;
	if (goldIndex != null) goldIndexSize = goldIndex.size();
	//if (this.getRelevantRetrievedCorrectCounterResource() == null) System.out.println("Debug: this.getRelevantRetrievedCorrectCounterResource() == null");
	//System.out.println("Debug: goldIndex.size() " + goldIndex.size());
	this.getRelevantRetrievedCorrectCounterResource().addRelevant(goldIndexSize);
	//aRelevantRetrievedCorrectCounter.addRelevant(goldIndexSize);
	
	// count the retrieved
	AnnotationIndex<Annotation> testIndex = aJCas.getAnnotationIndex(testAnnotationType);
	int testIndexSize = 0;
	if (testIndex != null) testIndexSize = testIndex.size();
	//System.out.println("Debug: testIndex.size() " + testIndex.size());
	this.getRelevantRetrievedCorrectCounterResource().addRetrieved(testIndexSize);
	//aRelevantRetrievedCorrectCounter.addRetrieved(testIndexSize);

	FSIterator<Annotation> testIter = testIndex.iterator();

	/// count the correct
	// intersection of relevant and retrieved
	// For all test annotations 
	while (testIter.hasNext()) {
		Annotation aTestAnnotation = testIter.next();
		// check its presence in the gold index
		FSIterator<Annotation> result = this.filter(aJCas,goldIndex,goldAnnotationType,featureNames,aTestAnnotation);
		/*while (result.hasNext()) {
			Annotation aResult = result.next();
			System.out.println("Debug: aResult "+aResult.getCoveredText());

		}*/
		if (result.hasNext()) {
		//if (result != null) {
			//System.out.println("Debug: test "+aTestAnnotation.getCoveredText());
			// 
			this.getRelevantRetrievedCorrectCounterResource().addCorrect();
			//aRelevantRetrievedCorrectCounter.addCorrect();

		}
	}
}
 
开发者ID:EUMSSI,项目名称:EUMSSI-tools,代码行数:64,代码来源:InformationRetrievalEvaluatorAE.java


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