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


Java FeatureStructure類代碼示例

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


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

示例1: defaultFeatureMapper

import org.apache.uima.cas.FeatureStructure; //導入依賴的package包/類
/**
 * {@code FeatureCopier} used for features which are references to {@code FeatureStructure}s.
 *
 * @param fromFeature the {@link Feature}
 * @param fromFs the {@link FeatureStructure} to copy from
 * @param toFs the {@link FeatureStructure} to copy to
 */
private void defaultFeatureMapper(Feature fromFeature, FeatureStructure fromFs,
    FeatureStructure toFs) {
  TypeSystem typeSystem = fromFs.getCAS().getTypeSystem();
  if (typeSystem.subsumes(typeSystem.getType(CAS.TYPE_NAME_STRING), fromFeature.getRange())) {
    STRING_COPIER.copy(fromFeature, fromFs, toFs);
  } else {
    FeatureStructure fromFeatureValue = fromFs.getFeatureValue(fromFeature);
    if (fromFeatureValue != null) {
      FeatureStructure toFeatureValue = fsEncounteredCallback.apply(fromFeatureValue);
      Feature toFeature = toFs.getType().getFeatureByBaseName(fromFeature.getShortName());
      toFs.setFeatureValue(toFeature, toFeatureValue);
    }
  }
}
 
開發者ID:nlpie,項目名稱:biomedicus,代碼行數:22,代碼來源:FeatureCopiers.java

示例2: getValueOfFS

import org.apache.uima.cas.FeatureStructure; //導入依賴的package包/類
@Override
public UimaPrimitive getValueOfFS(TypeSystem typeSystem, FeatureStructure targetFS) throws NlpTabException {
    Collection<Object> values = new LinkedList<>();

    FeatureStructure pointer = targetFS;

    while (pointer.getType().getName().equals(nonEmptyName)) {
        Object value;
        try {
            value = headMethod.invoke(pointer, headFeature);
        } catch (IllegalAccessException | InvocationTargetException e) {
            throw new NlpTabException(e);
        }

        values.add(value);

        pointer = pointer.getFeatureValue(tailFeature);
    }

    Type type = targetFS.getType();
    String typeShortName = type.getShortName();

    return new UimaPrimitive(values, typeShortName);
}
 
開發者ID:nlpie,項目名稱:nlptab,代碼行數:25,代碼來源:PrimitiveListValueAdapter.java

示例3: CasViewProcessor

import org.apache.uima.cas.FeatureStructure; //導入依賴的package包/類
@Inject
CasViewProcessor(Client client,
                 FeatureStructureProcessorFactory featureStructureProcessorFactory,
                 @Assisted CasProcessorSettings casProcessorSettings,
                 @Assisted SofaData sofaData) throws InterruptedException {
    this.client = client;
    this.featureStructureProcessorFactory = featureStructureProcessorFactory;

    this.casProcessorSettings = casProcessorSettings;
    typeSystemInfo = casProcessorSettings.getTypeSystemInfo();
    casProcessingDelegate = casProcessorSettings.getCasProcessingDelegate();


    this.sofaData = sofaData;
    this.fsRefQueue = sofaData.getFsRefQueue();

    CAS cas = sofaData.getCas();

    lowLevelCAS = cas.getLowLevelCAS();
    Type topType = cas.getTypeSystem().getTopType();
    FSIterator<FeatureStructure> allIndexedFS = cas.getIndexRepository().getAllIndexedFS(topType);
    while (allIndexedFS.hasNext()) {
        sofaData.getIdentifierForFs(allIndexedFS.next());
    }
}
 
開發者ID:nlpie,項目名稱:nlptab,代碼行數:26,代碼來源:CasViewProcessor.java

示例4: getSlotMentionByName

import org.apache.uima.cas.FeatureStructure; //導入依賴的package包/類
public static CCPSlotMention getSlotMentionByName(CCPClassMention ccpClassMention, String slotMentionName) {
	FSArray slotMentionsArray = ccpClassMention.getSlotMentions();
	if (slotMentionsArray != null) {
		CCPSlotMention returnSlotMention = null;
		for (int i = 0; i < slotMentionsArray.size(); i++) {
			FeatureStructure fs = slotMentionsArray.get(i);
			if (fs instanceof CCPSlotMention) {
				CCPSlotMention ccpSlotMention = (CCPSlotMention) fs;
				if (ccpSlotMention.getMentionName().equals(slotMentionName)) {
					returnSlotMention = ccpSlotMention;
					break;
				}
			} else {
				logger.error("Expecting CCPSlotMention but got a : " + fs.getClass().getName());
			}
		}
		return returnSlotMention;
	} else {
		return null;
	}
}
 
