Complete the docstring below, and use the helper functions attached if necessary: def check_syllable_counts(poem_lines: POEM, description: POETRY_FORM_DESCRIPTION, word_to_phonemes: PRONUNCIATION_DICT) \ -> List[POEM_LINE]: """Return a list of lines from poem_lines that do NOT have the right number of syllables as specified by the poetry form description, according to the pronunciation dictionary word_to_phonemes. If all lines have the right number of syllables, return the empty list. Precondition: len(poem_lines) == len(description[0]) >>> poem_lines = ['The first line leads off,', ... 'With a gap before the next.', 'Then the poem ends.'] >>> description = ((5, 5, 4), ('*', '*', '*')) >>> word_to_phonemes = {'NEXT': ('N', 'EH1', 'K', 'S', 'T'), ... 'GAP': ('G', 'AE1', 'P'), ... 'BEFORE': ('B', 'IH0', 'F', 'AO1', 'R'), ... 'LEADS': ('L', 'IY1', 'D', 'Z'), ... 'WITH': ('W', 'IH1', 'DH'), ... 'LINE': ('L', 'AY1', 'N'), ... 'THEN': ('DH', 'EH1', 'N'), ... 'THE': ('DH', 'AH0'), ... 'A': ('AH0'), ... 'FIRST': ('F', 'ER1', 'S', 'T'), ... 'ENDS': ('EH1', 'N', 'D', 'Z'), ... 'POEM': ('P', 'OW1', 'AH0', 'M'), ... 'OFF': ('AO1', 'F')} >>> check_syllable_counts(poem_lines, description, word_to_phonemes) ['With a gap before the next.', 'Then the poem ends.'] >>> poem_lines = ['The first line leads off,'] >>> description = ((0,), ('*')) >>> check_syllable_counts(poem_lines, description, word_to_phonemes) [] """
Complete the docstring below, and use the helper functions attached if necessary:
def check_syllable_counts(poem_lines: POEM,
description: POETRY_FORM_DESCRIPTION,
word_to_phonemes: PRONUNCIATION_DICT) \
-> List[POEM_LINE]:
"""Return a list of lines from poem_lines that do NOT have the right
number of syllables as specified by the poetry form description, according
to the pronunciation dictionary word_to_phonemes. If all lines have the
right number of syllables, return the empty list.
Precondition: len(poem_lines) == len(description[0])
>>> poem_lines = ['The first line leads off,',
... 'With a gap before the next.', 'Then the poem ends.']
>>> description = ((5, 5, 4), ('*', '*', '*'))
>>> word_to_phonemes = {'NEXT': ('N', 'EH1', 'K', 'S', 'T'),
... 'GAP': ('G', 'AE1', 'P'),
... 'BEFORE': ('B', 'IH0', 'F', 'AO1', 'R'),
... 'LEADS': ('L', 'IY1', 'D', 'Z'),
... 'WITH': ('W', 'IH1', 'DH'),
... 'LINE': ('L', 'AY1', 'N'),
... 'THEN': ('DH', 'EH1', 'N'),
... 'THE': ('DH', 'AH0'),
... 'A': ('AH0'),
... 'FIRST': ('F', 'ER1', 'S', 'T'),
... 'ENDS': ('EH1', 'N', 'D', 'Z'),
... 'POEM': ('P', 'OW1', 'AH0', 'M'),
... 'OFF': ('AO1', 'F')}
>>> check_syllable_counts(poem_lines, description, word_to_phonemes)
['With a gap before the next.', 'Then the poem ends.']
>>> poem_lines = ['The first line leads off,']
>>> description = ((0,), ('*'))
>>> check_syllable_counts(poem_lines, description, word_to_phonemes)
[]
"""
Step by step
Solved in 3 steps