Question

In: Computer Science

Problem 1 - Find the Diphthongs A diphthong is a composite vowel sound composed of two...

Problem 1 - Find the Diphthongs

A diphthong is a composite vowel sound composed of two simple vowel sounds. We're going to be looking for these in words. For instance "ay" is normally a diphthong for instance in the words "lay" and "day", as is "ou" for instance in "loud," "lout."

We're going to simplify this by looking only for two vowels in a row in a word regardless of whether they are sounded out as diphthongs or not.  

Let me show some examples of the counting:

[Ae]rat[io]n; count = 2

F[ou]ndat[io]n; count = 2

Q[ue][ue]ing; count = 2

The reason that we are counting this as two, is because once we've used a vowel as part of a diphthong do not use it again.   

Note also that after the last pair, there's another vowel, but since the last e was used, the i doesn't pair, so it is not part of a diphthong.  

P[ae]an; count = 1

Several; count = 0

[Ae][ae][ae][ae][ae]; count = 5

This is obviously an invented word, but who cares, it's composed of five diphthong pairs.  

Glor[ia]; count = 1

For this exercise, the vowels are a, e, i, o, u, and y.  

Take in a word, output each diphthong pair and finally output the count.  

In terms of spaces, commas, and periods, let the words be divided, so don't count a dipthong over a space or other grammatical mark, meaning that for instance "a year" should group like "a [ye]ar" rather than "[a y][ea]r."  

Sample Output

linux1[150]% python3 find_diphthongs.py

Enter a string with a lot of diphthongs: aeration

ae

io

The diphthong count is 2

linux1[151]% python3 find_diphthongs.py

Enter a string with a lot of diphthongs: aeitiour

ae

io

The diphthong count is 2

linux1[152]% python3 find_diphthongs.py

Enter a string with a lot of diphthongs: ayayay

ay

ay

ay

The diphthong count is 3

linux1[153]% python3 find_diphthongs.py

Enter a string with a lot of diphthongs: argument

The diphthong count is 0

If you want to eliminate a space between your letters and you're printing the characters separately, use:

print('a', 'e', sep='')

Solutions

Expert Solution

save as find_diphthongs.py

# Function that return true 
# if character ch is a vowel 
def isVowel(ch): 
    if ch in ['a', 'e', 'i', 'o', 'u','y']: 
        return True
    else:  
        return False

# Function to return the count of adjacent 
# vowel pairs in the given string 
def vowelPairs(s, n):   
    cnt = 0
    i=0
    
    while i<n-1:  
        step=1
        # If current character and the 
        # character after it are both vowels 
        if (isVowel(s[i]) and  isVowel(s[i + 1])): 
            print(s[i]+s[i+1])
            step = 2  #skip the used a vowel as part of a diphthong do not use it again
            cnt += 1  #count the diphthong
        i= i + step
          
    return cnt 
  
# Driver code 
def main():
    text=input("Enter a string with a lot of diphthongs: ")
    n = len(text) 
    c=vowelPairs(text, n)
    print("The diphthong count is ",c)

if __name__ == "__main__":
    main()


Related Solutions

1. A bacteria contain a genomic island composed in several composite transposon.Why might this bacterium be...
1. A bacteria contain a genomic island composed in several composite transposon.Why might this bacterium be of concern medically?
The first and second formants when you make an "ee" vowel sound are approximately 270 Hz...
The first and second formants when you make an "ee" vowel sound are approximately 270 Hz and 2300 Hz . The speed of sound in your vocal tract is approximately 350 m/s . If you breathe a mix of oxygen and helium (as deep-sea divers often do), the speed increases to 810m/s With this mix of gases, what are the frequencies of the two formants?
The Great Vowel Shift (GVS) is a well-studied sound change phenomenon which occurred between 1400 and...
The Great Vowel Shift (GVS) is a well-studied sound change phenomenon which occurred between 1400 and 1600. Describe what occurred in the shift in a couple/few sentences, making reference to specific phones.
Find the number of 7 letters words that contain at least one vowel.
Find the number of 7 letters words that contain at least one vowel.
A composite cylindrical wall is composed of 2 materials of thermal conductivity ka = 240 W/mK...
A composite cylindrical wall is composed of 2 materials of thermal conductivity ka = 240 W/mK and kb = 20 W/mK, where interfacial contact resistance is negligible. - Liquid pumped through the tube is at a temperature Tinf, i = 200 F and provides a convection coefficient hi = 450 W/m^2K at the inner surface of the composite pipe -The outer surface is exposed to Tinf, o and provides a convection coefficient of ho = 20 W/m^2K -A thermocouple between...
Problem 9-16 One unit of A is composed of two units of B and three units...
Problem 9-16 One unit of A is composed of two units of B and three units of C. Each B is composed of one unit of F. C is made of one unit of D, one unit of E, and two units of F. Items A, B, C, and D have 15, 50, 45, and 25 units of on-hand inventory, respectively. Items A, B, and C use lot-for-lot (L4L) as their lot-sizing technique, while D, E, and F require multiples...
Problem 6:   Two students are standing the same distance from a source of sound. The first...
Problem 6:   Two students are standing the same distance from a source of sound. The first student receives a power of 246 × 10-6 W in their eardrum. The second student receives σ = 1.17 times more power in their eardrum. Part (a) What is the ratio of the diameters of the student's eardrums? Part (b) If the second student's eardrum has a diameter of d = 1 cm what was the intensity of the sound that the student heard,...
Find inductance, L, of a concentric cable composed of two cylindrical wires: a solid inner wire...
Find inductance, L, of a concentric cable composed of two cylindrical wires: a solid inner wire of a radius a = 2 mm carrying a constant current I, and a very thin cylindrical outer wire of a radius b = 5 mm and carrying a constant current ??I.
For the following exercises, use the spinner shown in Figure 3 to find the probabilities indicated. Landing on blue or a vowel
For the following exercises, use the spinner shown in Figure 3 to find the probabilities indicated.Landing on blue or a vowel
Problem: Susan Sound predicts that students will learn most effectively with a constant background sound, as...
Problem: Susan Sound predicts that students will learn most effectively with a constant background sound, as opposed to an unpredictable sound or no sound at all. She randomly divides twenty-four students into three groups of eight. All students study a passage of text for 30 minutes. Those in group 1 study with background sound at a constant volume in the background. Those in group 2 study with noise that changes volume periodically. Those in group 3 study with no sound...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT