谁能指导我如何创建一个自定义JAPE文件并使用 GATE 源代码对其进行配置。我尝试使用以下代码并获得诸如“解析语法时出错:”和“未设置语法 URL 或 binaryGrammarURL 参数!”之类的异常。
try{
Document doc = new DocumentImpl();
String str = "This is test.";
DocumentContentImpl impl = new DocumentContentImpl(str);
doc.setContent(impl);
System.setProperty("gate.home", "C:\\Program Files\\GATE_Developer_7.1");
Gate.init();
gate.Corpus corpus = (Corpus) Factory
.createResource("gate.corpora.CorpusImpl");
File gateHome = Gate.getGateHome();
File pluginsHome = new File(gateHome, "plugins");
Gate.getCreoleRegister().registerDirectories(new File(pluginsHome, "ANNIE").toURI().toURL());
Transducer transducer = new Transducer();
transducer.setDocument(doc);
transducer.setGrammarURL(new URL("file:///D:/misc_workspace/gate-7.1-build4485-SRC/plugins/ANNIE/resources/NE/SportsCategory.jape"));
transducer.setBinaryGrammarURL(new URL("file:///D:/misc_workspace/gate-7.1-build4485-SRC/plugins/ANNIE/resources/NE/SportsCategory.jape"));
LanguageAnalyser jape = (LanguageAnalyser)Factory.createResource(
"gate.creole.Transducer", gate.Utils.featureMap(
"grammarURL", "D:/misc_workspace/gate-7.1-build4485-SRC/plugins/ANNIE/resources/NE/SportsCategory.jape",
"encoding", "UTF-8"));