Skip to content

Commit

Permalink
may fix #6 #7
Browse files Browse the repository at this point in the history
  • Loading branch information
bung87 committed Mar 9, 2020
1 parent 0823406 commit 066f13e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions bixin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
from collections import Counter
from jieba_fast import Tokenizer
import tempfile
# import platform

# isWin = platform.system() == 'Windows'

big_dict = os.path.join(os.path.dirname(__file__), "data","dict.txt.big")
tokenizer = Tokenizer(big_dict)
Expand Down Expand Up @@ -50,10 +53,11 @@ def _initialize(self, pos_emotion, pos_evaluation, neg_emotion, neg_evaluation,
.union(self.least_degree)

pos_neg = self.pos_emotion.union(self.neg_emotion)
with tempfile.NamedTemporaryFile(suffix=".txt",mode="w",encoding="utf-8") as f:
with tempfile.NamedTemporaryFile(suffix=".txt",mode="w",encoding="utf-8",delete=False) as f:
f.write("\n".join(pos_neg.union(pos_neg_eva)))
f.close() # for Win
tokenizer.load_userdict(f.name)

os.unlink(f.name) # for Win
self.initialized = True

def initialize(self,include_evalution_dict=False,include_tc=False):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}
setup(
name='bixin',
version='0.0.5',
version='0.0.6',
license="MIT",
author="bung",
packages=find_packages(exclude=['bin', 'tests']),
Expand Down

0 comments on commit 066f13e

Please sign in to comment.