Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. def clean_up(s):
  2. punctuation = """!"'`@$%^&_-+={}|\\/,;:.-?)([]<>*#\n\t\r"""
  3. result = s.upper().strip(punctuation)
  4. return result
  5.  
  6. def check_syllables(poem_lines, pattern, word_to_phonemes):
  7. d = {}
  8. wrong_list = []
  9. for i in range(len(poem_lines)):
  10. d[i] = 0
  11. for word in poem_lines[i].split():
  12. for x in word_to_phonemes[clean_up(word)]:
  13. if('0' in x or '1' in x or '2' in x):
  14. d[i] = d[i] + 1
  15. for i in range(len(pattern[0])):
  16. if pattern[0][i] != d[i]:
  17. wrong_list.append(poem_lines[i])
  18. return wrong_list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement