How can I split a text into sentences using the Stanford parser?

后端 未结 12 1907
终归单人心
终归单人心 2020-11-27 14:52

How can I split a text or paragraph into sentences using Stanford parser?

Is there any method that can extract sentences, such as getSentencesFromString()

12条回答
  •  北海茫月
    2020-11-27 15:41

    You can pretty easy use Stanford tagger for this.

    String text = new String("Your text....");  //Your own text.
    List> tokenizedSentences = MaxentTagger.tokenizeText(new StringReader(text));
    
    for(List act : tokenizedSentences)       //Travel trough sentences
    {
        System.out.println(edu.stanford.nlp.ling.Sentence.listToString(act)); //This is your sentence
    }
    

提交回复
热议问题