第五章 分类和词性标注

import nltk

text = nltk.word_tokenize("And now for something completely different")

a=nltk.pos_tag(text)

分词后进行词性标注,CC是连词,RB是副词,IN是介词,NN是名词,JJ是形容词,


可以使用

nltk.help.upenn_tagset('RB')

查询缩写字母代表的含义


标记含义例子
ADJ 形容词new, good, high, special, big, local
ADV 动词really, already, still, early, now
CNJ 连词and, or, but, if, while, although
DET 限定词the, a, some, most, every, no
EX 存在量词there, there's
FW 外来词dolce, ersatz, esprit, quo, maitre
MOD 情态动词will, can, would, may, must, should
N 名词year, home, costs, time, education
NP 专有名词Alison, Africa, April, Washington
NUM 数词twenty-four, fourth, 1991, 14:24
PRO 代词he, their, her, its, my, I, us
P 介词on, of, at, with, by, into, under
TO 词to to
UH 感叹词ah, bang, ha, whee, hmpf, oops
V 动词is, has, get, do, make, see, run
VD 过去式said, took, told, made, asked
VG 现在分词making, going, playing, working
VN 过去分词given, taken, begun, sung
WH Wh 限定词who, which, when, what, where, how


将词性按频率排列

tag_fd = nltk.FreqDist(tag for (word, tag) in a)

将tag_fd转化为链表

tag_fd.keys()

将频率分布转化为累计分布图

tag_fd.plot(cumulative=True)


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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值