implement a naive n-gram method