Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def clean_up(s):
- punctuation = """!"'`@$%^&_-+={}|\\/,;:.-?)([]<>*#\n\t\r"""
- result = s.upper().strip(punctuation)
- return result
- def check_syllables(poem_lines, pattern, word_to_phonemes):
- d = {}
- wrong_list = []
- for i in range(len(poem_lines)):
- d[i] = 0
- for word in poem_lines[i].split():
- for x in word_to_phonemes[clean_up(word)]:
- if('0' in x or '1' in x or '2' in x):
- d[i] = d[i] + 1
- for i in range(len(pattern[0])):
- if pattern[0][i] != d[i]:
- wrong_list.append(poem_lines[i])
- return wrong_list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement