本文整理汇总了Java中org.apache.uima.cas.FeatureStructure.setStringValue方法的典型用法代码示例。如果您正苦于以下问题:Java FeatureStructure.setStringValue方法的具体用法?Java FeatureStructure.setStringValue怎么用?Java FeatureStructure.setStringValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.uima.cas.FeatureStructure
的用法示例。
在下文中一共展示了FeatureStructure.setStringValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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);
}
示例3: copyPrimiteFeature
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
private void copyPrimiteFeature(FeatureStructure sourceFs,
FeatureStructure targetFs, Feature feat) {
String rangeName = feat.getRange().getName();
if (CAS.TYPE_NAME_STRING.equals(rangeName)) {
targetFs.setStringValue(feat, sourceFs.getStringValue(feat));
} else if (CAS.TYPE_NAME_INTEGER.equals(rangeName)) {
targetFs.setIntValue(feat, sourceFs.getIntValue(feat));
} else if (CAS.TYPE_NAME_FLOAT.equals(rangeName)) {
targetFs.setFloatValue(feat, sourceFs.getFloatValue(feat));
} else if (CAS.TYPE_NAME_BYTE.equals(rangeName)) {
targetFs.setByteValue(feat, sourceFs.getByteValue(feat));
} else if (CAS.TYPE_NAME_SHORT.equals(rangeName)) {
targetFs.setShortValue(feat, sourceFs.getShortValue(feat));
} else if (CAS.TYPE_NAME_LONG.equals(rangeName)) {
targetFs.setLongValue(feat, sourceFs.getLongValue(feat));
} else if (CAS.TYPE_NAME_DOUBLE.equals(rangeName)) {
targetFs.setDoubleValue(feat, sourceFs.getDoubleValue(feat));
} else if (CAS.TYPE_NAME_BOOLEAN.equals(rangeName)) {
targetFs.setBooleanValue(feat, sourceFs.getBooleanValue(feat));
}
}
示例4: putMetadata
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
@Override
public void putMetadata(String key, String value) {
FeatureStructure mapEntry = getMapEntry(key);
if (mapEntry != null) {
metadata.removeFsFromIndexes(mapEntry);
} else {
mapEntry = metadata.createFS(metadataType);
mapEntry.setStringValue(keyFeature, key);
}
mapEntry.setStringValue(valueFeature, value);
metadata.addFsToIndexes(mapEntry);
}
示例5: makeLinkFS
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
private static FeatureStructure makeLinkFS(JCas aJCas, String aType, String aSlotLabel,
AnnotationFS aTarget)
{
Type linkType = aJCas.getTypeSystem().getType(aType);
FeatureStructure linkA1 = aJCas.getCas().createFS(linkType);
linkA1.setStringValue(linkType.getFeatureByBaseName("role"), aSlotLabel);
linkA1.setFeatureValue(linkType.getFeatureByBaseName("target"), aTarget);
aJCas.getCas().addFsToIndexes(linkA1);
return linkA1;
}
示例6: setFeatureValue
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
public static void setFeatureValue(FeatureStructure aFS, Feature aFeature, Object aValue)
{
switch (aFeature.getRange().getName()) {
case CAS.TYPE_NAME_STRING:
aFS.setStringValue(aFeature, aValue == null ? null : aValue.toString());
break;
case CAS.TYPE_NAME_BOOLEAN:
aFS.setBooleanValue(aFeature, Boolean.valueOf(aValue.toString()));
break;
case CAS.TYPE_NAME_FLOAT:
aFS.setFloatValue(aFeature, Float.valueOf(aValue.toString()));
break;
case CAS.TYPE_NAME_INTEGER:
aFS.setIntValue(aFeature, Integer.valueOf(aValue.toString()));
break;
case CAS.TYPE_NAME_BYTE:
aFS.setByteValue(aFeature, Byte.valueOf(aValue.toString()));
break;
case CAS.TYPE_NAME_DOUBLE:
aFS.setDoubleValue(aFeature, Double.valueOf(aValue.toString()));
break;
case CAS.TYPE_NAME_LONG:
aFS.setLongValue(aFeature, Long.valueOf(aValue.toString()));
break;
case CAS.TYPE_NAME_SHORT:
aFS.setShortValue(aFeature, Short.valueOf(aValue.toString()));
break;
default:
return;
// return aFS.getFeatureValue(aFeature);
}
}
示例7: setLinkFeature
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
private static void setLinkFeature(FeatureStructure aFS, AnnotationFeature aFeature,
List<LinkWithRoleModel> aValue, Feature feature)
{
Type linkType = aFS.getCAS().getTypeSystem().getType(aFeature.getLinkTypeName());
Feature roleFeat = linkType.getFeatureByBaseName(aFeature
.getLinkTypeRoleFeatureName());
Feature targetFeat = linkType.getFeatureByBaseName(aFeature
.getLinkTypeTargetFeatureName());
// Create all the links
// FIXME: actually we could re-use existing link link feature structures
List<FeatureStructure> linkFSes = new ArrayList<>();
if (aValue != null) {
// remove duplicate links
Set<LinkWithRoleModel> links = new HashSet<>(aValue);
for (LinkWithRoleModel e : links) {
// Skip links that have been added in the UI but where the target has not
// yet been
// set
if (e.targetAddr == -1) {
continue;
}
FeatureStructure link = aFS.getCAS().createFS(linkType);
link.setStringValue(roleFeat, e.role);
link.setFeatureValue(targetFeat, selectByAddr(aFS.getCAS(), e.targetAddr));
linkFSes.add(link);
}
}
setLinkFeatureValue(aFS, feature, linkFSes);
}
示例8: makeLinkFS
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
public static FeatureStructure makeLinkFS(JCas aJCas, String aSlotLabel, int aTargetBegin,
int aTargetEnd)
{
Token token1 = new Token(aJCas, aTargetBegin, aTargetEnd);
token1.addToIndexes();
Type linkType = aJCas.getTypeSystem().getType(LINK_TYPE);
FeatureStructure linkA1 = aJCas.getCas().createFS(linkType);
linkA1.setStringValue(linkType.getFeatureByBaseName("role"), aSlotLabel);
linkA1.setFeatureValue(linkType.getFeatureByBaseName("target"), token1);
aJCas.getCas().addFsToIndexes(linkA1);
return linkA1;
}
示例9: setFeature
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
/**
* Set a feature value.
*
* @param aFS
* the feature structure.
* @param aFeature
* the feature within the annotation whose value to set. If this parameter is
* {@code null} then nothing happens.
* @param aValue
* the feature value.
*/
public static void setFeature(FeatureStructure aFS, AnnotationFeature aFeature, Object aValue)
{
if (aFeature == null) {
return;
}
Feature feature = aFS.getType().getFeatureByBaseName(aFeature.getName());
switch (aFeature.getMultiValueMode()) {
case NONE: {
String effectiveType = aFeature.getType();
if (effectiveType.contains(":")) {
effectiveType = CAS.TYPE_NAME_STRING;
}
// Sanity check
if (!Objects.equals(effectiveType, feature.getRange().getName())) {
throw new IllegalArgumentException("On [" + aFS.getType().getName() + "] feature ["
+ aFeature.getName() + "] actual type [" + feature.getRange().getName()
+ "] does not match expected feature type [" + effectiveType + "].");
}
switch (effectiveType) {
case CAS.TYPE_NAME_STRING:
aFS.setStringValue(feature, (String) aValue);
break;
case CAS.TYPE_NAME_BOOLEAN:
aFS.setBooleanValue(feature, aValue != null ? (boolean) aValue : false);
break;
case CAS.TYPE_NAME_FLOAT:
aFS.setFloatValue(feature, aValue != null ? (float) aValue : 0.0f);
break;
case CAS.TYPE_NAME_INTEGER:
aFS.setIntValue(feature, aValue != null ? (int) aValue : 0);
break;
default:
throw new IllegalArgumentException("Cannot set value of feature ["
+ aFeature.getName() + "] with type [" + feature.getRange().getName()
+ "] to [" + aValue + "]");
}
break;
}
case ARRAY: {
switch (aFeature.getLinkMode()) {
case WITH_ROLE: {
// Get type and features - we need them later in the loop
setLinkFeature(aFS, aFeature, (List<LinkWithRoleModel>) aValue, feature);
break;
}
default:
throw new IllegalArgumentException("Unsupported link mode ["
+ aFeature.getLinkMode() + "] on feature [" + aFeature.getName() + "]");
}
break;
}
default:
throw new IllegalArgumentException("Unsupported multi-value mode ["
+ aFeature.getMultiValueMode() + "] on feature [" + aFeature.getName() + "]");
}
}