Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1.     def check_word(self, word):
  2.         word_list = word.split()
  3.         words = len(word_list)
  4.         correct_words = 0
  5.         for word in word_list:
  6.             stripped_word = ''.join(c for c in word if c.isalpha()).lower()
  7.             if len(word)/2 > len(stripped_word):
  8.                 break
  9.             if stripped_word in self.english_words:
  10.                 correct_words += 1
  11.         if words > 0:
  12.             this_score = correct_words/words
  13.         else:
  14.             this_score = 0
  15.         return this_score
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement