简体   繁体   English

将所有包含的注释列表添加为GATE中新注释的功能

[英]Add list of all contained annotations as features of new annotation in GATE

I am trying to add a list of all contained "all_tags" annotations as a feature of a new annotation using Java RHS rule. 我正在尝试使用Java RHS规则添加所有包含的“ all_tags”注释的列表,作为新注释的功能。

Below only adds one annotation rather than all of them in a list: 下面仅添加一个注释,而不是列表中的所有注释:

AnnotationSet contTagAS = getContainedAnnotations(inputAS,spanAs).get("all_tags");

for (Annotation tagAnn : contTagAS.inDocumentOrder())
{
  FeatureMap lookupFeatures  = tagAnn.getFeatures();
  tag = lookupFeatures.get("type").toString();  
}

I want each all_tags "type" to be added as features separated by commmas, ie "type 1, type 2, type 3" 我希望将每个all_tags“类型”添加为以逗号分隔的功能,即“类型1,类型2,类型3”

I have tried List Annotation classes but cannot find the right method. 我尝试了List Annotation类,但是找不到正确的方法。

Many thanks 非常感谢

AnnotationSet contTagAS = getContainedAnnotations(inputAS,spanAs).get("all_tags");

StringJoiner joiner = new StringJoiner(",");

for (Annotation tagAnn : contTagAS.inDocumentOrder())
{
  FeatureMap lookupFeatures  = tagAnn.getFeatures();
  String tag = lookupFeatures.get("type").toString();
  joiner.add(tag);
}

outputAS.add(
    spanAs.firstNode(), 
    spanAs.lastNode(), 
    "new annotation", 
    featureMap("tags", joiner.toString())
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM