1
私は、コアライブラリとその周りの単純ラッパーの両方を使ってみましたが、どちらも同じ簡単な文章では三つ組を見つけられませんでした。Stanford NLP OpenIEがいくつかの文章でトリプルを特定できない
単純なラッパーコード:
for (final Quadruple<String, String, String, Double> tripple : sentence.openie()) {
System.out.println(tripple);
}
とコアライブラリのコードはtheir own example usageです:
package edu.stanford.nlp.naturalli;
import edu.stanford.nlp.ie.util.RelationTriple;
import edu.stanford.nlp.io.IOUtils;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.semgraph.SemanticGraph;
import edu.stanford.nlp.semgraph.SemanticGraphCoreAnnotations;
import edu.stanford.nlp.util.CoreMap;
import edu.stanford.nlp.util.PropertiesUtils;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
/**
* A demo illustrating how to call the OpenIE system programmatically.
*/
public class OpenIEDemo {
private OpenIEDemo() {} // static main
public static void main(String[] args) throws Exception {
// Create the Stanford CoreNLP pipeline
Properties props = PropertiesUtils.asProperties(
"annotators", "tokenize,ssplit,pos,lemma,depparse,natlog,openie"
// , "depparse.model", "edu/stanford/nlp/models/parser/nndep/english_SD.gz"
// "annotators", "tokenize,ssplit,pos,lemma,parse,natlog,openie"
// , "parse.originalDependencies", "true"
);
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
// Annotate an example document.
String text;
if (args.length > 0) {
text = IOUtils.slurpFile(args[0]);
} else {
text = "Obama was born in Hawaii. He is our president.";
}
Annotation doc = new Annotation(text);
pipeline.annotate(doc);
// Loop over sentences in the document
int sentNo = 0;
for (CoreMap sentence : doc.get(CoreAnnotations.SentencesAnnotation.class)) {
System.out.println("Sentence #" + ++sentNo + ": " + sentence.get(CoreAnnotations.TextAnnotation.class));
// Print SemanticGraph
System.out.println(sentence.get(SemanticGraphCoreAnnotations.EnhancedDependenciesAnnotation.class).toString(SemanticGraph.OutputFormat.LIST));
// Get the OpenIE triples for the sentence
Collection<RelationTriple> triples = sentence.get(NaturalLogicAnnotations.RelationTriplesAnnotation.class);
// Print the triples
for (RelationTriple triple : triples) {
System.out.println(triple.confidence + "\t" +
triple.subjectLemmaGloss() + "\t" +
triple.relationLemmaGloss() + "\t" +
triple.objectLemmaGloss());
}
// Alternately, to only run e.g., the clause splitter:
List<SentenceFragment> clauses = new OpenIE(props).clausesInSentence(sentence);
for (SentenceFragment clause : clauses) {
System.out.println(clause.parseTree.toString(SemanticGraph.OutputFormat.LIST));
}
System.out.println();
}
}
}
どちらの方法は、トリプルが同じ試験に合格し、失敗を見つける:
The cat jumped over the fence.: (cat,jumped over,fence,1.0)
The brown dog barked.: FAIL
The apple was eaten by John.: (apple,was eaten by,John,1.0)
Joe ate the ripe apple.: (Joe,ate,ripe apple,1.0)
They named their daughter Natasha.: (They,named,their daughter Natasha,1.0)
Bob sold me her boat.: FAIL
Grandfather left Rosalita and Raoul all his money.: FAIL
Who killed the cat?: FAIL
How many astronauts have walked on the moon?: (astronauts,have walked on,moon,1.0)
返されるコレクションが失敗した場合は空です。
誰もが似たような問題を抱えていますか?
どのようなトリプルの文に期待していますか?茶色の犬は吠えましたか?_、直接のオブジェクトが欠けています。そして、私は誰があなたのためにどんなトリプルを期待するのかもよくわかりません。 _ボブは私のボートを売った_私のために働くが、それはまた間違ったトリプル '(ボブ、売却、私)'を返します。 –
@SebastianSchuster _茶色の犬は吠えた_私はそれが何を見つけることができるかを返すと予想した。被験者は犬であり関係は吠えているが、3つをすべて見つけることができなければ何も返さないと思うだろう。私は誰が被害者であるかというと、誰が誰を殺したのか(誰が殺されたのか、誰が殺されたのか、猫)を仮定した。なぜボブが私のボートを私に売ってもらうことができたのか分かりません。どのモデルを使用していますか? – 64test1234