University of Arizona, Department of Computer Science

CSc 120: Primary stress position

Context

This is a sub-problem of the long problem for this assignment, namely, rhyming words.

Expected Behavior

Write a function primary_stress_position(phoneme_list) that behaves as follows. The argument phoneme_list is a list of phonemes, as described here. It returns an integer that is the position of the primary stress phoneme (i.e., the phoneme with the main stress) in phoneme_list. If there is no primary stress in phoneme_list, your function should return None.

This document describes how the primary-stress phoneme is indicated.

You can assume that there is at most one primary-stress phoneme in phoneme_list.

Examples

  1. primary_stress_position(['W', 'IY1', 'K', 'L', 'IY0'])
    Return value: 1
    Reason: the return value is the position of the primary-stress phoneme, 'IY1', in the argument list of phonemes.
    Comment: The argument list of phonemes gives the pronunciation of the word WEEKLY.

  2. primary_stress_position(['K', 'AH0', 'M', 'P', 'Y', 'UW1', 'T', 'ER0', 'AY2', 'Z'])
    Return value: 5
    Reason: the return value is the position of the primary-stress phoneme, 'UW1', in the argument list of phonemes.
    Comment: The argument list here is the pronunciation of the word COMPUTERIZE.

  3. primary_stress_position(['R', 'AH0', 'K', 'AO1', 'R', 'D' ])
    Return value: 3
    Reason: the return value is the position of the primary-stress phoneme, 'AO1', in the argument list of phonemes.
    Comment: The argument list here is the pronunciation of the word RECORD.

  4. primary_stress_position(['EY1', 'K'])
    Return value: 0
    Reason: the return value is the position of the primary-stress phoneme, 'EY1', in the argument list of phonemes.
    Comment: The argument list here is the pronunciation of the word ACHE.

  5. primary_stress_position(['AH0', 'V'])
    Return value: None
    Reason: the return value indicates that there is no primary stress phoneme in the argument list.
    Comment: The argument list here is a pronunciation of the word OF.