当前位置: 首页>>代码示例>>Java>>正文


Java FeatureStructure.getStringValue方法代码示例

本文整理汇总了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() + "]");
    }
}
 
开发者ID:webanno,项目名称:webanno,代码行数:24,代码来源:WebAnnoCasUtil.java

示例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;
}
 
开发者ID:webanno,项目名称:webanno,代码行数:26,代码来源:CasDiff2.java

示例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);
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:34,代码来源:TypePathExtractor.java

示例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;
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:14,代码来源:CASDocument.java

示例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;
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:15,代码来源:CASDocument.java

示例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() + "]");
    }
}
 
开发者ID:webanno,项目名称:webanno,代码行数:73,代码来源:FeatureSupport.java


注:本文中的org.apache.uima.cas.FeatureStructure.getStringValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。