Open dyspnea opened 5 months ago
import jieba import jieba.posseg as pseg txt='Wi-Fi是个好东西' jieba.load_userdict('user_dict.txt') a = pseg.cut(txt)
print(list(a))
实际运行时,加载的用户词典,对jieba.cut生效,对pseg.cut无效,如何增加自定义词典呢? 词典内容是: Wi-Fi
import jieba jieba.load_userdict('user_dict.txt') import jieba.posseg as pseg txt='Wi-Fi是个好东西' a = pseg.cut(txt) print(list(a))
改成这样也不行,Wi-Fi 在pseg.cut时会被拆开,但加载字典后,jieba.cut会把Wi-Fi当做一个整体 Python3.10.9,win11
import jieba import jieba.posseg as pseg txt='Wi-Fi是个好东西' jieba.load_userdict('user_dict.txt') a = pseg.cut(txt)
a =jieba.cut(txt)
print(list(a))
实际运行时,加载的用户词典,对jieba.cut生效,对pseg.cut无效,如何增加自定义词典呢? 词典内容是: Wi-Fi