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

jieba分词使用paddlepaddle #25

Open
ljk99 opened this issue Jan 6, 2022 · 0 comments
Open

jieba分词使用paddlepaddle #25

ljk99 opened this issue Jan 6, 2022 · 0 comments

Comments

@ljk99
Copy link
Owner

ljk99 commented Jan 6, 2022

jieba分词使用paddletiny,只支持Python3.7,python3.8直接安装paddlepaddle
在官方代码的基础上加上下面两行
import paddle
paddle.enable_static()

`
import paddle
import jieba
import jieba.posseg as pseg
words = pseg.cut("我爱北京天安门") #jieba默认模式
paddle.enable_static()
jieba.enable_paddle() #启动paddle模式。 0.40版之后开始支持,早期版本不支持
words = pseg.cut("我爱北京天安门",use_paddle=True) #paddle模式
for word, flag in words:
print('%s %s' % (word, flag))
#import nltk

#nltk.download()
quit()
`

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