<p>我的代码中有这个错误,我不知道如何修复</p>
<pre><code>import nltk
from nltk.util import ngrams
def word_grams(words, min=1, max=4):
s = []
for n in range(min, max):
for ngram in ngrams(words, n):
s.<a href="https://www.cnpython.com/list/append" class="inner-link">append</a>(' '.join(str(i) for i in ngram))
return s
print word_grams('one two three four'.split(' '))
</code></pre>
<p>厄洛尔</p>
<pre><code>s.append(' '.join(str(i) for i in ngram))
</code></pre>
<p>TypeError:“str”对象不可调用</p>