문제

I am a NLP student and relatively new to Stanford CoreNLP. I wanted to try PCFG parser for my sentence because I wanted to get the probability score for the best parse tree the parser fetches. I was able to successfully use LexicalizedParser as

    LexicalizedParser myParser = LexicalizedParser.loadModel();
    myParser.parse(tokenLabels); // where List<CoreLabel> tokenLabels

But I don't see any loadModel method for ExhaustivePCFGParser so am confused as to how to initialize and start using parse function for it. I can see the constructor defined for it but have no idea what the parameters means ? Could you please provide some guidance for this.

도움이 되었습니까?

해결책

You almost certainly still want to work by using a LexicalizedParser. From that you can get a ParserQuery object (just as the parse(List<? extends HasWord> lst) method of LexicalizedParser does) and then operate with it:

ParserQuery pq = myParser.parserQuery();
if (pq.parse(tokenLabels)) {
    System.out.println("Viterbi probability  is " + pq.getPCFGScore());
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top