将exstract_tags参数allowPOS转换为frozenset以减少查找时间。

This commit is contained in:
walkskyer 2014-11-15 18:14:47 +08:00
parent dd62477605
commit bab5f362ba

View File

@ -74,6 +74,7 @@ def extract_tags(sentence, topK=20, withWeight=False, allowPOS=[]):
idf_freq, median_idf = idf_loader.get_idf() idf_freq, median_idf = idf_loader.get_idf()
if allowPOS: if allowPOS:
allowPOS = frozenset(allowPOS)
words = jieba.posseg.cut(sentence) words = jieba.posseg.cut(sentence)
else: else:
words = jieba.cut(sentence) words = jieba.cut(sentence)