Handling conjunctions when splitting sentences using core-nlp's DocumentPreprocessor

Viewed 758

I am trying to split a given text into sentences using the core-nlps' DocumentPreprocessor method.

Below is the code which I'm using.

List<String> splitSentencesList = new ArrayList<>();
Reader reader = new StringReader(inputText);
DocumentPreprocessor dp = new DocumentPreprocessor(reader); 
 for(List<HasWord> sentence :dp){
               splitSentencesList.add(Sentence.listToString(sentence).toLowerCase().replace(" .", ""));} 

This works for most of the cases. But, how do we handle conjunctions within a sentence?

E.g:

I like coffee and donuts for my breakfast.

Ideally, which should be further handled as :

I like coffee for my breakfast.
I like donuts for my breakfast.

One option is to do a regex based rule to split them further. Is there any inbuilt method to achieve this in core-nlp.

any pointers on this is appreciated.

1 Answers
Related