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


Java CAS.getTypeSystem方法代碼示例

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


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

示例1: CASDocument

import org.apache.uima.cas.CAS; //導入方法依賴的package包/類
CASDocument(@Nullable LabelAdapters labelAdapters, CAS cas) {
  this.labelAdapters = labelAdapters;
  this.cas = cas;

  TypeSystem typeSystem = cas.getTypeSystem();
  metadataType = typeSystem
      .getType("edu.umn.biomedicus.uima.type1_5.DocumentMetadata");
  keyFeature = metadataType.getFeatureByBaseName("key");
  valueFeature = metadataType.getFeatureByBaseName("value");

  metadata = cas.getView("metadata");
  Type idType = typeSystem
      .getType("edu.umn.biomedicus.uima.type1_5.DocumentId");
  Feature idFeat = idType.getFeatureByBaseName("documentId");
  documentId = metadata.getIndexRepository()
      .getAllIndexedFS(idType)
      .get()
      .getStringValue(idFeat);
}
 
開發者ID:nlpie,項目名稱:biomedicus,代碼行數:20,代碼來源:CASDocument.java

示例2: process

import org.apache.uima.cas.CAS; //導入方法依賴的package包/類
@Override
public void process(CAS aCAS) throws AnalysisEngineProcessException {
  LOGGER.debug("Segmenting rtf text.");
  CAS systemView = aCAS.getView("SystemView");
  TextSegmentsBuilder textSegmentsBuilder = new TextSegmentsBuilder(systemView);

  TypeSystem typeSystem = systemView.getTypeSystem();

  textSegmentsBuilder.addAnnotations(typeSystem
      .getType("edu.umn.biomedicus.type.ParagraphAnnotation"));
  textSegmentsBuilder.addAnnotations(typeSystem
      .getType("edu.umn.biomedicus.type.RowAnnotation"));
  textSegmentsBuilder.addAnnotations(typeSystem
      .getType("edu.umn.biomedicus.type.CellAnnotation"));
  textSegmentsBuilder.addAnnotations(typeSystem
      .getType("edu.umn.biomedicus.type.NestedRowAnnotation"));
  textSegmentsBuilder.addAnnotations(typeSystem
      .getType("edu.umn.biomedicus.type.NestedCellAnnotation"));

  textSegmentsBuilder.buildInView();
}
 
開發者ID:nlpie,項目名稱:biomedicus,代碼行數:22,代碼來源:TextSegmenter.java

示例3: getAnnotation

import org.apache.uima.cas.CAS; //導入方法依賴的package包/類
@Nullable
AnnotationFS getAnnotation(CAS cas, int begin, int end, int value) {
  if (begin < 0) {
    throw new IllegalArgumentException("Begin: " + begin + "before 0.");
  }

  if (end < begin) {
    throw new IllegalArgumentException(
        annotationClassName + " - illegal annotation span at begin: " + begin
            + " end: " + end);
  }

  if (!zeroLengthEmitted && end == begin) {
    return null;
  }

  TypeSystem typeSystem = cas.getTypeSystem();
  Type type = typeSystem.getType(annotationClassName);
  AnnotationFS annotation = cas.createAnnotation(type, begin, end);
  if (valueIncluded) {
    Feature valueFeature = type.getFeatureByBaseName("value");
    annotation.setIntValue(valueFeature, value);
  }
  return annotation;
}
 
開發者ID:nlpie,項目名稱:biomedicus,代碼行數:26,代碼來源:PropertyCasMapping.java

示例4: CasOutputDestination

import org.apache.uima.cas.CAS; //導入方法依賴的package包/類
/**
 * Default constructor, initializes all fields.
 *
 * @param destinationView The view to write to.
 * @param casMappings The property cas mappings
 * @param annotationTypeForControlWord The annotation type to create for control words.
 */
