From 066f13ed8717cf4a2725e10d76fc896a1347e483 Mon Sep 17 00:00:00 2001 From: zhoupeng Date: Mon, 9 Mar 2020 08:49:59 +0800 Subject: [PATCH] may fix #6 #7 --- bixin/__init__.py | 8 ++++++-- setup.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bixin/__init__.py b/bixin/__init__.py index 3d6570c..0d51471 100644 --- a/bixin/__init__.py +++ b/bixin/__init__.py @@ -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) @@ -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): diff --git a/setup.py b/setup.py index 69055d7..41f7df0 100644 --- a/setup.py +++ b/setup.py @@ -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']),