I was wondering how I can find the start and end position of a sentence in a paragraph using StanfordCoreNLP. Right now I am using DocumentPreprocessor to split the paragraph into sentences. Is it possible to get the start and end index of where the sentence is actually located in the original text?
I am using the code from another question asked on here.
String paragraph = "My 1st sentence. “Does it work for questions?” My third sentence.";
Reader reader = new StringReader(paragraph);
DocumentPreprocessor dp = new DocumentPreprocessor(reader);
List<String> sentenceList = new ArrayList<String>();
for (List<HasWord> sentence : dp) {
String sentenceString = Sentence.listToString(sentence);
sentenceList.add(sentenceString.toString());
}
for (String sentence : sentenceList) {
System.out.println(sentence);
}
Taken from: How can I split a text into sentences using the Stanford parser?
Thanks