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


Java TypeSystem.getFeatureByFullName方法代码示例

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


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

示例1: configure

import org.apache.uima.cas.TypeSystem; //导入方法依赖的package包/类
/**
 * Configure this ObjectBuilder by extracting the feature name and kind.  If
 * no such attributes exist, an exception is thrown.
 */
public void configure(Element elt, TypeSystem typeSystem)
                    throws MappingException {
  String featureName = elt.getAttributeValue("name");
  if(featureName == null) {
    throw new MappingException("gateAnnotFeatureValue element must have "
        + "name attribute");
  }

  feature = typeSystem.getFeatureByFullName(featureName);
  if(feature == null) {
    throw new MappingException("Feature " + featureName + " not found in "
        + "type system");
  }
  // we don't know at this stage whether the feature object is appropriate to
  // the type of FeatureStructure that will be passed in at buildObject time.

  String kindString = elt.getAttributeValue("kind");
  if(kindString == null) {
    // assume string if not otherwise specified
    kindString = "string";
  }

  kind = FeatureDefinition.getKindValue(kindString);
  // throws MappingException if not a valid kind.
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:30,代码来源:UIMAFSFeatureValueBuilder.java

示例2: getAnnotationsWithinSpan

import org.apache.uima.cas.TypeSystem; //导入方法依赖的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

示例3: getAnnotationsWithSameStart

import org.apache.uima.cas.TypeSystem; //导入方法依赖的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

示例4: getPrecedingAnnotations

import org.apache.uima.cas.TypeSystem; //导入方法依赖的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

示例5: configure

import org.apache.uima.cas.TypeSystem; //导入方法依赖的package包/类
/**
 * Configure this ObjectBuilder by extracting the GATE and UIMA types and the
 * feature definitions from the XML element.
 */
public void configure(Element elt, TypeSystem typeSystem)
      throws MappingException {
  annotationType = elt.getAttributeValue("type");
  if(annotationType == null) {
    throw new MappingException("No \"type\" attribute specified for "
        + "gateAnnotation");
  }

  String uimaTypeString = elt.getAttributeValue("uimaType");
  if(uimaTypeString == null) {
    throw new MappingException("No \"uimaType\" attribute specified for "
        + "gateAnnotation");
  }

  uimaType = typeSystem.getType(uimaTypeString);
  if(uimaType == null) {
    throw new MappingException("Type " + uimaTypeString
        + " not found in UIMA type system");
  }

  if(!typeSystem.subsumes(typeSystem.getType(CAS.TYPE_NAME_ANNOTATION),
                          uimaType)) {
    throw new MappingException("Type " + uimaTypeString
        + " is not an annotation type");
  }

  uimaAnnotationBeginFeature = typeSystem.getFeatureByFullName(
       CAS.FEATURE_FULL_NAME_BEGIN);
  if(uimaAnnotationBeginFeature == null) {
    throw new MappingException(CAS.FEATURE_FULL_NAME_BEGIN + " feature not "
        + "found in type system - are you sure CAS is a CAS?");
  }

  uimaAnnotationEndFeature = typeSystem.getFeatureByFullName(
       CAS.FEATURE_FULL_NAME_END);
  if(uimaAnnotationEndFeature == null) {
    throw new MappingException(CAS.FEATURE_FULL_NAME_END + " feature not "
        + "found in type system - are you sure CAS is a CAS?");
  }

  String indexedString = elt.getAttributeValue("indexed");
  indexed = Boolean.valueOf(indexedString).booleanValue();

  // build the list of feature definitions
  List featureElements = elt.getChildren("feature");
  featureDefs = new ArrayList(featureElements.size());

  Iterator featureElementsIt = featureElements.iterator();
  while(featureElementsIt.hasNext()) {
    Element featureElt = (Element)featureElementsIt.next();
    String featureName = featureElt.getAttributeValue("name");
    if(featureName == null) {
      throw new MappingException("feature element must have \"name\" "
          + "attribute specified");
    }

    List children = featureElt.getChildren();
    if(children.isEmpty()) {
      throw new MappingException("feature element must have a child element "
          + "specifying its value");
    }
    Element valueElement = (Element)children.get(0);

    // create the object builder that gives this feature's value
    ObjectBuilder valueBuilder = ObjectManager.createBuilder(valueElement,
                                                             typeSystem);

    featureDefs.add(new FeatureDefinition(featureName, valueBuilder));
  }
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:75,代码来源:GateAnnotationBuilder.java

示例6: initUimaGateIndex

import org.apache.uima.cas.TypeSystem; //导入方法依赖的package包/类
/**
 * Initialise the necessary variables for the GATE/UIMA index.
 */
private void initUimaGateIndex(TypeSystem typeSystem)
                  throws ResourceInstantiationException {
  annotationSourceType = typeSystem.getType(ANNOTATIONSOURCE_TYPE_NAME);
  if(annotationSourceType == null) {
    throw new ResourceInstantiationException("Could not find "
        + ANNOTATIONSOURCE_TYPE_NAME + " in type system");
  }

  annotationSource_UIMAAnnotationFeature = typeSystem.getFeatureByFullName(
      ANNOTATIONSOURCE_UIMAANNOTATION_FEATURE_NAME);
  if(annotationSource_UIMAAnnotationFeature == null) {
    throw new ResourceInstantiationException("Could not find feature "
        + ANNOTATIONSOURCE_UIMAANNOTATION_FEATURE_NAME + " in type system");
  }

  annotationSource_GATEAnnotationIDFeature = typeSystem.getFeatureByFullName(
      ANNOTATIONSOURCE_GATEANNOTATIONID_FEATURE_NAME);
  if(annotationSource_GATEAnnotationIDFeature == null) {
    throw new ResourceInstantiationException("Could not find feature "
        + ANNOTATIONSOURCE_GATEANNOTATIONID_FEATURE_NAME + " in type system");
  }

  annotationSource_GATEAnnotationTypeFeature =
    typeSystem.getFeatureByFullName(
      ANNOTATIONSOURCE_GATEANNOTATIONTYPE_FEATURE_NAME);
  if(annotationSource_GATEAnnotationTypeFeature == null) {
    throw new ResourceInstantiationException("Could not find feature "
        + ANNOTATIONSOURCE_GATEANNOTATIONTYPE_FEATURE_NAME
        + " in type system");
  }

  FSIndexRepository uimaIndexes = cas.getIndexRepository();
  gateFSIndex = uimaIndexes.getIndex(GATE_INDEX_LABEL);
  if(gateFSIndex == null) {
    throw new ResourceInstantiationException("Couldn't find GATE index "
        + "in UIMA index repository");
  }

  gateAnnotationTypePath = cas.createFeaturePath();
  gateAnnotationTypePath.addFeature(
      annotationSource_GATEAnnotationTypeFeature);
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:46,代码来源:AnalysisEnginePR.java


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