開發者ID:UCDenver-ccp,項目名稱:ccp-nlp,代碼行數:22,代碼來源:UIMA_Util.java

示例5: getPrimitiveSlotMentionByName

import org.apache.uima.cas.FeatureStructure; //導入依賴的package包/類
public static CCPPrimitiveSlotMention getPrimitiveSlotMentionByName(CCPClassMention ccpClassMention,
		String slotMentionName) {
	FSArray slotMentionsArray = ccpClassMention.getSlotMentions();
	if (slotMentionsArray != null) {
		CCPPrimitiveSlotMention returnSlotMention = null;
		for (int i = 0; i < slotMentionsArray.size(); i++) {
			FeatureStructure fs = slotMentionsArray.get(i);
			if (fs instanceof CCPPrimitiveSlotMention) {
				CCPPrimitiveSlotMention ccpSlotMention = (CCPPrimitiveSlotMention) fs;
				if (ccpSlotMention.getMentionName().equals(slotMentionName)) {
					returnSlotMention = ccpSlotMention;
					break;
				}
			}
		}
		return returnSlotMention;
	} else {
		return null;
	}
}
 
開發者ID:UCDenver-ccp,項目名稱:ccp-nlp,代碼行數:21,代碼來源:UIMA_Util.java

示例6: getComplexSlotMentionByName

import org.apache.uima.cas.FeatureStructure; //導入依賴的package包/類
public static CCPComplexSlotMention getComplexSlotMentionByName(CCPClassMention ccpClassMention,
		String slotMentionName) {

	FSArray slotMentionsArray = ccpClassMention.getSlotMentions();
	if (slotMentionsArray != null) {
		CCPComplexSlotMention returnSlotMention = null;
		for (int i = 0; i < slotMentionsArray.size(); i++) {
			FeatureStructure fs = slotMentionsArray.get(i);
			if (fs instanceof CCPComplexSlotMention) {
				CCPComplexSlotMention ccpSlotMention = (CCPComplexSlotMention) fs;
				if (ccpSlotMention.getMentionName().equals(slotMentionName)) {
					returnSlotMention = ccpSlotMention;
					break;
				}
			}
		}
		return returnSlotMention;
	} else {
		return null;
	}
}
 
開發者ID:UCDenver-ccp,項目名稱:ccp-nlp,代碼行數:22,代碼來源:UIMA_Util.java

示例7: getMultipleSlotMentionsByName

import org.apache.uima.cas.FeatureStructure; //導入依賴的package包/類
public static List<CCPSlotMention> getMultipleSlotMentionsByName(CCPClassMention ccpClassMention,
		String slotMentionName) {
	List<CCPSlotMention> returnSlotMentions = new ArrayList<CCPSlotMention>();
	FSArray slotMentionsArray = ccpClassMention.getSlotMentions();
	if (slotMentionsArray != null) {
		FeatureStructure[] slotMentions = slotMentionsArray.toArray();
		for (FeatureStructure fs : slotMentions) {
			CCPSlotMention ccpSlotMention = (CCPSlotMention) fs;
			if (ccpSlotMention.getMentionName().equals(slotMentionName)) {
				returnSlotMentions.add(ccpSlotMention);
			}
		}
		return returnSlotMentions;
	} else {
		return null;
	}
}
 
開發者ID:UCDenver-ccp,項目名稱:ccp-nlp,代碼行數:18,代碼來源:UIMA_Util.java

示例8: getAnnotationProperties

import org.apache.uima.cas.FeatureStructure; //導入依賴的package包/類
/**
 * 
 * Returns a Collection of a specific annotation property type
 * 
 * 
 * 
 * @param <T>
 * 
 * @param ccpTA
 * 
 * @param annotationPropertyClass
 * 
 * @param jcas
 * 
 * @return
 */
