文章起源 | 恒源云社区(一个专一 AI 行业的共享算力平台:恒源智享云)

原文地址 | SpaCy


最近分享了社区大佬们的一些语言解决类的论文,干货满满!

戳 可查看,兴许就有你须要的知识点哦~

恒源云 _比照学习,只须要 Dropout?
恒源云 _ 语音辨认与语义解决畛域之机器翻译 21.7 mRASP2
恒源云 _LLD: 外部数据领导的标签去噪办法【ACL 2022】
恒源云 _Y-Tuning: 通过对标签表征进行微调的深度学习新范式【ACL 2022】
恒源云 _ 语音辨认与语义解决畛域之 NAG 优化器

✨明天呢,就给大家分享一下如何在恒源云GPU服务器上如何应用spaCy。

置信很多小伙伴都晓得,spaCy 是一个自然语言解决库,包含分词、词性标注、词干化、命名实体辨认、名词短语提取等性能。

那如何装置呢?

# 装置 spaCy 3 For CUDA 11.2,依据镜像 CUDA 版本替换 [] 内版本pip install spacy[cuda112]==3.0.6# 装置 spaCy 2 For CUDA 11.2,依据镜像 CUDA 版本替换 [] 内版本pip install spacy[cuda112]==2.3.5# 通过 spacy 模块下载模型因为墙可能不可用,可通过上面 pip 装置形式装置python -m spacy download en_core_web_sm# 装置 3.0.0 en_core_web_smpip install https://mirror.ghproxy.com/https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.0.0/en_core_web_sm-3.0.0-py3-none-any.whl --no-cache# 装置 2.3.1 en_core_web_smpip install https://mirror.ghproxy.com/https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.3.1/en_core_web_sm-2.3.1.tar.gz --no-cache

装置之后又如何应用呢?

import spacy# Load English tokenizer, tagger, parser and NERnlp = spacy.load("en_core_web_sm")# Process whole documentstext = ("When Sebastian Thrun started working on self-driving cars at "        "Google in 2007, few people outside of the company took him "        "seriously. “I can tell you very senior CEOs of major American "        "car companies would shake my hand and turn away because I wasn’t "        "worth talking to,” said Thrun, in an interview with Recode earlier "        "this week.")doc = nlp(text)# Analyze syntaxprint("Noun phrases:", [chunk.text for chunk in doc.noun_chunks])print("Verbs:", [token.lemma_ for token in doc if token.pos_ == "VERB"])# Find named entities, phrases and conceptsfor entity in doc.ents:    print(entity.text, entity.label_)

以上就是明天所有的分享内容啦。对了,提前预祝大家除夕高兴呀~