“上海自来水来自海上“, 我想,这是每个学过中文的修辞的都知道,这个叫做回环修辞(或者回文)。
如果采用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,即,词性。