首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在java中嵌入jape规则(Gate)

在java中嵌入jape规则(Gate)
EN

Stack Overflow用户
提问于 2014-03-10 14:06:59
回答 1查看 1.4K关注 0票数 2

我正在尝试编写自己的规则来注释我的java代码中的作者(来自author,jape)我已经初始化了新的处理resource.The代码,运行得很好,但没有注释ma text: input: who is the Author of xyz output:它应该被注释为author,并将图书的名称保存在某个临时变量中。我的java代码:

代码语言:javascript
复制
    Gate.init();
Gate.getCreoleRegister().registerDirectories(
           new File(Gate.getPluginsHome(), "ANNIE").toURI().toURL());
SerialAnalyserController pipeline =
          (SerialAnalyserController)gate.Factory.createResource(
             "gate.creole.SerialAnalyserController");
LanguageAnalyser tokeniser = (LanguageAnalyser)gate.Factory.createResource(
             "gate.creole.tokeniser.DefaultTokeniser");
LanguageAnalyser jape = (LanguageAnalyser)gate.Factory.createResource(
          "gate.creole.Transducer", gate.Utils.featureMap(
              "grammarURL", new File("E:\\GATE_Developer_7.1\\plugins\\ANNIE\\resources\\NE\\Author.jape").toURI().toURL(),
              "encoding", "UTF-8"));
pipeline.add(tokeniser);
pipeline.add(jape);
Corpus corpus = gate.Factory.newCorpus(null);
Document doc = gate.Factory.newDocument("Who is author of Inception");
DocumentContent dc=doc.getContent();        
corpus.add(doc);
pipeline.setCorpus(corpus);
pipeline.execute();
System.out.println("Found annotations of the following types: " +
          doc.getAnnotations().getAllTypes());

在输出中它只给出令牌,空格令牌有人能帮我解决这个问题吗?

EN

回答 1

Stack Overflow用户

发布于 2016-08-05 13:55:10

这里是您为注释指定的名称,您可以使用它。因此,您可以使用此方法。

代码语言:javascript
复制
doc.getAnnotations().get("Name of the annotations which you want to get");
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22293143

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档