本文整理汇总了Python中jieba.dt方法的典型用法代码示例。如果您正苦于以下问题:Python jieba.dt方法的具体用法?Python jieba.dt怎么用?Python jieba.dt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jieba
的用法示例。
在下文中一共展示了jieba.dt方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cut
# 需要导入模块: import jieba [as 别名]
# 或者: from jieba import dt [as 别名]
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
示例2: _lcut_internal
# 需要导入模块: import jieba [as 别名]
# 或者: from jieba import dt [as 别名]
def _lcut_internal(s):
return dt._lcut_internal(s)
示例3: _lcut_internal_no_hmm
# 需要导入模块: import jieba [as 别名]
# 或者: from jieba import dt [as 别名]
def _lcut_internal_no_hmm(s):
return dt._lcut_internal_no_hmm(s)
示例4: __init__
# 需要导入模块: import jieba [as 别名]
# 或者: from jieba import dt [as 别名]
def __init__(self, idf_path=None):
self.tokenizer = jieba.dt
self.postokenizer = jieba.posseg.dt
self.stop_words = self.STOP_WORDS.copy()
self.idf_loader = IDFLoader(idf_path or DEFAULT_IDF)
self.idf_freq, self.median_idf = self.idf_loader.get_idf()