fxsjy / jieba

结巴中文分词
MIT License
33.39k stars 6.73k forks source link

paddle模式无法加载自定义词典 #924

Open stanleyli60 opened 3 years ago

stanleyli60 commented 3 years ago

代码如下:

import jieba
import paddle
import jieba.posseg as pseg

if __name__ == '__main__':
    paddle.enable_static()
    jieba.enable_paddle()
    str = "杨和苏KeyNG - “ 路西法” 【LYRIC VIDEO】-5X29cDrQjsA"
    jieba.load_userdict("words.txt")
    words = pseg.cut(str, use_paddle=True)
    for word, flag in words:
        print('%s %s' % (word, flag))

words.txt包括:

杨和苏 100 PER

运行结果: 杨 nr 和 c 苏KeyNG - “ 路西法” 【LYRIC VIDEO】-5X29cDrQjsA nt

请问有什么办法可以自定义一些关键词吗?

mongkuli commented 2 years ago

这个问题怎么解决,我现在也想加字典但是没有成功

lzuqjz commented 2 years ago

the same problem.