本文整理汇总了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);
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}