当前位置: 首页 > news >正文

如何自学网站建设书籍吉林省建设网站

如何自学网站建设书籍,吉林省建设网站,电脑公司网站模板下载,网站空间可以自己做吗当使用Spacy进行自然语言处理时#xff0c;常见的用例包括文本分词、命名实体识别、词性标注、句法分析等。下面是一些常见的使用例子及相应的代码#xff1a; 文本分词#xff08;Tokenization#xff09;#xff1a; 将文本划分成单词或标点符号等基本单元。 import … 当使用Spacy进行自然语言处理时常见的用例包括文本分词、命名实体识别、词性标注、句法分析等。下面是一些常见的使用例子及相应的代码 文本分词Tokenization 将文本划分成单词或标点符号等基本单元。 import spacy# 加载英文模型 nlp spacy.load(en_core_web_sm) # 文本分词 text This is a sample sentence. doc nlp(text)# 输出分词结果 for token in doc:print(token.text) 运行结果 This is a sample sentence . 命名实体识别Named Entity Recognition 识别文本中的命名实体如人名、地名、组织机构等。 import spacy# 加载英文模型 nlp spacy.load(en_core_web_sm) # 文本 text Apple is a big company, headquartered in Cupertino, California. # 处理文本 doc nlp(text) # 提取命名实体 for ent in doc.ents:print(ent.text, ent.label_) 运行结果: Apple ORG Cupertino GPE California GPE 词性标注Part-of-speech Tagging 标注文本中每个词的词性 import spacy# 加载英文模型 nlp spacy.load(en_core_web_sm)# 文本 text This is a sample sentence.# 处理文本 doc nlp(text)# 输出词性标注结果 for token in doc:print(token.text, token.pos_) 运行结果 This PRON is AUX a DET sample NOUN sentence NOUN . PUNCT 句法分析Dependency Parsing 分析文本中单词之间的依赖关系。 import spacy# 加载英文模型 nlp spacy.load(en_core_web_sm)# 文本 text Apple is looking at buying U.K. startup for $1 billion# 处理文本 doc nlp(text)# 输出句法依赖关系 for token in doc:print(token.text, token.dep_, token.head.text, token.head.pos_,[child for child in token.children]) 运行结果 Apple nsubj looking VERB [] is aux looking VERB [] looking ROOT looking VERB [Apple, is, at, startup] at prep looking VERB [buying] buying pcomp at ADP [U.K.] U.K. dobj buying VERB [] startup dep looking VERB [for] for prep startup NOUN [billion] $ quantmod billion NUM [] 1 compound billion NUM [] billion pobj for ADP [$, 1] 英文分句 import spacy nlp spacy.load(en_core_web_sm) nlp.add_pipe(sentencizer) doc nlp(This is a sentence. This is another sentence.) for sentence in doc.sents:print(sentence) 运行结果 This is a sentence. This is another sentence. 关键字抽取 import spacynlp spacy.load(en_core_web_sm) text Please ignore that NLLB is not made to translate this large number of tokens at once. Again, I am more interest in the computational limits I have.I already use torch.no_grad() and put the model in evaluation mode which I read online should safe some memory. My full code to run the inference looks like this:doc nlp(text) keywords [token.text for token in doc if token.pos_ in [NOUN, PROPN]] print(keywords) 运行结果 [NLLB, number, tokens, interest, limits, torch.no_grad, model, evaluation, mode, memory, code, inference] 句子相似度的比较 import spacy nlp spacy.load(en_core_web_lg)doc1 nlp(uthe person wear red T-shirt) doc2 nlp(uthis person is walking) doc3 nlp(uthe boy wear red T-shirt)print(doc1.similarity(doc2)) print(doc1.similarity(doc3)) print(doc2.similarity(doc3)) 运行结果 0.7003971105290047 0.9671912343259517 0.6121211244876517 Model Architectures · spaCy API Documentation
http://www.pierceye.com/news/173632/

相关文章:

  • 网络分析的应用案例广东网络seo推广平台
  • 网站开发设计合同北京网站排名优化公司
  • 免费建立个人网站凡科怎么下载app
  • 网站题头是什么做线上网站需要钱吗
  • 陕西省建设工程监理协会网站 查询动易网站首页错位
  • 老公做网站网站推广wordpress 文件加载顺序
  • 网站开发保存学习进度的方案搭建网站免费
  • 做网站对外贸有什么用网站怎么防k
  • 网站开发网站建设常州建站程序
  • 赤峰建设局网站物流公司网站制作模板
  • 装修第三方平台网站建设网站开发及设计
  • 男女做那个的小视频网站个人如何注册公司流程
  • 机关网站建设前期准备工作wordpress替代
  • 机关网站建设无锡宜兴网站建设
  • 江苏景禾瑜博建设工程有限公司网站做网站注册公司
  • 如何找到做网站的客户贵州二建报名入口官网
  • 网站怎么做301定向wordpress极客式主题
  • 造价工程建设协会网站怎么把做的网站发布
  • 万网网站首页好企业网站
  • 廊坊做网站电话企业网络搭建拓扑图
  • 建设社区网站有什么借鉴之处专业网站制作哪家专业
  • 南宁网站推广流程wordpress 雅黑字体
  • 个人网站制作代码河北seo基础知识
  • 国内做视频的网站有哪些企业网站价格花
  • 泰安网站推广优化wordpress首页图片
  • 政协网站建设更改wordpress管理员用户名
  • 网站浏览器兼容性通用有那种网站么
  • 网站中全景是怎么做的云南网络营销文化优化
  • 苏州网站优化哪家好换空间对网站的影响
  • 如何做黑客攻击网站专业的网站建设运营