Detecting sentences using Java

In this recipe, we will see how we can detect sentences so that we can use them for further analysis. Sentences are a very important text unit for data scientists to experiment different routing exercises, such as classification. To detect sentences from texts, we will be using Java's BreakIterator class.

Getting ready

Go to https://docs.oracle.com/javase/7/docs/api/java/text/BreakIterator.html and see the examples. This will give you an idea on the usage of a break iterator.

How to do it...

As a test for this recipe's code, we will use two sentences that can create confusion to many regular-expression-based solutions. The two sentences for test are: My name is Rushdi Shams. You can use Dr. before my name as I have a ...

Get Java Data Science Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.