helpers.py 文件源码

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

项目:featherduster 作者: nccgroup 项目源码 文件源码
def count_words(candidate_text, common_words=frequency.common_words['english'], case_sensitive=True):
   '''
   Count the instances of common words in the expected plaintext
   language, return the total number of characters matched in each
   word 

   candidate_text - (string) Sample to analyze
   common_words - (list) Sequences expected to appear in the text
   case_sensitive - (bool) Whether or not to match case sensitively
   '''
   score = 0

   for word in common_words:
      if not case_sensitive:
         word = word.lower()
      num_found = candidate_text.count(word)
      if num_found > 0:
         score += num_found * len(word)

   return score
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号