日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

AttributeError: ‘pyltp.Postagger‘ object has no attribute ‘load‘

發(fā)布時(shí)間:2023/12/31 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 AttributeError: ‘pyltp.Postagger‘ object has no attribute ‘load‘ 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

環(huán)境:

組件版本
ltp ? ? ? ?4.0.8
pyltp0.4.0
Python3.6.10

? ? ? ? ? ? ? ? ?

?

報(bào)錯(cuò)代碼如下:

## 代碼片段import os import jieba from pyltp import Postagger, Parsersent = '2018年7月26日,華為創(chuàng)始人任正非向5G極化碼(Polar碼)之父埃爾達(dá)爾教授舉行頒獎(jiǎng)儀式,表彰其對(duì)于通信領(lǐng)域做出的貢獻(xiàn)。'jieba.add_word('Polar碼') jieba.add_word('5G極化碼') jieba.add_word('埃爾達(dá)爾') jieba.add_word('之父') words = list(jieba.cut(sent))print(words)# 詞性標(biāo)注 pos_model_path = os.path.join(os.path.dirname(__file__), 'data/pos.model') postagger = Postagger() postagger.load(pos_model_path) postags = postagger.postag(words)

解決方案:

最后一段代碼改成:

# 詞性標(biāo)注
postagger = Postagger(os.path.join("data", "pos.model"))
postags = postagger.postag(words)
print("\t".join(postags))
# postagger = Postagger()
# postagger.load(pos_model_path)
# postags = postagger.postag(words)
?

?



?

轉(zhuǎn)載自[1]

Reference:

[1]AttributeError: 'pyltp.Postagger' object has no attribute 'load'

總結(jié)

以上是生活随笔為你收集整理的AttributeError: ‘pyltp.Postagger‘ object has no attribute ‘load‘的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。