[TOC]
词性标注器
之后的很多工作都需要标注完的词汇。nltk自带英文标注器
pos_tag
import nltk
text = nltk.word_tokenize("And now for something compleyely difference")
print(text)
print(nltk.pos_tag(text))
标注语料库
表示已经标注的标识符:nltk.tag.str2tuple('word/类型')
text = "The/AT grand/JJ is/VBD ."
print([nltk.tag.str2tuple(t) for t in text.split()])
读取已经标注的语料库
nltk语料库ue肚脐提供了统一接口,可以不必理会不同的文件格式。格式:
语料库.tagged_word()/tagged_sents()
。参数可以指定categories和fields
print(nltk.corpus.brown.tagged_words())
名词、动词、形容词等
这里以名词为例
from nltk.corpus import brown
word_tag = nltk.FreqDist(brown.tagged_words(categories="news"))
print([word+'/'+tag for (word,tag)in word_tag if tag.startswith('V')])
################下面是查找money的不同标注#################################
wsj &#