bugfix. Out of boundary when extracting ngrams.