How can I split a text or paragraph into sentences using Stanford parser?
Is there any method that can extract sentences, such as getSentencesFromString()
With the Simple API provided by Stanford CoreNLP version 3.6.0 or 3.7.0.
Here's an example with 3.6.0. It works exactly the same with 3.7.0.
Java Code Snippet
import java.util.List;
import edu.stanford.nlp.simple.Document;
import edu.stanford.nlp.simple.Sentence;
public class TestSplitSentences {
public static void main(String[] args) {
Document doc = new Document("The text paragraph. Another sentence. Yet another sentence.");
List sentences = doc.sentences();
sentences.stream().forEach(System.out::println);
}
}
Yields:
The text paragraph.
Another sentence.
Yet another sentence.
pom.xml
4.0.0
stanfordcorenlp
stanfordcorenlp
1.0-SNAPSHOT
1.8
1.8
edu.stanford.nlp
stanford-corenlp
3.6.0
com.google.protobuf
protobuf-java
2.6.1