本文整理汇总了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);
}
}
}
示例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);
}
示例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());
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
}
示例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));
}
示例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);
}