【发布时间】:2014-03-10 06:06:58
【问题描述】:
我正在尝试编写自己的规则,在我的 java 代码中注释作者(来自作者,jape)我已经初始化了我的新处理资源。代码运行良好,但没有注释 ma 文本: 输入:谁是xyz的作者 输出:它应该被注释为作者并且 shd 将书名保存在一些临时变量中。 我的java代码:
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());
在输出中它只给出令牌,空格令牌 谁能帮我解决这个问题。?
【问题讨论】:
-
在 GUI 中使用相同的 JAPE 语法是否有效?如果是这样,请尝试从那里保存已知工作的应用程序状态并使用
PersistenceManager将其加载到您的嵌入式代码中,这可能比尝试在代码中手动构建管道更容易。 -
感谢您的回复先生。!我没有使用这个,而是使用了 annieTransducer。我使用以下方法进行初始化,它起作用了: if("gate.creole.ANNIETransducer".equals(ANNIEConstants.PR_NAMES[i])) { File temp_value= new File("E:\\GATE_Developer_7.1\\plugins\\安妮\\资源\\NE"); URL temp_url =temp_value.toURL(); params1.put("grammarURL",temp_url); params1.put("编码", "UTF-8"); pr = ( ProcessingResource) gate.Factory 。 createResource (ANNIEConstants . PR_NAMES [i],params ); }
标签: java nlp information-extraction gate