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


Java AnnotationFS.setFeatureValue方法代码示例

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


在下文中一共展示了AnnotationFS.setFeatureValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fillAnnotation

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
protected void fillAnnotation(T label, AnnotationFS annotationFS) {
  List<Span> cueTerms = label.getCueTerms();
  ArrayFS fsArray = cas.createArrayFS(cueTerms.size());
  for (int i = 0; i < cueTerms.size(); i++) {
    Span cueTerm = cueTerms.get(i);

    AnnotationFS cueAnnotation = cas.createAnnotation(cueType, cueTerm.getStartIndex(),
        cueTerm.getEndIndex());

    cas.addFsToIndexes(cueAnnotation);
    fsArray.set(i, cueAnnotation);
  }
  cas.addFsToIndexes(fsArray);
  annotationFS.setFeatureValue(cues, fsArray);
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:17,代码来源:BiomedicusTsLabelsPlugin.java

示例2: makeAnnotation

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
public void makeAnnotation(AnnotationFS firstToken, AnnotationFS lastToken, String tag) {
    Preconditions.checkArgument(firstToken != null, "firstToken == null");
    CAS cas = firstToken.getCAS();
    Type targetType = tag2TypeMap.get(tag);
    if (targetType == null) {
        logger.warn(String.format("Dictionary tag '%s' is not mapped to any annotation type", tag));
    } else {
        AnnotationFS anno = cas.createAnnotation(targetType, firstToken.getBegin(), lastToken.getEnd());
        Feature firstTokenFeature = targetType.getFeatureByBaseName("firstToken");
        // TODO doc
        if (firstTokenFeature != null) {
            anno.setFeatureValue(firstTokenFeature, firstToken);
        }
        cas.addFsToIndexes(anno);
    }
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:18,代码来源:TypedChunkAnnotationAdapter.java

示例3: addChainAnnotations

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的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

示例4: copyRelationAnnotation

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
public static void copyRelationAnnotation(AnnotationFS aOldFs, AnnotationFS asourceFS,
        AnnotationFS aTargetFs, JCas aJCas)
{
    Feature[] features = getAllFeatures(aOldFs);
    Type type = aOldFs.getType();
    Feature sourceFeat = type.getFeatureByBaseName(WebAnnoConst.FEAT_REL_SOURCE);
    Feature targetFeat = type.getFeatureByBaseName(WebAnnoConst.FEAT_REL_TARGET);
    AnnotationFS newFs = aJCas.getCas().createAnnotation(type, aOldFs.getBegin(),
            aOldFs.getEnd());
    for (Feature f : features) {
        if (isLinkOrBasicFeatures(aOldFs, f)) {
            continue;
        }
        if (f.equals(sourceFeat)) {
            newFs.setFeatureValue(f, asourceFS);
        }
        else if (f.equals(targetFeat)) {
            newFs.setFeatureValue(f, aTargetFs);
        }
        else {
            setFeatureValue(newFs, f, getFeatureValue(aOldFs, f));
        }
    }
    aJCas.addFsToIndexes(newFs);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:26,代码来源:MergeCas.java

示例5: fillAnnotation

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
protected void fillAnnotation(DictionaryTerm label, AnnotationFS annotationFS) {
  List<DictionaryConcept> concepts = label.getConcepts();
  int size = concepts.size();
  ArrayFS arrayFS = cas.createArrayFS(size);
  for (int i = 0; i < size; i++) {
    DictionaryConcept dictionaryConcept = concepts.get(i);
    AnnotationFS conceptAnnotation = dictionaryConceptLabelAdapter.labelToAnnotation(dictionaryConcept);
    arrayFS.set(i, conceptAnnotation);
  }
  cas.addFsToIndexes(arrayFS);
  annotationFS.setFeatureValue(conceptsFeature, arrayFS);
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:14,代码来源:DictionaryTermLabelAdapter.java

示例6: makeAnnotation

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
public void makeAnnotation(AnnotationFS firstToken, AnnotationFS lastToken, String tag) {
    Preconditions.checkArgument(firstToken != null, "firstToken == null");
    CAS cas = firstToken.getCAS();
    AnnotationFS anno = cas.createAnnotation(resultAnnotationType, firstToken.getBegin(), lastToken.getEnd());
    anno.setStringValue(tagFeature, tag);
    if (firstTokenFeature != null) {
        anno.setFeatureValue(firstTokenFeature, firstToken);
    }
    cas.addFsToIndexes(anno);
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:12,代码来源:TaggedChunkAnnotationAdapter.java

示例7: makeAnnotation

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
public void makeAnnotation(AnnotationFS firstToken, AnnotationFS lastToken, Object metadata) {
    Preconditions.checkArgument(firstToken != null, "firstToken == null");
    CAS cas = firstToken.getCAS();
    AnnotationFS resAnno = cas.createAnnotation(resultAnnoType, firstToken.getBegin(), lastToken.getEnd());
    if (firstTokenFeature != null) {
        resAnno.setFeatureValue(firstTokenFeature, firstToken);
    }
    cas.addFsToIndexes(resAnno);
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:11,代码来源:DefaultChunkAnnotationAdapter.java

示例8: mapStructureRoles

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
private <BT extends BratType, BA extends BratStructureAnnotation<BT>> AnnotationFS mapStructureRoles(
        BA bAnno, BratUimaStructureMapping<BT> strMapping) {
    AnnotationFS result = cas.createAnnotation(strMapping.uimaType, 0, 0);
    for (Feature roleFeature : strMapping.featureRoles.keySet()) {
        String roleName = strMapping.featureRoles.get(roleFeature);
        Collection<BratAnnotation<?>> roleBratAnnos = bAnno.getRoleAnnotations().get(roleName);
        if (roleBratAnnos.isEmpty()) {
            continue;
        }
        List<AnnotationFS> roleUimaAnnos = Lists.newLinkedList();
        for (BratAnnotation<?> roleBratAnno : roleBratAnnos) {
            AnnotationFS roleUimaAnno = mappingCtx.getMapped(roleBratAnno);
            if (roleUimaAnno == null) {
                throw new IllegalStateException(String.format(
                        "Brat annotation %s has not been mapped", roleBratAnno));
            }
            roleUimaAnnos.add(roleUimaAnno);
        }
        FeatureStructure featVal;
        if (PUtils.hasCollectionRange(roleFeature)) {
            featVal = PUtils.toCompatibleCollection(cas, roleFeature, roleUimaAnnos);
        } else {
            if (roleUimaAnnos.size() > 1) {
                getLogger().error(String.format(
                        "Too much role '%s' values in anno %s in doc %s. " +
                                "Only the first value will be mapped.",
                        roleName, bAnno.getId(), currentDocName));
            }
            featVal = roleUimaAnnos.get(0);
        }
        result.setFeatureValue(roleFeature, featVal);
    }
    return result;
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:35,代码来源:BratCollectionReader.java

示例9: addSlotAnnotations

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
/**
 * update a base annotation with slot annotations
 * 
 * @param linkFSesPerAnno
 *            contains list of slot annotations per a base annotation
 * @param aLinkeF
 *            The link slot annotation feature
 */
private void addSlotAnnotations(Map<AnnotationFS, List<FeatureStructure>> linkFSesPerAnno,
        Feature aLinkeF)
{
    for (AnnotationFS anno : linkFSesPerAnno.keySet()) {
        ArrayFS array = anno.getCAS().createArrayFS(linkFSesPerAnno.get(anno).size());
        array.copyFromArray(
                linkFSesPerAnno.get(anno)
                        .toArray(new FeatureStructure[linkFSesPerAnno.get(anno).size()]),
                0, 0, linkFSesPerAnno.get(anno).size());
        anno.setFeatureValue(aLinkeF, array);
        anno.getCAS().addFsToIndexes(anno);
    }
}
 
开发者ID:webanno,项目名称:webanno,代码行数:22,代码来源:WebannoTsv3Reader.java

示例10: makeLinkHostFS

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
private static AnnotationFS makeLinkHostFS(JCas aJCas, String aType, int aBegin, int aEnd,
        FeatureStructure... aLinks)
{
    Type hostType = aJCas.getTypeSystem().getType(aType);
    AnnotationFS hostA1 = aJCas.getCas().createAnnotation(hostType, aBegin, aEnd);
    hostA1.setFeatureValue(hostType.getFeatureByBaseName("links"),
            FSCollectionFactory.createFSArray(aJCas, asList(aLinks)));
    aJCas.getCas().addFsToIndexes(hostA1);
    return hostA1;
}
 
开发者ID:webanno,项目名称:webanno,代码行数:11,代码来源:WebAnnoTsv3WriterTestBase.java

示例11: testFail

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Test
public void testFail()
    throws Exception
{
    TypeSystemDescription tsd = UIMAFramework.getResourceSpecifierFactory()
            .createTypeSystemDescription();
    
    String refTypeName = "RefType";
    
    TypeDescription refTypeDesc = tsd.addType(refTypeName, null, CAS.TYPE_NAME_ANNOTATION);
    refTypeDesc.addFeature("ref", null, CAS.TYPE_NAME_ANNOTATION);
    
    CAS cas = CasCreationUtils.createCas(tsd, null, null);
    
    Type refType = cas.getTypeSystem().getType(refTypeName);
    
    // A regular index annotation
    AnnotationFS anno1 = cas.createAnnotation(cas.getAnnotationType(), 0, 1);
    cas.addFsToIndexes(anno1);

    // A non-index annotation but reachable through an indexe one (below)
    AnnotationFS anno2 = cas.createAnnotation(cas.getAnnotationType(), 0, 1);

    // An indexed annotation that references the non-indexed annotation above
    AnnotationFS anno3 = cas.createAnnotation(refType, 0, 1);
    anno3.setFeatureValue(refType.getFeatureByBaseName("ref"), anno2);
    cas.addFsToIndexes(anno3);
    
    List<LogMessage> messages = new ArrayList<>();
    CasDoctor cd = new CasDoctor(AllFeatureStructuresIndexedCheck.class);
    // A project is not required for this check
    boolean result = cd.analyze(null, cas, messages);
    
    messages.forEach(System.out::println);
    
    assertFalse(result);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:38,代码来源:AllAnnotationsIndexedCheckTest.java

示例12: testOK

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Test
public void testOK()
    throws Exception
{
    TypeSystemDescription tsd = UIMAFramework.getResourceSpecifierFactory()
            .createTypeSystemDescription();
    
    String refTypeName = "RefType";
    
    TypeDescription refTypeDesc = tsd.addType(refTypeName, null, CAS.TYPE_NAME_ANNOTATION);
    refTypeDesc.addFeature("ref", null, CAS.TYPE_NAME_ANNOTATION);
    
    CAS cas = CasCreationUtils.createCas(tsd, null, null);
    
    Type refType = cas.getTypeSystem().getType(refTypeName);
    
    // A regular index annotation
    AnnotationFS anno1 = cas.createAnnotation(cas.getAnnotationType(), 0, 1);
    cas.addFsToIndexes(anno1);

    // An indexed annotation but reachable through an indexe one (below)
    AnnotationFS anno2 = cas.createAnnotation(cas.getAnnotationType(), 0, 1);
    cas.addFsToIndexes(anno2);

    // An indexed annotation that references the non-indexed annotation above
    AnnotationFS anno3 = cas.createAnnotation(refType, 0, 1);
    anno3.setFeatureValue(refType.getFeatureByBaseName("ref"), anno2);
    cas.addFsToIndexes(anno3);
    
    List<LogMessage> messages = new ArrayList<>();
    CasDoctor cd = new CasDoctor(AllFeatureStructuresIndexedCheck.class);
    // A project is not required for this check
    boolean result = cd.analyze(null, cas, messages);
    
    messages.forEach(System.out::println);
    
    assertTrue(result);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:39,代码来源:AllAnnotationsIndexedCheckTest.java

示例13: makeLinkHostFS

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
public static void makeLinkHostFS(JCas aJCas, int aBegin, int aEnd, FeatureStructure... aLinks)
{
    Type hostType = aJCas.getTypeSystem().getType(HOST_TYPE);
    AnnotationFS hostA1 = aJCas.getCas().createAnnotation(hostType, aBegin, aEnd);
    hostA1.setFeatureValue(hostType.getFeatureByBaseName("links"),
            FSCollectionFactory.createFSArray(aJCas, asList(aLinks)));
    aJCas.getCas().addFsToIndexes(hostA1);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:9,代码来源:DiffUtils.java

示例14: makeLinkHostMultiSPanFeatureFS

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
public static AnnotationFS makeLinkHostMultiSPanFeatureFS(JCas aJCas, int aBegin, int aEnd,
        Feature aSpanFeature, String aValue, FeatureStructure... aLinks)
{
    Type hostType = aJCas.getTypeSystem().getType(HOST_TYPE);
    AnnotationFS hostA1 = aJCas.getCas().createAnnotation(hostType, aBegin, aEnd);
    hostA1.setFeatureValue(hostType.getFeatureByBaseName("links"),
            FSCollectionFactory.createFSArray(aJCas, asList(aLinks)));
    hostA1.setStringValue(aSpanFeature, aValue);
    aJCas.getCas().addFsToIndexes(hostA1);
    return hostA1;
}
 
开发者ID:webanno,项目名称:webanno,代码行数:12,代码来源:DiffUtils.java

示例15: createRelationLayer

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
/**
 * Creates a relation layer. For every token, store the governor positions and the dependent
 * annotation
 */

private void createRelationLayer(JCas aJcas, Map<Type, Type> relationayers,
        Map<Type, Map<String, List<AnnotationFS>>> tokenAnnotations,
        Map<Type, Map<String, List<String>>> relationTargets)
{

    for (Type layer : relationayers.keySet()) {

        if (relationTargets.get(layer) == null) {
            continue;
        }
        Feature dependentFeature = layer.getFeatureByBaseName("Dependent");
        Feature governorFeature = layer.getFeatureByBaseName("Governor");

        Map<String, List<String>> tokenIdMaps = relationTargets.get(layer);
        Map<String, List<AnnotationFS>> tokenAnnos = tokenAnnotations
                .get(relationayers.get(layer));
        Map<String, List<AnnotationFS>> relationAnnos = tokenAnnotations.get(layer);
        for (String dependnetId : tokenIdMaps.keySet()) {
            int i = 0;
            for (String governorId : tokenIdMaps.get(dependnetId)) {

                AnnotationFS relationAnno = relationAnnos.get(dependnetId).get(i);
                AnnotationFS dependentAnno = tokenAnnos.get(dependnetId).get(0);
                AnnotationFS governorAnno = tokenAnnos.get(governorId).get(0);

                if (layer.getName().equals(Dependency.class.getName())) {
                    Type tokenType = getType(aJcas.getCas(), Token.class.getName());
                    Feature attachFeature = tokenType.getFeatureByBaseName("pos");
                    AnnotationFS posDependentAnno = dependentAnno;
                    dependentAnno = CasUtil.selectCovered(aJcas.getCas(), tokenType,
                            dependentAnno.getBegin(), dependentAnno.getEnd()).get(0);
                    dependentAnno.setFeatureValue(attachFeature, posDependentAnno);

                    AnnotationFS posGovernorAnno = governorAnno;
                    governorAnno = CasUtil.selectCovered(aJcas.getCas(), tokenType,
                            governorAnno.getBegin(), governorAnno.getEnd()).get(0);
                    governorAnno.setFeatureValue(attachFeature, posGovernorAnno);
                }
                // update begin/end of relation annotation
                if (dependentAnno.getEnd() <= governorAnno.getEnd()) {
                    ((Annotation) relationAnno).setBegin(dependentAnno.getBegin());
                    ((Annotation) relationAnno).setEnd(governorAnno.getEnd());
                }
                else {
                    ((Annotation) relationAnno).setBegin(governorAnno.getBegin());
                    ((Annotation) relationAnno).setEnd(dependentAnno.getEnd());
                }

                relationAnno.setFeatureValue(dependentFeature, dependentAnno);
                relationAnno.setFeatureValue(governorFeature, governorAnno);
                i++;
            }

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


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