擅长:python、mysql、java
<p>请尝试下面的代码</p>
<pre><code>stop=stopwords.words('english')
temp = [[genre, word.lower()] for genre in cfdconditions for word in brown.words(categories=genre) if word.lower() not in stop]
cdev_cfd=nltk.ConditionalFreqDist(temp)
cdev_cfd.tabulate(conditions=cfdconditions,samples=cfdevents)
lst=[]
for i in temp:
if i[1].endswith('ing'):
lst.append((i[0],'ing'))
elif i[1].endswith('ed'):
lst.append((i[0],'ed'))
inged_cfd=nltk.ConditionalFreqDist(lst)
inged_cfd.tabulate(conditions=cfdconditions,samples=['ed','ing'])
</code></pre>