어떻게 온라인 데모에서 볼 수 있듯이 stanford corenlp를 사용하여 프로그래밍 방식으로 동일한 종속성 구문을 구할 수 있습니까?의존성 분석 출력을 온라인 데모처럼 정확하게 얻으려면 어떻게해야합니까?
corenlp 패키지를 사용하여 다음 문장에 대한 종속성 구문 분석을 얻고 있습니다.
텍사스에서 2 번째 건강 관리 종사자가 에볼라에 양성 반응을 보인다고 당국이 밝혔습니다.
내가 프로그래밍 나는 스탠포드 corenlp에게 3.5.0 패키지를 사용하여 다음과 같은 출력을 얻을
Properties props = new Properties();
props.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
String text = "Second healthcare worker in Texas tests positive for Ebola , authorities say ."; // Add your text here!
Annotation document = new Annotation(text);
pipeline.annotate(document);
String[] myStringArray = {"SentencesAnnotation"};
List<CoreMap> sentences = document.get(SentencesAnnotation.class);
for(CoreMap sentence: sentences) {
SemanticGraph dependencies = sentence.get(BasicDependenciesAnnotation.class);
IndexedWord root = dependencies.getFirstRoot();
System.out.printf("root(ROOT-0, %s-%d)%n", root.word(), root.index());
for (SemanticGraphEdge e : dependencies.edgeIterable()) {
System.out.printf ("%s(%s-%d, %s-%d)%n", e.getRelation().toString(), e.getGovernor().word(), e.getGovernor().index(), e.getDependent().word(), e.getDependent().index());
}
}
}
아래의 코드를 사용하여 구문 분석을 얻으려고.
root(ROOT-0, worker-3)
amod(worker-3, Second-1)
nn(worker-3, healthcare-2)
prep(worker-3, in-4)
amod(worker-3, positive-7)
dep(worker-3, say-12)
pobj(in-4, tests-6)
nn(tests-6, Texas-5)
prep(positive-7, for-8)
pobj(for-8, ebola-9)
nsubj(say-12, authorities-11)
온라인 데모에서는 루트로 말하면서 구문 분석의 단어 사이에 ccomp와 같은 다른 관계가있는 다른 대답을 제공합니다.
amod(worker-3, Second-1)
nn(worker-3, healthcare-2)
nsubj(tests-6, worker-3)
prep(worker-3, in-4)
pobj(in-4, Texas-5)
ccomp(say-12, tests-6)
acomp(tests-6, positive-7)
prep(positive-7, for-8)
pobj(for-8, Ebola-9)
nsubj(say-12, authorities-11)
root(ROOT-0, say-12)
출력물을 온라인 데모와 일치하도록 어떻게 해결합니까?
나는 파서가 결정 론적이라고 믿는다. 온라인 데모와 동일한 버전의 CoreNLP를 실행하고 동일한 모델을 사용하고 있는지 확인하십시오. 스탠포드 팀에 이메일을 보내야하고 웹 사이트에서 실행중인 버전/모델을 물어볼 수도 있습니다. 실제로 언급했는지는 확실하지 않습니다. – mbatchkarov