问题重现:
# -*- encoding:utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import nltk
from nltk.corpus import stopwords
text="I've got a very big apple "
text=text.split(" ")
# text.remove('')
text = list(set(text))
print text
text_list=nltk.pos_tag(text)
print text_list
for item in text_list:
if item[1]=='JJ':#如果该英文单词是形容词
print"item[0]=",item[0]
解决方案如下:
# -*- encoding:utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import nltk
from nltk.corpus import stopwords
text="I've got a very big apple "
text=text.split(" ")
text.remove('')
text = list(set(text))
print text
text_list=nltk.pos_tag(text)
print text_list
for item in text_list:
if item[1]=='JJ':#如果该英文单词是形容词
print"item[0]=",item[0]