本文整理汇总了Python中nltk.probability.FreqDist.pop方法的典型用法代码示例。如果您正苦于以下问题:Python FreqDist.pop方法的具体用法?Python FreqDist.pop怎么用?Python FreqDist.pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nltk.probability.FreqDist
的用法示例。
在下文中一共展示了FreqDist.pop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: filter_words
# 需要导入模块: from nltk.probability import FreqDist [as 别名]
# 或者: from nltk.probability.FreqDist import pop [as 别名]
def filter_words(words):
new_words = FreqDist(words)
stopwords = get_stop_words('ar')
keys = new_words.keys()
for word in keys:
if word in stopwords:
new_words.pop(word)
if len(word) <= 2:
new_words.pop(word)
return new_words
示例2: worst_errors_many_wrong_decisions
# 需要导入模块: from nltk.probability import FreqDist [as 别名]
# 或者: from nltk.probability.FreqDist import pop [as 别名]
def worst_errors_many_wrong_decisions(self, k, feature_extractor):
worst_errors = []
features = []
wrongDocs = self.error_prediction_docs(self.maintest, self.testClassify)
for doc in wrongDocs:
feature_dic = feature_extractor(movie_reviews.words(fileids=[doc]))
features = features + feature_dic.keys()
fd = FreqDist(feature.lower() for feature in features)
for i in range(1, k+1):
x = fd.max()
fd.pop(x)
worst_errors.append(x)
return worst_errors
示例3: word_count
# 需要导入模块: from nltk.probability import FreqDist [as 别名]
# 或者: from nltk.probability.FreqDist import pop [as 别名]
def word_count(text, exclude_inputlist):
frequency = FreqDist(wd.lower() for wd in text if wd.isalpha())
excludelist = stopwords.words('english') + exclude_inputlist
for word in frequency.keys():
if word in excludelist or frequency[word] < 2 or not word.isalpha(): frequency.pop(word)
return frequency