本文整理汇总了Java中org.apache.uima.cas.FeatureStructure.getStringValue方法的典型用法代码示例。如果您正苦于以下问题:Java FeatureStructure.getStringValue方法的具体用法?Java FeatureStructure.getStringValue怎么用?Java FeatureStructure.getStringValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.uima.cas.FeatureStructure
的用法示例。
在下文中一共展示了FeatureStructure.getStringValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFeature
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
public static <T> T getFeature(FeatureStructure aFS, String aFeatureName)
{
Feature feature = aFS.getType().getFeatureByBaseName(aFeatureName);
if (feature == null) {
throw new IllegalArgumentException("Type [" + aFS.getType().getName()
+ "] has no feature called [" + aFeatureName + "]");
}
switch (feature.getRange().getName()) {
case CAS.TYPE_NAME_STRING:
return (T) aFS.getStringValue(feature);
case CAS.TYPE_NAME_BOOLEAN:
return (T) (Boolean) aFS.getBooleanValue(feature);
case CAS.TYPE_NAME_FLOAT:
return (T) (Float) aFS.getFloatValue(feature);
case CAS.TYPE_NAME_INTEGER:
return (T) (Integer) aFS.getIntValue(feature);
default:
throw new IllegalArgumentException("Cannot get value of feature [" + feature.getName()
+ "] with type [" + feature.getRange().getName() + "]");
}
}
示例2: generateSubPositions
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
@Override
public List<? extends Position> generateSubPositions(int aCasId, AnnotationFS aFs,
LinkCompareBehavior aLinkCompareBehavior)
{
List<Position> subPositions = new ArrayList<>();
for (LinkFeatureDecl decl : linkFeatures) {
Feature linkFeature = aFs.getType().getFeatureByBaseName(decl.name);
ArrayFS array = (ArrayFS) aFs.getFeatureValue(linkFeature);
if (array == null) {
continue;
}
for (FeatureStructure linkFS : array.toArray()) {
String role = linkFS.getStringValue(linkFS.getType().getFeatureByBaseName(
decl.roleFeature));
AnnotationFS target = (AnnotationFS) linkFS.getFeatureValue(linkFS.getType()
.getFeatureByBaseName(decl.targetFeature));
Position pos = getPosition(aCasId, aFs, decl.name, role, target.getBegin(),
target.getEnd(), aLinkCompareBehavior);
subPositions.add(pos);
}
}
return subPositions;
}
示例3: getPrimitiveFeatureValue
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
/**
* see section 4.2.1 of the UIMA References documentation.
*
* @param view
* @param featureStructure
* @param feature
* @return The feature value.
*/
private static Object getPrimitiveFeatureValue(
JCas view,
FeatureStructure featureStructure,
Feature feature) throws CleartkExtractorException {
TypeSystem typeSystem = view.getTypeSystem();
Type type = feature.getRange();
if (type.equals(typeSystem.getType("uima.cas.Boolean")))
return featureStructure.getBooleanValue(feature);
else if (type.equals(typeSystem.getType("uima.cas.Double")))
return featureStructure.getDoubleValue(feature);
else if (type.equals(typeSystem.getType("uima.cas.Float")))
return featureStructure.getFloatValue(feature);
else if (type.equals(typeSystem.getType("uima.cas.Byte")))
return featureStructure.getByteValue(feature);
else if (type.equals(typeSystem.getType("uima.cas.Short")))
return featureStructure.getShortValue(feature);
else if (type.equals(typeSystem.getType("uima.cas.Integer")))
return featureStructure.getIntValue(feature);
else if (type.equals(typeSystem.getType("uima.cas.Long")))
return featureStructure.getLongValue(feature);
else if (type.equals(typeSystem.getType("uima.cas.String")))
return featureStructure.getStringValue(feature);
else
throw CleartkExtractorException.notPrimitive(feature);
}
示例4: getMapEntry
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
@Nullable
private FeatureStructure getMapEntry(String key) {
FSIterator<FeatureStructure> fsIterator = metadata.getIndexRepository()
.getAllIndexedFS(metadataType);
while (fsIterator.hasNext()) {
FeatureStructure featureStructure = fsIterator.next();
String curKey = featureStructure.getStringValue(keyFeature);
if (Objects.equals(curKey, key)) {
return featureStructure;
}
}
return null;
}
示例5: getAllMetadata
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
@Override
public Map<String, String> getAllMetadata() {
Map<String, String> returnVal = new HashMap<>();
FSIterator<FeatureStructure> fsIterator = metadata.getIndexRepository()
.getAllIndexedFS(metadataType);
while (fsIterator.hasNext()) {
FeatureStructure featureStructure = fsIterator.next();
String key = featureStructure.getStringValue(keyFeature);
String val = featureStructure.getStringValue(valueFeature);
returnVal.put(key, val);
}
return returnVal;
}
示例6: getFeatureValue
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
default public <T> T getFeatureValue(AnnotationFeature aFeature, FeatureStructure aFS)
{
Feature feature = aFS.getType().getFeatureByBaseName(aFeature.getName());
switch (aFeature.getMultiValueMode()) {
case NONE: {
final String effectiveType;
if (aFeature.isVirtualFeature()) {
effectiveType = CAS.TYPE_NAME_STRING;
}
else {
effectiveType = aFeature.getType();
}
// Sanity check
if (!Objects.equals(effectiveType, feature.getRange().getName())) {
throw new IllegalArgumentException("Actual feature type ["
+ feature.getRange().getName() + "]does not match expected feature type ["
+ effectiveType + "].");
}
// switch (aFeature.getType()) {
// case CAS.TYPE_NAME_STRING:
// return (T) aFS.getStringValue(feature);
// case CAS.TYPE_NAME_BOOLEAN:
// return (T) (Boolean) aFS.getBooleanValue(feature);
// case CAS.TYPE_NAME_FLOAT:
// return (T) (Float) aFS.getFloatValue(feature);
// case CAS.TYPE_NAME_INTEGER:
// return (T) (Integer) aFS.getIntValue(feature);
// default:
// throw new IllegalArgumentException("Cannot get value of feature ["
// + aFeature.getName() + "] with type [" + feature.getRange().getName() + "]");
// }
return WebAnnoCasUtil.getFeature(aFS, aFeature.getName());
}
case ARRAY: {
switch (aFeature.getLinkMode()) {
case WITH_ROLE: {
// Get type and features - we need them later in the loop
Feature linkFeature = aFS.getType().getFeatureByBaseName(aFeature.getName());
Type linkType = aFS.getCAS().getTypeSystem().getType(aFeature.getLinkTypeName());
Feature roleFeat = linkType.getFeatureByBaseName(aFeature
.getLinkTypeRoleFeatureName());
Feature targetFeat = linkType.getFeatureByBaseName(aFeature
.getLinkTypeTargetFeatureName());
List<LinkWithRoleModel> links = new ArrayList<>();
ArrayFS array = (ArrayFS) aFS.getFeatureValue(linkFeature);
if (array != null) {
for (FeatureStructure link : array.toArray()) {
LinkWithRoleModel m = new LinkWithRoleModel();
m.role = link.getStringValue(roleFeat);
m.targetAddr = WebAnnoCasUtil.getAddr(link.getFeatureValue(targetFeat));
m.label = ((AnnotationFS) link.getFeatureValue(targetFeat))
.getCoveredText();
links.add(m);
}
}
return (T) links;
}
default:
throw new IllegalArgumentException("Cannot get value of feature ["
+ aFeature.getName() + "] with link mode [" + aFeature.getMultiValueMode()
+ "]");
}
}
default:
throw new IllegalArgumentException("Unsupported multi-value mode ["
+ aFeature.getMultiValueMode() + "] on feature [" + aFeature.getName() + "]");
}
}