NLP spaCy使用(二,从一个例子入手)

“上海自来水来自海上“, 我想,这是每个学过中文的修辞的都知道,这个叫做回环修辞(或者回文)。
如果采用spaCy处理会怎么样?

nlp_zh = spacy.load(‘zh_core_web_md’) sh_z = nlp_zh(‘上海自来水来自海上。’) for token in sh_z:
print(token.text, token.pos_,token.tag_, spacy.explain(token.pos_), spacy.explain(token.tag_)) 其结果如下:
上海 PROPN NR proper noun proper noun
自来水 NOUN NN noun noun, singular or mass
来自 VERB VV verb other verb
海上 NOUN NN noun noun, singular or mass
。 PUNCT PU punctuation punctuation

看起来是不是很不错?可能现在对 “PROPN”, "NR"等不太了解,且一步一步。

函数 .explain

首先,spaCy提供一个非常有用的函数,即,spacy.explain。该函数在spaCy系统中归于top level。即,由spacy全局对象提供的方法。在spacy的api文档中,对explain的注释如下:

Get a description for a given POS tag, dependency label or entity type

再抽丝剥茧,什么是“POS tag”?

POS 在NLP中是一个通用的缩写,即Parts of speech,即,词性。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值