如何避免Ngrams的StopIteration错误

时间:2018-08-17 01:54:42

标签: python text-processing python-textprocessing

我正在学习如何处理语言数据,尤其是使用ngram。当我编写以下循环时,它给我一条StopIteration错误消息。这些文件是包含许多单词的列表的文本文件。您能告诉我这是什么原因,请问如何避免这种情况?

for x in listdir:
    os.chdir('...')
    x1 = open(x,'r')
    data1 = x1.read().split('\n')
    fg = sorted(ngrams(data1, 6)) 
    ....

/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py:34: DeprecationWarning: generator 'ngrams' raised StopIteration

0 个答案:

没有答案