2017-08-29 5 views
0

私のプロジェクトにcoreNLPの依存解析を使用しています。基本的な依存関係と強化された依存関係は、特定の依存関係では異なる結果になります。 次のコードを使用して、依存関係を強化しました。次たとえばStandford coreNLPで基本と拡張の依存関係が異なる結果

val lp = LexicalizedParser.loadModel("edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz") 
lp.setOptionFlags("-maxLength", "80") 
val rawWords = edu.stanford.nlp.ling.Sentence.toCoreLabelList(tokens_arr:_*) 
val parse = lp.apply(rawWords) 
val tlp = new PennTreebankLanguagePack() 
val gsf:GrammaticalStructureFactory = tlp.grammaticalStructureFactory() 
val gs:GrammaticalStructure = gsf.newGrammaticalStructure(parse) 
val tdl = gs.typedDependenciesCCprocessed() 

Account name of ramkumar. 

私は基本的な依存関係を取得するには、単純なAPIを使用します。依存関係は (アカウント、名前)の間に(化合物)です。しかし、上記のコードを使用して依存関係を強化すると、(アカウント、名前)と(dobj)の関係が得られます。

これに対する修正は何ですか?これはバグですか、何か間違っていますか?

答えて

0

私は、このコマンドを実行すると:ファイルexample.txtであなたの例のテキストでは

java -Xmx8g edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner,parse -file example.txt -outputFormat json 

を、私は依存関係の両方のタイプのためにそれらの単語の両方との間の関係としてcompoundを参照してください。

私はsimple APIでこれを試しても同じ結果が得られました。

あなたはsimpleは、このコードを生成ものを見ることができます。

package edu.stanford.nlp.examples; 

import edu.stanford.nlp.semgraph.SemanticGraphFactory; 
import edu.stanford.nlp.simple.*; 

import java.util.*; 

public class SimpleDepParserExample { 

    public static void main(String[] args) { 
    Sentence sent = new Sentence("...example text..."); 
    Properties props = new Properties(); 
    // use sent.dependencyGraph() or sent.dependencyGraph(props, SemanticGraphFactory.Mode.ENHANCED) to see enhanced dependencies 
    System.out.println(sent.dependencyGraph(props, SemanticGraphFactory.Mode.BASIC)); 
    } 

} 

私はスタンフォードCoreNLPのための任意のScalaのインターフェイスについては何も知りません。 Stanford CoreNLP 3.8.0でも同様の結果が得られると推測していますが、私の結果はGitHubの最新コードを使用しています。 Stanford CoreNLPの古いバージョンを使用している場合は、エラーの原因となる可能性があります。

しかし、Javaを使用してさまざまな方法でこの例を実行しても、私はあなたが遭遇している問題は表示されません。

関連する問題