當前位置: 首頁>>代碼示例>>Java>>正文


Java CAS.createFeaturePath方法代碼示例

本文整理匯總了Java中org.apache.uima.cas.CAS.createFeaturePath方法的典型用法代碼示例。如果您正苦於以下問題:Java CAS.createFeaturePath方法的具體用法?Java CAS.createFeaturePath怎麽用?Java CAS.createFeaturePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.uima.cas.CAS的用法示例。


在下文中一共展示了CAS.createFeaturePath方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAnnotationsWithinSpan

import org.apache.uima.cas.CAS; //導入方法依賴的package包/類
/**
 * return all annotations within the exact same span as the input span
 * 
 * @param span
 * @param jcas
 * @return
 */
public static Iterator<Annotation> getAnnotationsWithinSpan(Span span, JCas jcas, int annotationType) {

	// System.out.println("Looking for annotations within " + span.getSpanStart() + " -- " +
	// span.getSpanEnd());
	/* Get a reference to the CAS and the CAS ConstraintFactory */
	CAS cas = jcas.getCas();
	ConstraintFactory cf = cas.getConstraintFactory();

	/* Constraints are built from tests and feature-paths */
	/* First build the tests */
	FSIntConstraint gtEqToSpanStart = cf.createIntConstraint();
	gtEqToSpanStart.geq(span.getSpanStart());

	FSIntConstraint ltEqToSpanEnd = cf.createIntConstraint();
	ltEqToSpanEnd.leq(span.getSpanEnd());

	/* Get handles to the features, use the type system */
	TypeSystem ts = cas.getTypeSystem();

	Feature beginFeature = ts.getFeatureByFullName(CAS.FEATURE_FULL_NAME_BEGIN);
	Feature endFeature = ts.getFeatureByFullName(CAS.FEATURE_FULL_NAME_END);

	/* Create a feature path for each feature */
	FeaturePath pathToBeginValue = cas.createFeaturePath();
	pathToBeginValue.addFeature(beginFeature);
	FeaturePath pathToEndValue = cas.createFeaturePath();
	pathToEndValue.addFeature(endFeature);

	/*
	 * Connect the tests to the feature paths (s = the span of the trigger annotation, c = the
	 * span of the phrases and tokens to compare)
	 */

	/**
	 * is it within the span
	 * 
	 * <pre>
	 *                           ccccc
	 *                          ssssssss
	 * </pre>
	 */
	FSMatchConstraint testBegin = cf.embedConstraint(pathToBeginValue, gtEqToSpanStart);
	FSMatchConstraint testEnd = cf.embedConstraint(pathToEndValue, ltEqToSpanEnd);

	/* AND the tests for each of the three cases, then OR the AND'ed tests together */
	FSMatchConstraint testBoth = cf.and(testBegin, testEnd);

	/* Create a filtered iterator that uses this constraint */
	Iterator<Annotation> iter = (Iterator<Annotation>) cas.createFilteredIterator(jcas.getJFSIndexRepository()
			.getAnnotationIndex(annotationType).iterator(), testBoth);

	return iter;

}
 
開發者ID:UCDenver-ccp,項目名稱:ccp-nlp,代碼行數:62,代碼來源:UIMA_Util.java

示例2: getAnnotationsWithSameStart

import org.apache.uima.cas.CAS; //導入方法依賴的package包/類
/**
 * return all annotations that start with the input startIndex
 * 
 * @param startIndex
 * @param jcas
 * @return
 */
public static Iterator<Annotation> getAnnotationsWithSameStart(int startIndex, JCas jcas) {

	// System.out.println("Looking for annotations starting at " + startIndex);

	/* Get a reference to the CAS and the CAS ConstraintFactory */
	CAS cas = jcas.getCas();
	ConstraintFactory cf = cas.getConstraintFactory();

	/* Constraints are built from tests and feature-paths */
	/* First build the tests */
	FSIntConstraint eqToSpanStart = cf.createIntConstraint();
	eqToSpanStart.eq(startIndex);

	/* Get handles to the features, use the type system */
	TypeSystem ts = cas.getTypeSystem();

	Feature beginFeature = ts.getFeatureByFullName(CAS.FEATURE_FULL_NAME_BEGIN);

	/* Create a feature path for each feature */
	FeaturePath pathToBeginValue = cas.createFeaturePath();
	pathToBeginValue.addFeature(beginFeature);

	/*
	 * Connect the tests to the feature paths (s = the span of the trigger annotation, c = the
	 * span of the phrases and tokens to compare)
	 */

	/**
	 * does it start at the same index
	 * 
	 * <pre>
	 *                      cccccccc
	 *                      ssssssss
	 * </pre>
	 */
	FSMatchConstraint testStart = cf.embedConstraint(pathToBeginValue, eqToSpanStart);

	/* Create a filtered iterator that uses this constraint */
	Iterator<Annotation> iter = (Iterator<Annotation>) cas.createFilteredIterator(jcas.getJFSIndexRepository()
			.getAnnotationIndex(CCPTextAnnotation.type).iterator(), testStart);

	return iter;

}
 
開發者ID:UCDenver-ccp,項目名稱:ccp-nlp,代碼行數:52,代碼來源:UIMA_Util.java

示例3: getPrecedingAnnotations

import org.apache.uima.cas.CAS; //導入方法依賴的package包/類
public static Iterator<Annotation> getPrecedingAnnotations(int startIndex, int ccpAnnotationType, JCas jcas) {

		// System.out.println("Looking for annotations ending before  " + startIndex);

		/* Get a reference to the CAS and the CAS ConstraintFactory */
		CAS cas = jcas.getCas();
		ConstraintFactory cf = cas.getConstraintFactory();

		/* Constraints are built from tests and feature-paths */
		/* First build the tests */
		FSIntConstraint ltSpanStart = cf.createIntConstraint();
		ltSpanStart.lt(startIndex);

		/* Get handles to the features, use the type system */
		TypeSystem ts = cas.getTypeSystem();

		Feature endFeature = ts.getFeatureByFullName(CAS.FEATURE_FULL_NAME_END);

		/* Create a feature path for each feature */
		FeaturePath pathToEndValue = cas.createFeaturePath();
		pathToEndValue.addFeature(endFeature);

		/*
		 * Connect the tests to the feature paths (s = the span of the trigger annotation, c = the
		 * span of the phrases and tokens to compare)
		 */

		/**
		 * does it start at the same index
		 * 
		 * <pre>
		 *                      cccccccc
		 *                      ssssssss
		 * </pre>
		 */
		FSMatchConstraint testStart = cf.embedConstraint(pathToEndValue, ltSpanStart);

		/* Create a filtered iterator that uses this constraint */
		Iterator<Annotation> iter = (Iterator<Annotation>) cas.createFilteredIterator(jcas.getJFSIndexRepository()
				.getAnnotationIndex(ccpAnnotationType).iterator(), testStart);

		return iter;

	}
 
開發者ID:UCDenver-ccp,項目名稱:ccp-nlp,代碼行數:45,代碼來源:UIMA_Util.java


注:本文中的org.apache.uima.cas.CAS.createFeaturePath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。