mirror of
https://github.com/fxsjy/jieba.git
synced 2025-07-10 00:01:33 +08:00
Merge pull request #152 from jagt/jieba3k
close cache file to avoid warning message.
This commit is contained in:
commit
5574304a9e
@ -84,7 +84,8 @@ def initialize(*args):
|
||||
if os.path.exists(cache_file) and os.path.getmtime(cache_file)>os.path.getmtime(abs_path):
|
||||
logger.debug("loading model from cache %s" % cache_file)
|
||||
try:
|
||||
trie,FREQ,total,min_freq = marshal.load(open(cache_file,'rb'))
|
||||
with open(cache_file, 'rb') as cf:
|
||||
trie,FREQ,total,min_freq = marshal.load(cf)
|
||||
load_from_cache_fail = False
|
||||
except:
|
||||
load_from_cache_fail = True
|
||||
|
Loading…
x
Reference in New Issue
Block a user