2

新しい処理リソースを初期化した Java コードで Author (From author,jape) に注釈を付ける独自のルールを作成しようとしています。コードは正常に実行されますが、ma に注釈を付けません。著者として注釈を付け、書籍の名前を一時変数に保存する必要があります。私の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());

出力では、トークン、スペーストークンのみを提供します誰でも問題を解決するのを手伝ってくれますか?

4

2 に答える 2

1

問題は Java コードではなく、JAPE 文法にあります。Java コードは、次の JAPE 文法で正常に動作します。

Phase: Test1 Input: Token Options: control = appelt Rule: testRule ( {Token.kind == "word"} {Token.kind == "word"}):annotate --> :annotate.TwoWords = { string = :annotate.Token.string }

出力は次のとおりです。

Found annotations of the following types: [SpaceToken, TwoWords, Token]

JAPE 文法を提供していただければ、問題について詳しく説明します。

または、GATE Developer で JAPE 文法を試して、必要なものに一致するようにすることもできます。この後、Java プログラムは問題なく動作します。

于 2014-03-10T13:10:57.013 に答える
1

ここで、注釈に付けた名前を使用できます。したがって、この方法を使用できます。

doc.getAnnotations().get("Name of the annotations which you want to get");
于 2016-08-05T05:55:10.087 に答える