缩进错误:预期缩进的块(Nltk烹饪书)

时间:2019-04-21 10:09:54

标签: python indentation spyder

我正在跟踪Cook Book,遇到了这个错误。在第15行中存在一些问题,我无法解决。 enter image description here

代码

import re
replacement_patterns = [
(r'won\'t', 'will not'),
(r'can\'t', 'cannot'),
(r'i\'m', 'i am'),
(r'ain\'t', 'is not'),
(r'(\w+)\'ll', '\g<1> will'),
(r'(\w+)n\'t', '\g<1> not'),
(r'(\w+)\'ve', '\g<1> have'),
(r'(\w+)\'s', '\g<1> is'),
(r'(\w+)\'re', '\g<1> are'),
(r'(\w+)\'d', '\g<1> would')
]
class RegexpReplacer(object):
def__init__(self,patterns=replacement_patterns):self.patterns=[(re.compile(regex),repl)for(regex,repl)inpatterns]
def replace(self, text):
s = text
for (pattern, repl) in self.patterns:
s = re.sub(pattern, repl, s)
return s

错误: IndentationError:预期出现缩进的块

0 个答案:

没有答案