当前位置: 首页>>代码示例>>Python>>正文


Python FreqDist.pop方法代码示例

本文整理汇总了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
开发者ID:ayat-rashad,项目名称:eg_twitter,代码行数:15,代码来源:process_data_spark.py

示例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
开发者ID:atiassa,项目名称:recommend-2011,代码行数:15,代码来源:q2_1.py

示例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
开发者ID:thelemonyfresh,项目名称:patent_assignment,代码行数:8,代码来源:assignment.py


注:本文中的nltk.probability.FreqDist.pop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。