java - GATE 根据查询注解 ON TOKEN 对句子进行注解
问题描述
我正在使用 GATE 8.5,在执行标记器和句子拆分器之后,我执行我的地名词典匹配以获取一些标记上的查找注释,现在我想搜索那些具有查找注释的标记,以通过一些注释来注释包含这些标记的句子,我尝试类似:
Iterator sentenceIterator =
inputAnnSet.get(ANNIEConstants.SENTENCE_ANNOTATION_TYPE).iterator(),
tokenIterator;
while(sentenceIterator.hasNext())
{Annotation sentenceAnnotation =
(Annotation)sentenceIterator.next();
tokenIterator = doc.getAnnotations().get("Lookup").iterator();
while(tokenIterator.hasNext())
{ Annotation tokenAnnotation = (Annotation)tokenIterator.next();
if(tokenAnnotation.getFeatures().get("majorType").equals("mytype") )
{
sentenceAnnotation.getFeatures().put(new
String("SentenceType"),
new String(doc.getContent().getContent(tokenAnnotation.getStartNode().getOffset(),
tokenAnnotation.getEndNode().getOffset()).toString()));
问候
解决方案
我认为您的代码将无法正常工作。您只需要查看特定句子中包含的标记:
AnnotationSet lookupAnnotations = doc.getAnnotations().get("Lookup");
for ( Annotation sentenceAnnotation : inputAnnSet.get(ANNIEConstants.SENTENCE_ANNOTATION_TYPE)) {
for ( Annotation tokenAnnotation : gate.Utils.getContainedAnnotations(
lookupAnnotations, sentenceAnnotation))
{
Object majorType = tokenAnnotation.getFeatures().get("majorType");
if (majorType != null && majorType.equals("mytype")) {
sentenceAnnotation.getFeatures().put(
"SentenceType", gate.Utils.stringFor(doc, tokenAnnotation));
break; //move to next sentence, this one is finished
}
}
}
推荐阅读
- protractor - 当我在量角器的 console.log 中执行 getText 时出现 ElementFinder 错误
- oracle - 通过在 Oracle Apex 中创建视图将 cols 转换为 oracle 中的行
- reactjs - 具有特定日期列的可排序反应材料 UI 表
- interop - FHIR 互操作性平台选择
- c++ - Qt5中如何比较两个中文字符串?
- java - 关于使用 UDP 将 mp3 文件从客户端上传到服务器
- c# - 如何通过单击按钮启动倒数计时器事件?
- ios - 配置文件即将过期
- database - 由于 Oracle DB 从 12c 升级到 19c,对现有 SQL、PL/SQL 脚本和数据模型有何影响?
- python - 错误/警告 *** MULE MSG QUEUE 已满:缓冲区大小 212992 字节(您可以使用 --mule-msg-size 调整它)***