将 GATE 特征导入 csv

Import GATE features to csv

我是 GATE Developer 的新手。我想使用 GATE 管道生成的注释作为分类器的特征。如何将这些功能保存到 csv 文件中?

在此处查看第一个示例:https://gate.ac.uk/wiki/groovy-recipes/

最简单的方法是使用 groovy 脚本 PR,它遍历所有注释并在需要的地方和需要的地方写入。这是 wiki 中脚本的稍微简化的版本:

new File("./outfile.txt").withWriterAppend{ out ->
  doc.getAnnotations().each {anno ->
      if( anno.getFeatures() )
        anno.getFeatures().each{ fName, fValue ->
          out.writeLine(/"${doc.getName()}","${anno.getType()}","${doc.stringFor(anno)}",${anno.start()},${anno.end()},"${fName}","${fValue}"/)
        }
      else
        out.writeLine(/"${doc.getName()}","${anno.getType()}","${doc.stringFor(anno)}",${anno.start()},${anno.end()},,/)        
    }
}

它仅以某种 csv 格式导出默认注释集中的注释。 outfile.txt 将在您的 gate_home 文件夹中。