我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用jieba.pool()。
def cut(sentence, HMM=True): """ Global `cut` function that supports parallel processing. Note that this only works using dt, custom POSTokenizer instances are not supported. """ global dt if jieba.pool is None: for w in dt.cut(sentence, HMM=HMM): yield w else: parts = strdecode(sentence).splitlines(True) if HMM: result = jieba.pool.map(_lcut_internal, parts) else: result = jieba.pool.map(_lcut_internal_no_hmm, parts) for r in result: for w in r: yield w
def cut(sentence): if (not hasattr(jieba,'pool')) or (jieba.pool==None): for w in __cut_internal(sentence): yield w else: parts = re.compile('([\r\n]+)').split(sentence) result = jieba.pool.map(__lcut_internal,parts) for r in result: for w in r: yield w