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


Java FeatureStructure.setFeatureValue方法代码示例

本文整理汇总了Java中org.apache.uima.cas.FeatureStructure.setFeatureValue方法的典型用法代码示例。如果您正苦于以下问题:Java FeatureStructure.setFeatureValue方法的具体用法?Java FeatureStructure.setFeatureValue怎么用?Java FeatureStructure.setFeatureValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.uima.cas.FeatureStructure的用法示例。


在下文中一共展示了FeatureStructure.setFeatureValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: addChainAnnotations

import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
/**
 * The individual link annotations are stored in a {@link TreeMap} (chainAnnosPerTye) with chain
 * number and link number references, sorted in an ascending order <br>
 * Iterate over each chain number and link number references and construct the chain.
 */
private void addChainAnnotations(JCas aJCas)
{
    for (Type linkType : chainAnnosPerTyep.keySet()) {
        for (int chainNo : chainAnnosPerTyep.get(linkType).keySet()) {

            Type chainType = aJCas.getCas().getTypeSystem().getType(
                    linkType.getName().substring(0, linkType.getName().length() - 4) + CHAIN);
            Feature firstF = chainType.getFeatureByBaseName(FIRST);
            Feature nextF = linkType.getFeatureByBaseName(NEXT);
            FeatureStructure chain = aJCas.getCas().createFS(chainType);

            aJCas.addFsToIndexes(chain);
            AnnotationFS firstFs = chainAnnosPerTyep.get(linkType).get(chainNo).get(1);
            AnnotationFS linkFs = firstFs;
            chain.setFeatureValue(firstF, firstFs);
            for (int i = 2; i <= chainAnnosPerTyep.get(linkType).get(chainNo).size(); i++) {
                linkFs.setFeatureValue(nextF,
                        chainAnnosPerTyep.get(linkType).get(chainNo).get(i));
                linkFs = chainAnnosPerTyep.get(linkType).get(chainNo).get(i);
            }
        }
    }
}
 
开发者ID:webanno,项目名称:webanno,代码行数:29,代码来源:WebannoTsv3Reader.java

示例3: copyFeatures

import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
private void copyFeatures(FeatureStructure sourceFs, FeatureStructure targetFs, Set<Feature> features) {
	for(Feature feat : features) {
		if (feat.getRange().isPrimitive()) {
			copyPrimiteFeature(sourceFs, targetFs, feat);
		}
		else {
			// TODO consider arrays
			targetFs.setFeatureValue(feat, sourceFs.getFeatureValue(feat));
		}
	}
}
 
开发者ID:argo-nactem,项目名称:nactem-type-mapper,代码行数:12,代码来源:NactemTypeMapper.java

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

示例5: 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);

}
 
开发者ID:webanno,项目名称:webanno,代码行数:34,代码来源:WebAnnoCasUtil.java

示例6: setLinkFeatureValue

import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
public static void setLinkFeatureValue(FeatureStructure aFS, Feature aFeature,
        List<FeatureStructure> linkFSes)
{
    // Create a new array if size differs otherwise re-use existing one
    ArrayFS array = (ArrayFS) WebAnnoCasUtil.getFeatureFS(aFS, aFeature.getShortName());
    if (array == null || (array.size() != linkFSes.size())) {
        array = aFS.getCAS().createArrayFS(linkFSes.size());
    }

    // Fill in links
    array.copyFromArray(linkFSes.toArray(new FeatureStructure[linkFSes.size()]), 0, 0,
            linkFSes.size());

    aFS.setFeatureValue(aFeature, array);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:16,代码来源:WebAnnoCasUtil.java

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

示例8: setFirstLink

import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
/**
 * Set the first link of a chain in the chain head feature structure.
 */
private void setFirstLink(FeatureStructure aChain, AnnotationFS aLink)
{
    aChain.setFeatureValue(aChain.getType().getFeatureByBaseName(chainFirstFeatureName), aLink);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:8,代码来源:ChainAdapter.java

示例9: setFeatureFS

import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
/**
 * Set a feature value.
 *
 * @param aFS
 *            the feature structure.
 * @param aFeatureName
 *            the feature within the annotation whose value to set.
 * @param aValue
 *            the feature value.
 */
public static void setFeatureFS(FeatureStructure aFS, String aFeatureName,
        FeatureStructure aValue)
{
    Feature labelFeature = aFS.getType().getFeatureByBaseName(aFeatureName);
    aFS.setFeatureValue(labelFeature, aValue);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:17,代码来源:WebAnnoCasUtil.java


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