zoukankan      html  css  js  c++  java
  • Mac下,spacy配置

     pip3 install -U spacy -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
     python3 -m spacy download en 

    在终端里输一下就完事了

    # import stanfordnlp
    # nlp = stanfordnlp.Pipeline() 
    # doc = nlp("Barack Obama was born in Hawaii.  He was elected president in 2008.")
    # doc.sentences[0].print_dependencies()
    import spacy
    s="Everything will be OK in the end,if it's not OK,it's not the end."
    nlp=spacy.load("en_core_web_sm")
    doc=nlp(s)
    # 利用空格分开
    print(doc.text.split())
    # 利用token的.orth_方法,可以识别标点符号
    print([token.orth_ for token in doc])
    # 带下划线的方法返回字符、不带下划线的方法返回数字
    print([(token, token.orth_, token.orth) for token in doc])
    # 分词,去除标点和空格
    print([token.orth_ for token in doc if not token.is_punct | token.is_space])
    
    # 标准化到基本形式
    #practice = "practice practiced practicing"
    #nlp_practice = nlp(practice)
    #print([word.lemma_ for word in nlp_practice])
    View Code
  • 相关阅读:
    sublime使用技巧
    周末时间学习Linux
    中小企业网络安全提升
    NoSQL是什么?
    IBM的淘汰之路
    Linux 中断处理浅析
    深入理解 C 语言的函数调用过程
    LAMP简易安装
    安装Fedora 24后必要的设置
    wget命令详解
  • 原文地址:https://www.cnblogs.com/war1111/p/10907732.html
Copyright © 2011-2022 走看看