mirror of
https://github.com/fxsjy/jieba.git
synced 2025-07-10 00:01:33 +08:00
new method: jieba.disable_parallel, which is the inverse operation of jieba.enable_parallel
This commit is contained in:
parent
b46166f768
commit
3f003e2f29
2
.gitignore
vendored
2
.gitignore
vendored
@ -161,3 +161,5 @@ pip-log.txt
|
||||
|
||||
# Mac crap
|
||||
.DS_Store
|
||||
*.log
|
||||
|
||||
|
@ -252,3 +252,10 @@ def enable_parallel(processnum):
|
||||
cut = pcut
|
||||
cut_for_search = pcut_for_search
|
||||
|
||||
def disable_parallel():
|
||||
global pool,cut,cut_for_search
|
||||
if pool != None:
|
||||
pool.close()
|
||||
pool = None
|
||||
cut = __ref_cut
|
||||
cut_for_search = __ref_cut_for_search
|
||||
|
@ -151,7 +151,7 @@ def __lcut_internal(sentence):
|
||||
return list(__cut_internal(sentence))
|
||||
|
||||
def cut(sentence):
|
||||
if not hasattr(jieba,'pool'):
|
||||
if (not hasattr(jieba,'pool')) or (jieba.pool==None):
|
||||
for w in __cut_internal(sentence):
|
||||
yield w
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user