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


Java AnnotationFS.getCAS方法代码示例

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


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

示例1: 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

示例2: getAttachedSpans

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
private Set<AnnotationFS> getAttachedSpans(AnnotationFS aFs, AnnotationLayer aLayer)
{
    CAS cas = aFs.getCAS();
    Set<AnnotationFS> attachedSpans = new HashSet<>();
    TypeAdapter adapter = annotationService.getAdapter(aLayer);
    if (adapter instanceof SpanAdapter && aLayer.getAttachType() != null) {
        Type spanType = CasUtil.getType(cas, aLayer.getAttachType().getName());
        Feature attachFeature = spanType.getFeatureByBaseName(aLayer.getAttachFeature()
            .getName());

        for (AnnotationFS attachedFs : selectAt(cas, spanType, aFs.getBegin(), aFs.getEnd())) {
            if (isSame(attachedFs.getFeatureValue(attachFeature), aFs)) {
                attachedSpans.add(attachedFs);
            }
        }
    }
    return attachedSpans;
}
 
开发者ID:webanno,项目名称:webanno,代码行数:19,代码来源:AnnotationDetailEditorPanel.java

示例3: 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

示例4: 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

示例5: makeChainHead

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
private static void makeChainHead(Type aType, AnnotationFS first)
{
    CAS cas = first.getCAS();
    FeatureStructure h = cas.createFS(aType);
    FSUtil.setFeature(h, "first", first);
    cas.addFsToIndexes(h);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:8,代码来源:WebAnnoTsv3WriterTestBase.java

示例6: getAttachedLinks

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
private Set<AnnotationFS> getAttachedLinks(AnnotationFS aFs, AnnotationLayer aLayer)
{
    CAS cas = aFs.getCAS();
    Set<AnnotationFS> attachedLinks = new HashSet<>();
    TypeAdapter adapter = annotationService.getAdapter(aLayer);
    if (adapter instanceof SpanAdapter) {
        for (AnnotationFeature linkFeature : annotationService
                .listAttachedLinkFeatures(aLayer)) {
            if (MultiValueMode.ARRAY.equals(linkFeature.getMultiValueMode())
                    && LinkMode.WITH_ROLE.equals(linkFeature.getLinkMode())) {
                // Fetch slot hosts that could link to the current FS and check if any of
                // them actually links to the current FS
                Type linkType = CasUtil.getType(cas, linkFeature.getLayer().getName());
                for (AnnotationFS linkFS : CasUtil.select(cas, linkType)) {
                    List<LinkWithRoleModel> links = adapter.getFeatureValue(linkFeature,
                            linkFS);
                    for (int li = 0; li < links.size(); li++) {
                        LinkWithRoleModel link = links.get(li);
                        AnnotationFS linkTarget = selectByAddr(cas, AnnotationFS.class,
                                link.targetAddr);
                        // If the current annotation fills a slot, then add the slot host to
                        // our list of attached links.
                        if (isSame(linkTarget, aFs)) {
                            attachedLinks.add(linkFS);
                        }
                    }
                }
            }
        }
    }
    return attachedLinks;
}
 
开发者ID:webanno,项目名称:webanno,代码行数:33,代码来源:AnnotationDetailEditorPanel.java

示例7: getAttachedRels

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
public Set<AnnotationFS> getAttachedRels(AnnotationFS aFs, AnnotationLayer aLayer)
{
    CAS cas = aFs.getCAS();
    Set<AnnotationFS> toBeDeleted = new HashSet<>();
    for (AnnotationLayer relationLayer : annotationService
        .listAttachedRelationLayers(aLayer)) {
        ArcAdapter relationAdapter = (ArcAdapter) annotationService.getAdapter(relationLayer);
        Type relationType = CasUtil.getType(cas, relationLayer.getName());
        Feature sourceFeature = relationType.getFeatureByBaseName(relationAdapter
            .getSourceFeatureName());
        Feature targetFeature = relationType.getFeatureByBaseName(relationAdapter
            .getTargetFeatureName());

        // This code is already prepared for the day that relations can go between
        // different layers and may have different attach features for the source and
        // target layers.
        Feature relationSourceAttachFeature = null;
        Feature relationTargetAttachFeature = null;
        if (relationAdapter.getAttachFeatureName() != null) {
            relationSourceAttachFeature = sourceFeature.getRange().getFeatureByBaseName(
                relationAdapter.getAttachFeatureName());
            relationTargetAttachFeature = targetFeature.getRange().getFeatureByBaseName(
                relationAdapter.getAttachFeatureName());
        }

        for (AnnotationFS relationFS : CasUtil.select(cas, relationType)) {
            // Here we get the annotations that the relation is pointing to in the UI
            FeatureStructure sourceFS;
            if (relationSourceAttachFeature != null) {
                sourceFS = relationFS.getFeatureValue(sourceFeature).getFeatureValue(
                    relationSourceAttachFeature);
            }
            else {
                sourceFS = relationFS.getFeatureValue(sourceFeature);
            }

            FeatureStructure targetFS;
            if (relationTargetAttachFeature != null) {
                targetFS = relationFS.getFeatureValue(targetFeature).getFeatureValue(
                    relationTargetAttachFeature);
            }
            else {
                targetFS = relationFS.getFeatureValue(targetFeature);
            }

            if (isSame(sourceFS, aFs) || isSame(targetFS, aFs)) {
                toBeDeleted.add(relationFS);
                LOG.debug("Deleted relation [" + getAddr(relationFS) + "] from layer ["
                    + relationLayer.getName() + "]");
            }
        }
    }

    return toBeDeleted;
}
 
开发者ID:webanno,项目名称:webanno,代码行数:56,代码来源:AnnotationDetailEditorPanel.java


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