ルールベースのエンティティ抽出にTokensRegexを使用しています。それはうまく動作しますが、私は希望のフォーマットで出力を得ることができません。次のコードスニペットは、私の文章については、以下を指定された出力できます:TokenRegexを使用して目的の形式で出力を取得する
Earlier this month Trump targeted Toyota, threatening to impose a hefty fee on the world's largest automaker if it builds its Corolla cars for the U.S. market at a plant in Mexico.
for (CoreMap sentence : sentences)
{
List<MatchedExpression> matched = extractor.extractExpressions(sentence);
if (matched != null) {
matched = MatchedExpression.removeNested(matched);
matched = MatchedExpression.removeNullValues(matched);
System.out.print("FOR SENTENCE:" + sentence);
}
for(MatchedExpression phrase : matched){
// Print out matched text and value
System.out.print("MATCHED ENTITY: " + phrase.getText()+ "\t" + "VALUE: " + phrase.getValue());
OUTPUTを
MATCHED ENTITY: Donald Trump targeted Toyota, threatening to impose a hefty fee on the world's largest automaker if it builds its Corolla cars for the U.S. market
VALUE: LIST([PERSON])
私が使用してトークンを反復処理する場合、私が知っている:
for (CoreLabel token : cm.get(TokensAnnotation.class))
{String word = token.get(TextAnnotation.class);
String lemma = token.get(LemmaAnnotation.class);
String pos = token.get(PartOfSpeechAnnotation.class);
String ne = token.get(NamedEntityTagAnnotation.class);
System.out.println("matched token: " + "word="+word + ", lemma="+lemma + ", pos=" + pos + ", NE=" + ne);
}
私は各タグに注釈を与える出力を得ることができます。しかし、私は自分のルールを使って名前付きエンティティを検出していますが、時には、複数のトークンエンティティで1つの単語が人物としてタグ付けされる場合があります。組織と場所の名前)
だから私は期待していた出力は次のようになります。
MATCHED ENTITY: Donald Trump VALUE: PERSON
MATCHED ENTITY: Toyota VALUE: ORGANIZATION
にはどうすれば所望の出力を得るために上記のコードを変更できますか?カスタムアノテーションを使用する必要がありますか?
「スレッドで例外が発生しました」「main」java.lang.RuntimeException:ファイル解析中にエラーが発生しました:multi-step-per-org.rules「」原因:java.io.IOException:「multi -step-per-org.rules "をクラスパス、ファイル名、またはURLとして使用する"ビルドでこのファイルが見つかりません。助けてください。 – serendipity
これは私のrulesファイルの名前です。ルールファイルの名前で置き換える必要があります。 – StanfordNLPHelp