How to parse languages other than English with Stanford Parser? in java, not command lines

后端 未结 1 1935
长发绾君心
长发绾君心 2021-01-15 20:28

I have been trying to use Stanford Parser in my Java program to parse some sentences in Chinese. Since I am quite new at both Java and Stanford Parser, I used the \'ParseDem

1条回答
  •  时光说笑
    2021-01-15 20:58

    The problem is that the GrammaticalStructureFactory is constructed from a PennTreebankLanguagePack, which is for the English Penn Treebank. You need to use (in two places)

    TreebankLanguagePack tlp = new ChineseTreebankLanguagePack();
    

    and to import this appropriately

    import edu.stanford.nlp.trees.international.pennchinese.ChineseTreebankLanguagePack;
    

    But we also generally recommend using the factored parser for Chinese (since it works considerably better, unlike for English, although at the cost of more memory and time usage)

    LexicalizedParser lp = LexicalizedParser.loadModel("edu/stanford/nlp/models/lexparser/chineseFactored.ser.gz");
    

    0 讨论(0)
提交回复
热议问题