//public static <T extends AnnotationProperty> Collection<T> getAnnotationProperties(
public static <T extends AnnotationMetadataProperty> Collection<T> getAnnotationProperties(
		CCPTextAnnotation ccpTA, Class<T> annotationPropertyClass, JCas jcas) {
	// int returnType = getFeatureStructureType(annotationPropertyClass);
	Collection<T> annotationPropertiesToReturn = new ArrayList<T>();
	AnnotationMetadata metaData = getAnnotationMetadata(ccpTA, jcas);
	FSArray annotationProperties = metaData.getMetadataProperties();
	if (annotationProperties != null) {
		for (int i = 0; i < annotationProperties.size(); i++) {
			FeatureStructure fs = annotationProperties.get(i);
			if (annotationPropertyClass.isAssignableFrom(fs.getClass())) {
				annotationPropertiesToReturn.add(annotationPropertyClass.cast(fs));
			}
		}
	}
	return annotationPropertiesToReturn;
}
 
開發者ID:UCDenver-ccp,項目名稱:ccp-nlp,代碼行數:34,代碼來源:UIMA_Annotation_Util.java

示例9: adaptFile

import org.apache.uima.cas.FeatureStructure; //導入依賴的package包/類
@Override
public void adaptFile(CAS cas, Path path) throws CollectionException {
  LOGGER.info("Deserializing an input stream into a cas");
  try (InputStream inputStream = Files.newInputStream(path)) {
    XmiCasDeserializer.deserialize(inputStream, cas,
        !(failOnUnknownType == null || failOnUnknownType));
  } catch (SAXException | IOException e) {
    LOGGER.error("Failed on document: {}", path);
    throw new CollectionException(e);
  }

  if (addDocumentId != null && addDocumentId) {
    CAS metadata = cas.getView("metadata");

    Type idType = metadata.getTypeSystem()
        .getType("edu.umn.biomedicus.uima.type1_5.DocumentId");
    Feature idFeat = idType.getFeatureByBaseName("documentId");

    FeatureStructure fs = metadata.createFS(idType);
    fs.setStringValue(idFeat, path.getFileName().toString());
    metadata.addFsToIndexes(fs);
  }
}
 
開發者ID:nlpie,項目名稱:biomedicus,代碼行數:24,代碼來源:XmiInputFileAdapter.java

示例10: annotationToLabel

import org.apache.uima.cas.FeatureStructure; //導入依賴的package包/類
@Override
public DictionaryTerm annotationToLabel(AnnotationFS annotationFS) {
  FeatureStructure conceptsFeatureValue = annotationFS.getFeatureValue(conceptsFeature);
  if (!(conceptsFeatureValue instanceof ArrayFS)) {
    throw new IllegalStateException("Concepts feature structure is not array.");
  }

  ArrayFS conceptsArray = (ArrayFS) conceptsFeatureValue;

  int size = conceptsArray.size();

  List<DictionaryConcept> concepts = new ArrayList<>(size);

  for (int i = 0; i < size; i++) {
    AnnotationFS conceptFeatureStructure = (AnnotationFS) conceptsArray.get(i);
    concepts.add(dictionaryConceptLabelAdapter.annotationToLabel(conceptFeatureStructure));
  }
  return new DictionaryTerm(annotationFS.getBegin(), annotationFS.getEnd(), concepts);
}
 
開發者ID:nlpie,項目名稱:biomedicus,代碼行數:20,代碼來源:DictionaryTermLabelAdapter.java

示例11: annotationToLabel

import org.apache.uima.cas.FeatureStructure; //導入依賴的package包/類
@Override
public T annotationToLabel(AnnotationFS annotationFS) {
  FeatureStructure cuesValue = annotationFS.getFeatureValue(cues);
  if (!(cuesValue instanceof ArrayFS)) {
    throw new IllegalStateException("Cues is not ArrayFS");
  }
  ArrayFS cuesArray = (ArrayFS) cuesValue;

  int size = cuesArray.size();
  List<Span> cueTerms = new ArrayList<>(size);
  for (int i = 0; i < size; i++) {
    FeatureStructure cueFs = cuesArray.get(i);
    if (!(cueFs instanceof AnnotationFS)) {
      throw new IllegalStateException();
    }
    AnnotationFS cueAnnotation = (AnnotationFS) cueFs;
    Span span = new Span(cueAnnotation.getBegin(),
        cueAnnotation.getEnd());
    cueTerms.add(span);
  }

  return create(annotationFS.getBegin(), annotationFS.getEnd(), cueTerms);
}
 
開發者ID:nlpie,項目名稱:biomedicus,代碼行數:24,代碼來源:BiomedicusTsLabelsPlugin.java

示例12: CASDocument