CasOutputDestination(CAS destinationView,
    List<PropertyCasMapping> casMappings,
    Map<String, Type> annotationTypeForControlWord,
    String name) {
  this.destinationView = destinationView;
  this.sofaBuilder = new StringBuilder();
  this.completedAnnotations = new ArrayList<>();
  this.annotationPropertyWatchers = casMappings.stream()
      .map(AnnotationPropertyWatcher::new)
      .collect(Collectors.toList());
  this.annotationTypeForControlWord = annotationTypeForControlWord;
  this.name = name;
  TypeSystem typeSystem = destinationView.getTypeSystem();
  illegalCharType = typeSystem
      .getType("edu.umn.biomedicus.type.IllegalXmlCharacter");
  valueFeat = illegalCharType.getFeatureByBaseName("value");
}
 
開發者ID:nlpie,項目名稱:biomedicus,代碼行數:25,代碼來源:CasOutputDestination.java

示例5: buildRequest

import org.apache.uima.cas.CAS; //導入方法依賴的package包/類
@Override
public IndexRequestBuilder buildRequest(String primaryIndex, SofaData sofaData, FeatureStructure featureStructure) throws IOException, NlpTabException, InterruptedException {
    Type type = featureStructure.getType();
    if (type == null) {
        throw new IllegalStateException();
    }

    CAS cas = featureStructure.getCAS();
    TypeSystem typeSystem = cas.getTypeSystem();
    if (typeSystem == null) {
        throw new IllegalStateException();
    }
    XContentBuilder builder = XContentFactory.jsonBuilder()
            .startObject()
            .field("system", primaryIndex)
            .field("casIdentifier", sofaData.getCasIdentifierString())
            .field("casViewIdentifier", sofaData.getCasViewIdentifierString())
            .field("documentIdentifier", sofaData.getDocumentIdentifierString())
            .field("primaryType", type.getName());

    builder.startArray("types");
    Type parentType = type;
    while (parentType != null) {
        builder.value(parentType.getName());
        parentType = typeSystem.getParent(parentType);
    }
    builder.endArray();

    if (primitiveValue != null) {
        builder.field("items", primitiveValue.getValueOrNull());
    }

    if (listItems != null) {
        builder.array("listItems", listItems.toArray());
    }

    if (arrayItems != null) {
        builder.array("arrayItems", arrayItems.toArray());
    }

    if (primitiveFeatureInstances != null) {
        Set<String> primitiveFeatureInstanceIds = primitiveFeatureInstances.keySet();
        for (String valueTypeKey : primitiveFeatureInstanceIds) {
            builder.startObject(valueTypeKey + "Features");
            Collection<PrimitiveFeatureInstance> valuePrimitiveFeatures = primitiveFeatureInstances.get(valueTypeKey);
            if (valuePrimitiveFeatures != null) {
                for (PrimitiveFeatureInstance primitiveFeatureInstance : valuePrimitiveFeatures) {
                    String name = primitiveFeatureInstance.getLuceneSafeFeatureName();
                    Object valueOrNull = primitiveFeatureInstance.getValueOfFeature().getValueOrNull();
                    builder.field(name, valueOrNull);
                }
            }
            builder.endObject();
        }
    }

    if (referenceFeatureInstances != null) {
        builder.startObject("references");
        for (ReferenceFeatureInstance referenceFeatureInstance : referenceFeatureInstances) {
            String featureName = referenceFeatureInstance.getLuceneSafeFeatureName();
            String referenceId = referenceFeatureInstance.getReferenceId();
            builder.field(featureName, referenceId);
        }
        builder.endObject();
    }

    return client.prepareIndex(primaryIndex, "FeatureStructure")
            .setId(sofaData.getIdentifierForFs(featureStructure))
            .setSource(builder.endObject());
}
 
開發者ID:nlpie,項目名稱:nlptab,代碼行數:71,代碼來源:SystemIndexFSProcessorDelegate.java

示例6: 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

示例7: 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

示例8: 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.getTypeSystem方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。