Using an NLTK Conditional Frequency Distribution and the nltk.bigrams function, train a bigram model on the Genesis:
text = nltk.corpus.genesis.words('english-kjv.txt')
bigrams = nltk.bigrams(text)
我有以下代码可以在movie_review语料库中打印15个最常见的事件。 import nltk
import random
from nltk.corpus import movie_reviews
documents =[]
for category in movie_reviews.categories():
for fileid in movie_reviews.f