代码如下:
import hanlp
tok = hanlp.load(hanlp.pretrained.tok.COARSE_ELECTRA_SMALL_ZH)
pos = hanlp.load(hanlp.pretrained.pos.PKU_POS_ELECTRA_SMALL)
tok.dict_force = {’’: [’’]}
tok.dict_force.update({‘油泼辣子’: [‘油泼辣子’]})
pos.dict_tags = {’’:’’}
pos.dict_tags.update({‘油泼辣子’: ‘nms’})
print(pos([“我”,“喜欢”,“吃”,“油泼辣子”]))
我期待的结果如下:
[‘r’, ‘v’, ‘v’, ‘nms’]
但结果为:
[‘r’, ‘v’, ‘v’, ‘n’]