2017-09-04 1 views
0

ではUnsupportedOperationExceptionを得るのですか私はStanford CoreNLPTreeから各フレーズ(成分)の頭語を検索したいのですが、私はconstituentsのいずれかのtree.Parent()をしようとしたとき、私はUnsupportedOperationExceptionを取得します。私は間違って何をしていますか?ここでは、なぜ私はスタンフォードCoreNLP

は私のコードです:私はparseTree.subTreeList()のサイズとして13を得る

Your tasks are challenging: 

、それらのすべてのために、私が取得:ここ

List<Tree> allConstituents = new ArrayList<>(); 
    private Tree parseTree; 

    List<CoreMap> sentences = LoadAndParse(language, filetype, modelPath, text); 

      for (CoreMap sentence : sentences) { 
       Tree parse = sentence.get(TreeAnnotation.class); 
       allConstituents = parseTree.subTreeList(); 

      for (int i = 0; i < allConstituents.size(); i++) { 
        Tree constituentTree = allConstituents.get(i); 
        HeadFinder headFinder = new SemanticHeadFinder(); 
        String head = constituentTree.headTerminal(headFinder, constituentTree.parent()); 

       } 
       } 

は、私が持っている例です。方法はconstituentTree.parent()UnsupportedOperationExceptionである。誰もが、ツリー内の「すべての」構成要素のセマンティック・ヘッドを得る正しい方法は何ですか?

+0

この問題は、そのタイプの親メソッドは実装されていないようです。スタンフォードCoreNLPに関する文書はありますか? – Stultuske

答えて

0

私はそれが本当にすべてのために働くの答えであるかどうかわからないんだけど、私の場合には、それは参考になりました:

は、すべての成分のための第2の入力として文全体を含むTreeメインを使用します。つまり:

   String head = constituentTree.headTerminal(headFinder, parseTree); 
関連する問題