This is my very first try for scala in play framework. What I really want to achieve is to take every first word from sentences in a paragraph.
This is the code that throws an error
Text is mutable.Seq[String]
someText.flatMap(_ split "[.?!]")
.map(_ split "\\s+" filter !_.equals("") head)
.toList
But the problem is on 2nd line. It throws an error saying that:
[NoSuchElementException: next on empty iterator]
In my humble opinion, sentence separated by whitespace will not be empty as long as the someText is a real paragraph with a lot of sentences.
Could somebody clarify, how this could happened and how to fix it?