在 GATE 中添加所有包含注释的列表作为新注释的特征

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

我正在尝试使用 Java RHS 规则添加所有包含 "all_tags" 注释的列表作为新注释的特征。

下面只加一个注解,不加一列:

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

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

我希望每个 all_tags "type" 添加为以逗号分隔的特征,即 "type 1, type 2, type 3"

我试过列表注释类但找不到正确的方法。

非常感谢

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())
);