import org.apache.uima.cas.FeatureStructure; //導入依賴的package包/類
CASDocument(@Nullable LabelAdapters labelAdapters,
    CAS cas,
    String documentId) {
  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.createView("metadata");
  metadata.setDocumentText("");
  Type idType = typeSystem
      .getType("edu.umn.biomedicus.uima.type1_5.DocumentId");
  Feature idFeat = idType.getFeatureByBaseName("documentId");
  this.documentId = documentId;
  FeatureStructure documentIdFs = metadata.createFS(idType);
  documentIdFs.setStringValue(idFeat, documentId);
  metadata.addFsToIndexes(documentIdFs);
}
 
開發者ID:nlpie,項目名稱:biomedicus,代碼行數:23,代碼來源:CASDocument.java

示例13: setFeatureValue

import org.apache.uima.cas.FeatureStructure; //導入依賴的package包/類
/**
 * Sets the feature value based on the type that you're using to set, make sure that your
 * primitives are casted to the right type.
 *
 * @param name the feature name
 * @param value the value to set
 */
public void setFeatureValue(String name, @Nullable Object value) {
  Feature feature = getFeature(name);
  if (value instanceof String) {
    featureStructure.setStringValue(feature, (String) value);
  } else if (value instanceof Integer) {
    featureStructure.setIntValue(feature, ((Integer) value));
  } else if (value instanceof Long) {
    featureStructure.setLongValue(feature, ((Long) value));
  } else if (value instanceof Double) {
    featureStructure.setDoubleValue(feature, ((Double) value));
  } else if (value instanceof Float) {
    featureStructure.setFloatValue(feature, ((Float) value));
  } else if (value instanceof FeatureStructure) {
    featureStructure.setFeatureValue(feature, ((FeatureStructure) value));
  } else if (value instanceof Byte) {
    featureStructure.setByteValue(feature, ((Byte) value));
  }
}
 
開發者ID:nlpie,項目名稱:biomedicus,代碼行數:26,代碼來源:FsAccessor.java

示例14: FsCopiers

import org.apache.uima.cas.FeatureStructure; //導入依賴的package包/類
/**
 * Convenience constructor which only needs the callback for encountered feature structures.
 *
 * @param featureStructureEncounteredCallback callback for encountered feature structures
 */
FsCopiers(UnaryOperator<FeatureStructure> featureStructureEncounteredCallback,
    FeatureCopiers featureCopiers) {
  this.featureCopiers = featureCopiers;
  this.featureStructureEncounteredCallback = featureStructureEncounteredCallback;

  fsCopiers = new HashMap<>();
  fsCopiers.put(CAS.TYPE_NAME_BOOLEAN_ARRAY, copyArray(BooleanArrayFS.class));
  fsCopiers.put(CAS.TYPE_NAME_BYTE_ARRAY, copyArray(ByteArrayFS.class));
  fsCopiers.put(CAS.TYPE_NAME_DOUBLE_ARRAY, copyArray(DoubleArrayFS.class));
  fsCopiers.put(CAS.TYPE_NAME_FLOAT_ARRAY, copyArray(FloatArrayFS.class));
  fsCopiers.put(CAS.TYPE_NAME_FS_ARRAY, this::copyFsArray);
  fsCopiers.put(CAS.TYPE_NAME_LONG_ARRAY, copyArray(LongArrayFS.class));
  fsCopiers.put(CAS.TYPE_NAME_INTEGER_ARRAY, copyArray(IntArrayFS.class));
  fsCopiers.put(CAS.TYPE_NAME_SHORT_ARRAY, copyArray(ShortArrayFS.class));
  fsCopiers.put(CAS.TYPE_NAME_STRING_ARRAY, copyArray(StringArrayFS.class));
}
 
開發者ID:nlpie,項目名稱:biomedicus,代碼行數:22,代碼來源:FsCopiers.java

示例15: testFeatureStructuresOfType

import org.apache.uima.cas.FeatureStructure; //導入依賴的package包/類
@Test
public void testFeatureStructuresOfType() throws Exception {
  new Expectations() {{
    cas.getIndexRepository().getAllIndexedFS(type);
    result = fsIterator;
    times = 1;
    Spliterators.spliteratorUnknownSize(fsIterator, anyInt);
    result = spliterator;
    times = 1;
    StreamSupport.stream(spliterator, anyBoolean);
    result = stream;
    times = 1;
  }};

  Stream<FeatureStructure> featureStructureStream = casHelper.featureStructuresOfType(type);
  Assert.assertEquals(featureStructureStream, stream);
}
 
開發者ID:nlpie,項目名稱:biomedicus,代碼行數:18,代碼來源:CasHelperTest.java


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