Improved the script for ngram extraction.