for fileid in nltk.corpus.gutenberg.fileids(): num_chars=len(nltk.corpus.gutenberg.raw(fileid)) #统计字符数 num_words=len(nltk.corpus.gutenberg.words(fileid)) #统计单词数 num_sent=len(nltk.corpus.gutenberg.sents(fileid)) #统计句子数 num_vocab=len(set([w.lower() for w in nltk.corpus.gutenberg.words(fileid)])) print(int(num_chars / num_words), int(num_words / num_sent),int(num_words / num_vocab), fileid) File "<input>", line 6 print(int(num_chars / num_words), int(num_words / num_sent),int(num_words / num_vocab), fileid) ^ IndentationError: unindent does not match any outer indentation level
时间: 2023-12-03 18:45:29 浏览: 190
yunpan.zip_com.imilab.yunpan_http://yunpan.gqvis
这个错误提示是缩进错误,可能是你的代码缩进不正确。你可以检查一下代码中的缩进,确保缩进正确。正确的代码应该是这样的:
```
for fileid in nltk.corpus.gutenberg.fileids():
num_chars = len(nltk.corpus.gutenberg.raw(fileid)) # 统计字符数
num_words = len(nltk.corpus.gutenberg.words(fileid)) # 统计单词数
num_sent = len(nltk.corpus.gutenberg.sents(fileid)) # 统计句子数
num_vocab = len(set([w.lower() for w in nltk.corpus.gutenberg.words(fileid)]))
print(int(num_chars / num_words), int(num_words / num_sent), int(num_words / num_vocab), fileid)
```
阅读全文