Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在java中嵌入jape规则(门)_Java_Nlp_Information Extraction_Gate - Fatal编程技术网

在java中嵌入jape规则(门)

在java中嵌入jape规则(门),java,nlp,information-extraction,gate,Java,Nlp,Information Extraction,Gate,我正在尝试编写自己的规则,在我的java代码中注释Author(来自Author,jape)。我已初始化了新的处理资源。代码运行良好,但不注释ma文本: 输入:谁是xyz的作者 输出:它应该被注释为author,shd将书的名称保存在某个临时变量中。 我的java代码: Gate.init(); Gate.getCreoleRegister().registerDirectories( new File(Gate.getPluginsHome(), "ANNIE")

我正在尝试编写自己的规则,在我的java代码中注释Author(来自Author,jape)。我已初始化了新的处理资源。代码运行良好,但不注释ma文本: 输入:谁是xyz的作者 输出:它应该被注释为author,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());
在输出中,它只提供令牌、空间令牌
有人能帮我解决这个问题吗?

问题在于你的日语语法,而不是Java代码。Java代码可以很好地使用以下JAPE语法:


阶段:测试1
输入:令牌
选项:control=appelt
规则:testRule
({Token.kind==“word”}{Token.kind==“word”}):注释
-->:annotate.twoords=
{string=:annotate.Token.string}

输出为:


找到以下类型的批注:[SpaceToken,TwoWords,Token]

如果你能提供你的日语语法,我会说更多关于你的问题


或者,您可以在GateDeveloper中使用JAPE语法,直到它开始匹配您想要的内容。在此之后,Java程序将正常工作。

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

doc.getAnnotations().get("Name of the annotations which you want to get");

当您在GUI中使用相同的日语语法时,它是否有效?如果是这样,请尝试从那里保存已知的工作应用程序状态,并使用
PersistenceManager
将其加载到嵌入的代码中,这可能比尝试手动编写代码来构建管道更容易。谢谢您的回复,先生。!我没有用这个,而是用了AnnietTransducer。我使用了下面的初始化,它起了作用:if(“gate.creole.annietTransducer”.equals(ANNIEConstants.PR_NAMES[I]){File temp_value=new File(“E:\\gate_Developer_7.1\\plugins\\ANNIE\\resources\\NE”);URL temp_URL=temp_value.tour();params1.put(“grammarul”,temp_URL);params1.put(“编码”,“UTF-8”);pr=(ProcessingResource)gate.Factory.createResource(ANNIEConstants.pr_NAMES[i],params);}不,先生,语法与GUI配合得非常好,而且我还解决了与java代码相关的问题。