栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python nltk pos

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python nltk pos

pos_tags标签说明
      • 用法:
        • 举个栗子
      • 标签说明:

用法:

pos_tags = nltk.pos_tag(words)
words是独立的单词列表

举个栗子

处理一段英文文本(text),进行分词,删除停用词,词性识别。

import nltk
from nltk.tokenize import sent_tokenize, word_tokenize
from nltk.corpus import stopwords
from string import punctuation

text = 'Compatibility of systems of linear constraints over the set of natural numbers.'
# 分词
words_before = word_tokenize(text.lower())

# 删除停用词和标点符号
stopwords = set(stopwords.words('english') + list(punctuation))

words = []
for w in words_before:
    if w not in stopwords:
        words.append(w)

# 词性标注
pos_tags = nltk.pos_tag(words)
print(pos_tags)

输出

[('compatibility', 'NN'), ('systems', 'NNS'), ('linear', 'JJ'), ('constraints', 'NNS'), ('set', 'VBD'), ('natural', 'JJ'), ('numbers', 'NNS')]
标签说明:
标签原词含义举例
CCcoordinatingconjunction连词and, or,but, if, while,although
CDcardinaldigit数词twenty-four, fourth, 1991,14:24
DTdeterminer限定词the, a, some, most,every, no
EXexistentialthere存在量词there, there’s
FWforeignword外来词dolce, ersatz, esprit, quo,maitre
INpreposition/subordinating conjunction介词连词on, of,at, with,by,into, under
JJadjective形容词new,good, high, special, big, local
JJRadjective comparative形容词比较级bleaker braver breezier briefer brighter brisker
JJSadjective, superlative形容词最高级calmest cheapest choicest classiest cleanest clearest
LSlistmarker标记
MDmodal情态动词can cannot could couldn’t
NNnoun , singular名词year,home, costs, time, education
NNSnounplural名词复数undergraduates scotches
NNPpropernoun, singular专有名词Alison,Africa,April,Washington
NNPSproper noun, plural专有名词复数Americans Americas Amharas Amityvilles
PDTpredeterminer前限定词all both half many
POSpossessiveending所有格标记’ 's
PRPpersonalpronoun人称代词
PRP$possessive pronoun所有格her his mine my our ours
RBadverb副词occasionally unabatingly maddeningly
RBRadverb,comparative副词比较级further gloomier grander
RBSadverb,superlative副词最高级best biggest bluntest earliest
RPparticle虚词aboard about across along apart
SYM符号% & ’ ‘’ ‘’. ) )
TOtoto to
UHinterjection感叹词Goodbye Goody Gosh Wow
VBverb, baseform动词ask assemble assess
VBDverb, pasttense动词过去式dipped pleaded swiped
VBGverb,gerund/present participle动词现在分词telegraphing stirring focusing
VBNverb, pastparticiple动词过去分词multihulled dilapidated aerosolized
VBPverb,sing. present, non-3d动词现在式非第三人称时态predominate wrap resort sue
VBZverb, 3rdperson sing. present动词现在式第三人称时态bases reconstructs marks
WDTwh-determinerWh限定词who,which,when,what,where,how
WPwh-pronounWH代词that what whatever
WP$possessivewh-pronounWH代词所有格whose
WRBwh-abverbWH副词-
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/275271.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号