post.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:redberry 作者: michaelcho 项目源码 文件源码
def keywords(self, num=5):

        words_only = self.strip_tags(self.content, strip_punctuation=True)
        words = words_only.split()

        counter = collections.Counter(words)
        common = counter.most_common()

        keywords = []

        INSIGNIFICANT_WORDS = ('should', 'which', 'therefore')

        for word in common:
            lower_word = word[0].lower()
            if len(lower_word) > 4 and lower_word not in INSIGNIFICANT_WORDS:
                keywords.append(lower_word)

            if len(keywords) >= num:
                break

        return ", ".join(keywords)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号