2016-12-03 1 views

답변

0

설명이 정확하지 않기 때문에 질문을 올바르게 해석 할 수 있을지 잘 모르겠습니다. Corenlp가 어떤 토큰 화 작업을 수행하지 않고도 구문 분석기에 토큰 목록을 제공하려는 것 같습니다. 그렇다면 사용중인 파서를 아는 것이 유용 할 것입니다. 하지만 두 가지 모두를 사용하면 토큰 목록에 피드를 제공 할 수 있으며 corenlp는 토큰 화에 뛰어 들지 않습니다. , 기록 된 표준 에러 라인을 삭제

String sentence = "I can't do that ."; 
    ArrayList<HasWord> hwl = new ArrayList<HasWord>(); 
    String[] tokens = sentence.split(" "); 
    for (String t : tokens){ 
    HasWord hw = new Word(); 
    hw.setWord(t); 
    hwl.add(hw); 
    } 
    LexicalizedParser lexParser = LexicalizedParser.loadModel("<path to chinese lex parsing here>","-maxLength", "70"); 
    Tree cTree = lexParser.parse(hwl); 
    System.out.println("c tree:" + cTree); 


    DependencyParser parser = DependencyParser.loadFromModelFile("<chinese model for dep parsing here>"); 
    MaxentTagger tagger = new MaxentTagger("<path to your tagger file goes here"); 
    List<TaggedWord> tagged = tagger.tagSentence(hwl); 
    GrammaticalStructure gs = parser.predict(tagged); 
    System.out.println("dep tree:" + gs.typedDependencies()); 

: (공백 적절한 tokenisation의 결과에 이전에 이미 tokenisation했을 경우, 및 분할) 나는 중국어 자원 근무 한 적이없는,하지만, 다음은 당신을 도울 수 그 결과는 다음과 같습니다.

c tree:(ROOT (S (MPN (FM I) (FM can't)) (VVFIN do) (ADJD that) ($. .))) 
dep tree:[nsubj(can't-2, I-1), root(ROOT-0, can't-2), xcomp(can't-2, do-3), dobj(do-3, that-4), punct(can't-2, .-5)] 

희망이 도움이 될 것입니다.

+0

위대한 답변이지만 커맨드 라인 명령을 사용하여 방금 문제를 해결했습니다 :'java -Xmx2g -cp "../parsing/*"edu.stanford.nlp.parser.lexparser.LexicalizedParser -sentences newline -outputFormat typedDependencies ../parsing/xinhuaFactored.ser.gz ./cpbdev.out> cpbdev.out.parsing' –

+0

그리고 나는 그 API에 정말 어려움을 느낍니다. 어떻게 배웠습니까? javadoc을 읽는가? –

+0

아 그래, 커맨드 라인에서 사용하고있어, 더 의미가 있습니다. 일반적으로, 나는 corenlp의 API가 꽤 잘 문서화되어 있다고 생각하지만, 숨겨진 것들이 있습니다. 그냥 그걸 가지고 노는 것은 항상 이해하는 데 도움이됩니다. – Igor

관련 문제