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.
1 parent 22bc140 commit 1d8fd23Copy full SHA for 1d8fd23
ch05/classify.py
@@ -54,7 +54,9 @@ def prepare_sent_features():
54
if not text:
55
meta[pid]['AvgSentLen'] = meta[pid]['AvgWordLen'] = 0
56
else:
57
- text = text.decode('utf-8')
+ 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