Next word prediction based on N-gram language model