def enable_parallel(processnum=None):
 global pool, dt, cut, cut_for_search
 from multiprocessing import cpu_count
 if (os.name == u'nt'):
  raise NotImplementedError(u'jieba: parallel mode only supports posix system')
 else:
  from multiprocessing import Pool
 dt.check_initialized()
 if (processnum is None):
  processnum = cpu_count()
 pool = Pool(processnum)
 cut = _pcut
 cut_for_search = _pcut_for_search

def enable_parallel ( processnum = None ) : global pool , dt , cut , cut_for_search from multiprocessing import cpu_count if ( os . name == u'nt' ) : raise NotImplementedError ( u'jieba: parallel mode only supports posix system' ) else : from multiprocessing import Pool dt . check_initialized ( ) if ( processnum is None ) : processnum = cpu_count ( ) pool = Pool ( processnum ) cut = _pcut cut_for_search = _pcut_for_search
change the modules cut and cut_for_search functions to the parallel version .