Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

用pseg分词标注词性时,如何加载自定义词典 #1017

Open
dyspnea opened this issue Jun 4, 2024 · 1 comment
Open

用pseg分词标注词性时,如何加载自定义词典 #1017

dyspnea opened this issue Jun 4, 2024 · 1 comment

Comments

@dyspnea
Copy link

dyspnea commented Jun 4, 2024

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

@dyspnea
Copy link
Author

dyspnea commented Jun 4, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant