2017-09-04 3 views
0

로 UnsupportedOperationException를받을 수 있나요 나는 Stanford CoreNLPTree 각 구 (구성)의 머리 단어를 찾기 위해 싶지만, 내가 constituents 중 어떤 tree.Parent()을하려고 할 때, 나는 UnsupportedOperationException를 얻을. 내가 도대체 ​​뭘 잘못하고있는 겁니까? 여기 왜 스탠포드 CoreNLP

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()); 

       } 
       } 

내가 가진 예는 다음과 같습니다 :

Your tasks are challenging: 

내가 parseTree.subTreeList()의 크기 (13)를 얻을 수 있지만, 그들 모두를 위해, 나는 얻을 여기

내 코드입니다 constituentTree.parent() 방법상의 UnsupportedOperationException. 누구든지 트리의 "모든"구성 요소의 의미 론적 머리를 얻는 올바른 방법은 무엇인지 나를 도울 수 있습니까? 정말 모두를 위해 작동하는 대답 인 경우

+0

문제는 상위 메소드가 해당 유형으로 구현되지 않은 것으로 보입니다. 스탠포드 CoreNLP에 관한 문서가 있습니까? – Stultuske

답변

0

는 잘 모르겠지만, 내 경우는 도움이되었다 :

사용하는 모든 구성 요소에 대한 두 번째 입력으로 전체 문장을 포함하는 주요 Tree; 즉 :

   String head = constituentTree.headTerminal(headFinder, parseTree); 
관련 문제