本文整理汇总了Python中textblob.TextBlob.pos_tags方法的典型用法代码示例。如果您正苦于以下问题:Python TextBlob.pos_tags方法的具体用法?Python TextBlob.pos_tags怎么用?Python TextBlob.pos_tags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类textblob.TextBlob
的用法示例。
在下文中一共展示了TextBlob.pos_tags方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RakeKeywordExtractor
# 需要导入模块: from textblob import TextBlob [as 别名]
# 或者: from textblob.TextBlob import pos_tags [as 别名]
RAKE_OBJ = RakeKeywordExtractor(set([]))
word_scores = RAKE_OBJ._calculate_word_scores(phrase_list)
phrase_scores = RAKE_OBJ._calculate_phrase_scores(phrase_list, word_scores)
sorted_phrase_scores = sorted(phrase_scores.iteritems(),key=operator.itemgetter(1), reverse=True)
n_phrases = len(sorted_phrase_scores)
return sorted_phrase_scores[0:int(n_phrases)]
#FILE = open(sys.argv[1],"r")
FILE = codecs.open(sys.argv[1],"r","iso8859-15")
CONTENT = FILE.read()
CONTENT = CONTENT.encode('ascii','ignore')
BLOB_OBJ = TextBlob(CONTENT,tokenizer=tokenizer,pos_tagger = nltk_tagger,np_extractor = COLL_OBJ) # OBJECT WITH FAST NP CHUNKER
pos_tags = nltk.pos_tag(BLOB_OBJ.tokens)
BLOB_OBJ.pos_tags = pos_tags
phrase_list = BLOB_OBJ.noun_phrases
newlist =[]
temp =[]
for word in phrase_list:
words = word.split(' ')
for x in words:
x = LEMMA_OBJ.lemmatize(x)
x = x.lower()
if x not in stopwords:
temp.append(x)
newlist.append(temp)
temp = []
phrase_list = newlist
#print COLLBLOB_OBJ.noun_phrases
keywordList = rake_extract(phrase_list)