check_rhyme_scheme: (POEM, POEM_FORM_DESCRIPTION,…
Question Answered step-by-step check_rhyme_scheme: (POEM, POEM_FORM_DESCRIPTION,… check_rhyme_scheme:(POEM, POEM_FORM_DESCRIPTION, PRONUNCIATION_DICT) ->List[List[POEM_LINE]def check_rhyme_scheme(poem_lines: POEM, description: POETRY_FORM_DESCRIPTION, word_to_phonemes: PRONUNCIATION_DICT) -> List[List[POEM_LINE]]: “””Return a list of lists of lines from poem_lines that do NOT rhyme with each other as specified by the poetry form description, according to the pronunciation dictionary word_to_phonemes. If all lines rhyme as they should, return the empty list. The lines is each inner list should be in the same order as they appear in poem_lines. Precondition: len(poem_lines) == len(description[1]) >>> poem_lines = [‘The first line leads off,’, … ‘With a gap before the next.’, ‘Then the poem ends.’] >>> description = ((5, 7, 5), (‘A’, ‘B’, ‘A’)) >>> 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’)} >>> bad_lines = check_rhyme_scheme(poem_lines, description, … word_to_phonemes) >>> bad_lines.sort() >>> bad_lines [[‘The first line leads off,’, ‘Then the poem ends.’]] “”” Computer Science Engineering & Technology Python Programming CSCA CSCA08 Share QuestionEmailCopy link Comments (0)


