本文整理匯總了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;
}
示例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;
}
示例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;
}