We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 9cebdb7 + 4de7593 commit e1d2b6dCopy full SHA for e1d2b6d
ch05/classify.py
@@ -54,6 +54,9 @@ def prepare_sent_features():
54
if not text:
55
meta[pid]['AvgSentLen'] = meta[pid]['AvgWordLen'] = 0
56
else:
57
+ from platform import python_version
58
+ if python_version().startswith('2'):
59
+ text = text.decode('utf-8')
60
sent_lens = [len(nltk.word_tokenize(
61
sent)) for sent in nltk.sent_tokenize(text)]
62
meta[pid]['AvgSentLen'] = np.mean(sent_lens)
0 commit comments