ありがとう。ペア番号)(CorefChain#のtoStringのoutoutです:
位置は(彼らは
CorefChain.getCorefMentions()
を使用取得するために)言及するエンティティのpostionペアのセットです
public String toString(){
return position.toString();
}
。ここでは位置からトークンを取得する方法を示しています(groovyで)完全なコードの例です。
class Example {
public static void main(String[] args) {
Properties props = new Properties();
props.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
props.put("dcoref.score", true);
pipeline = new StanfordCoreNLP(props);
Annotation document = new Annotation("The atom is a basic unit of matter, it consists of a dense central nucleus surrounded by a cloud of negatively charged electrons.");
pipeline.annotate(document);
Map<Integer, CorefChain> graph = document.get(CorefChainAnnotation.class);
println aText
for(Map.Entry<Integer, CorefChain> entry : graph) {
CorefChain c = entry.getValue();
println "ClusterId: " + entry.getKey();
CorefMention cm = c.getRepresentativeMention();
println "Representative Mention: " + aText.subSequence(cm.startIndex, cm.endIndex);
List<CorefMention> cms = c.getCorefMentions();
println "Mentions: ";
cms.each { it ->
print aText.subSequence(it.startIndex, it.endIndex) + "|";
}
}
}
}
出力は(「s」はどこから来るのか私は理解していない):
The atom is a basic unit of matter, it consists of a dense central nucleus surrounded by a cloud of negatively charged electrons.
ClusterId: 1
Representative Mention: he
Mentions: he|atom |s|
ClusterId: 6
Representative Mention: basic unit
Mentions: basic unit |
ClusterId: 8
Representative Mention: unit
Mentions: unit |
ClusterId: 10
Representative Mention: it
Mentions: it |
ps。私はデフォルトの設定(モデル)があなたのドメインで動作するとは思わない。スタンフォードコアnlpは、ニュース、記事などからセマンティックを抽出するのに適しているようです。例えば、スタンフォードNER(コアNLPの一部)は、CoNLL 2002および2003コーパスで訓練され、精巣を鍛えられました。 – Skarab
このアルゴリズムは部分的に便利で、適切なアルゴリズムに導かれましたが、ここでの出力は文に適していません。文中に "he"がなく、 "s"と "it"コアリファレンス分解のポイント。 – user1084563
'startIndex'と' endIndex'を文字インデックス(0ベース)のように見なしていますが、それらはトークンインデックス(1ベース)です。また、あなたは 'aText'を定義しませんでした。アノテーションのテキストを "he"(文字1と2)ではなく "アトム"(単語1と2)などにする必要があると仮定します。 –