Ошибка отступа: ожидается блок с отступом (поваренная книга Nltk) - PullRequest
0 голосов
/ 21 апреля 2019

Я слежу за кулинарной книгой и столкнулся с этой ошибкой. В строке 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: ожидается блок с отступом

...