class WordChunkUtils {

    public static List<WordChunk> getWordChunks(String string) {
        string = string.replaceAll("\\s+", " ");

        for (char c : SENTENCE_ENDING_INTERPUNCTIONS.toCharArray()) {
            string = string.replace(" " + c, "" + c);
        }

        ArrayList<WordChunk> res = new ArrayList<>();
        String[] parts = string.split("\\s+");

        for (int i = 0; i < parts.length; i++) {
            String part = parts[i];
            String word = getWord(part);
            if (res.size() > 0 && StringUtils.isEmpty(word)) {
                res.get(res.size() - 1).chunk += " " + part;
            } else {
                res.add(new WordChunk(part, word));
            }
        }

        WordChunk firstChunk = res.get(0);
        if (res.size() > 1 && StringUtils.isEmpty(firstChunk.word)) {
            res.remove(0);
            res.get(0).chunk = firstChunk.chunk + " " + res.get(0).chunk;
        }

        return res;
    }

    private  WordChunkUtils();

}