Skip to content

Commit

Permalink
Merge pull request nltk#2583 from CubieDev/hotfix-2582
Browse files Browse the repository at this point in the history
Fix for Issue nltk#2582, name `save_file` is not defined
  • Loading branch information
stevenbird authored Sep 4, 2020
2 parents b8a9647 + 019cc03 commit 873b359
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions nltk/sentiment/sentiment_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def save_file(self, content, filename):
"""
print("Saving", filename, file=sys.stderr)
with open(filename, 'wb') as storage_file:
import pickle
# The protocol=2 parameter is for python2 compatibility
pickle.dump(content, storage_file, protocol=2)

Expand Down
2 changes: 1 addition & 1 deletion nltk/sentiment/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ def demo_subjectivity(trainer, save_analyzer=False, n_instances=None, output=Non
results = sentim_analyzer.evaluate(test_set)

if save_analyzer == True:
save_file(sentim_analyzer, "sa_subjectivity.pickle")
sentim_analyzer.save_file(sentim_analyzer, "sa_subjectivity.pickle")

if output:
extr = [f.__name__ for f in sentim_analyzer.feat_extractors]
Expand Down

0 comments on commit 873b359

Please sign in to comment.