I can't understand your code, but here's how to achieve your stated intention with just 3 lines:
String document; // read from somewhere
List<List<String>> words = new ArrayList<>();
for (String sentence : document.split("[.?!]\\s*"))
words.add(Arrays.asList(sentence.split("[ ,;:]+")));
If you want to convert the Lists
to arrays, use List.asArray()
, but I wouldn't recommend it. Lists are far easier to deal with than arrays. For one, they expand automatically (one reason why the above code is so dense).
Addendum: (most) characters don't need escaping inside a character class.