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

后端 未结 3 1682
醉话见心
醉话见心 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:13

    Will continue from your code itself . This program block will provide all the noun phrases in sentence. Use getTagNodes() method to get Tokens and its types

    Parse topParses[] = ParserTool.parseLine(line, parser, 1);
    Parse words[]=null; //an array to store the tokens
    //Loop thorugh to get the tag nodes
    for (Parse nodes : topParses){
            words=nodes.getTagNodes(); // we will get a list of nodes
    }
    
    for(Parse word:words){
    //Change the types according to your desired types
        if(word.getType().equals("NN") || word.getType().equals("NNP") || word.getType().equals("NNS")){
                System.out.println(word);
                }
            }
    

提交回复
热议问题