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) [] """

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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)
    []
    """

def transform_string(s: str) -> str:
"""Return a new string based on s in which all letters have been
converted to uppercase and punctuation characters have been stripped
from both ends. Inner punctuation is left untouched.
>> transform_string('Birthday!!!')
'BIRTHDAY'
>> transform_string('"Quoted?"')
"QUOTED'
>>> transform_string('To be? Or not to be?')
'TO BE? OR NOT TO BE'
II II ||
"""!"'`@$%^&_-+={}|\\/,;: .-?)([→*#\n\t\r"""
s.upper().strip(punctuation)
punctuation
result
%3D
return result
def is_vowel_phoneme(phoneme: str) -> bool:
"""Return True if and only if phoneme is a vowel phoneme. That is, whether
phoneme ends in a 0, 1, or 2.
Precondition: len(phoneme) > 0 and phoneme.isupper()
>> is_vowel_phoneme('AE0')
True
>> is_vowel-phoneme('DH')
False
>>> is_vowel-phoneme('IH2')
True
II II ||
return phoneme[-1] in '012'
Transcribed Image Text:def transform_string(s: str) -> str: """Return a new string based on s in which all letters have been converted to uppercase and punctuation characters have been stripped from both ends. Inner punctuation is left untouched. >> transform_string('Birthday!!!') 'BIRTHDAY' >> transform_string('"Quoted?"') "QUOTED' >>> transform_string('To be? Or not to be?') 'TO BE? OR NOT TO BE' II II || """!"'`@$%^&_-+={}|\\/,;: .-?)([→*#\n\t\r""" s.upper().strip(punctuation) punctuation result %3D return result def is_vowel_phoneme(phoneme: str) -> bool: """Return True if and only if phoneme is a vowel phoneme. That is, whether phoneme ends in a 0, 1, or 2. Precondition: len(phoneme) > 0 and phoneme.isupper() >> is_vowel_phoneme('AE0') True >> is_vowel-phoneme('DH') False >>> is_vowel-phoneme('IH2') True II II || return phoneme[-1] in '012'
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY