How to extract the noun phrases using Open nlp's chunking parser

后端 未结 3 1685
醉话见心
醉话见心 2020-12-06 01:48

I am newbie to Natural Language processing.I need to extract the noun phrases from the text.So far i have used open nlp\'s chunking parser for parsing my text to get the Tre

3条回答
  •  醉话见心
    2020-12-06 02:23

    The Parse object is a tree; you can use getParent() and getChildren() and getType() to navigate the tree.

    List nounPhrases;
    
    public void getNounPhrases(Parse p) {
        if (p.getType().equals("NP")) {
             nounPhrases.add(p);
        }
        for (Parse child : p.getChildren()) {
             getNounPhrases(child);
        }
    }
    

提交回复
热议问题