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 + Windows + PowerShell + Python 3.7 安装方法 #1014

Open
doggy8088 opened this issue Apr 4, 2024 · 0 comments
Open

Jieba + Windows + PowerShell + Python 3.7 安装方法 #1014

doggy8088 opened this issue Apr 4, 2024 · 0 comments

Comments

@doggy8088
Copy link

doggy8088 commented Apr 4, 2024

终于成功运行起来了,以下是我在 Windows 成功设置的步骤:

  1. Install Python 3.7 and below

    https://www.python.org/downloads/release/python-379/

    $env:PATH = $env:USERPROFILE + '\AppData\Local\Programs\Python\Python37;' + $env:PATH
    $env:PATH = $env:USERPROFILE + '\AppData\Local\Programs\Python\Python37\Scripts;' + $env:PATH
  2. Install Jieba and dependent packages

    pip install jieba paddlepaddle-tiny protobuf==3.20.0
  3. Run Jieba

    jieba-demo.py:

    # encoding=utf-8
    import jieba
    
    jieba.enable_paddle()# 启动paddle模式。 0.40版之后开始支持,早期版本不支持
    strs=["我来到北京清华大学","乒乓球拍卖完了","中国科学技术大学"]
    for str in strs:
        seg_list = jieba.cut(str,use_paddle=True) # 使用paddle模式
        print("Paddle Mode: " + '/'.join(list(seg_list)))
    
    seg_list = jieba.cut("我来到北京清华大学", cut_all=True)
    print("Full Mode: " + "/ ".join(seg_list))  # 全模式
    
    seg_list = jieba.cut("我来到北京清华大学", cut_all=False)
    print("Default Mode: " + "/ ".join(seg_list))  # 精确模式
    
    seg_list = jieba.cut("他来到了网易杭研大厦")  # 默认是精确模式
    print(", ".join(seg_list))
    
    seg_list = jieba.cut_for_search("小明硕士毕业于中国科学院计算所,后在日本京都大学深造")  # 搜索引擎模式
    print(", ".join(seg_list))
    python .\jieba-demo.py
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