import nltkfrom nltk.corpus import brownbrown_tagged_sents = brown.tagged_sents(categories='news')((x[1],y[1],z[0],z[1]) for sent in brown_tagged_sents for x,y,z in nltk.trigrams(sent))cfd = nltk.ConditionalFreqDist( ((x[1],y[1],z[0],z[1]) for sent in brown_tagged_sents for x,y,z in nltk.trigrams(sent)))會出現上面的代碼:Traceback (most recent call last): File "/Users/shike/Desktop/textprocess/nltktest.py", line 10, in <module> for sent in brown_tagged_sents File "/usr/local/lib/python3.6/site-packages/nltk/probability.py", line 1803, in __init__ for (cond, sample) in cond_samples: ValueError: too many values to unpack (expected 2) 該列表理解((x[1],y[1],z[0],z[1]) for sent in brown_tagged_sents for x,y,z in nltk.trigrams(sent))可以單獨工作,但是當它用作參數時會出錯。我仍然不知道為什么。所有代碼均在 Python3 中測試。
nltk 要解壓縮的值太多(預期為 2)
幕布斯6054654
2021-08-05 16:36:48