Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this file there are 4 function stubs for which you must write the code. Note: In each case the function is to return the

In this file there are 4 function stubs for which you must write the code. Note: In each case the function is to return the result -- do not confuse this with printing the result.

vowel_count

This function takes a word and returns the number of vowels in the word (including y).

syllable_count

This function takes a word and returns the number of syllables in the word. For this exercise, assume that syllables are determined as follows: Each sequence of vowels a e i o u y, except for the last e in a word, is a vowel. However, if that algorithm yields a count of 0, change it to 1. For example,

Word Syllables
Harry 2
hairy 2
hare 1
the 1

filter_dict

This function takes the name of a dictionary file that contains 1 word per line, and the minimum and maximum word lengths. Your function will return a list of the words from the original dictionary file whose length is within the user-specified bounds. So for instance, if the min is 3 and max is 7, then only words with length >= 3 and length <= 7 will be returned in the list.

gematria

Once each letter is assigned a value you can compute the value of a word or phrase by simply summing the values of each letter in the word/phrase. Using a mapping of a=1, b=2, c=3, ..., z=26, "Phil" has a value of P=16 + h=8 + i=9 + l=12 == 45. This function that takes a word and the name of a dictionary file, and then returns a list of all the entries from the dictionary that gematrically match the given word. Note that the case of a letter does not change its value.

The template code is below:

def vowel_count(word): """  Returns the number of vowels in a word (including y).  :param word: the word to search for vowels   >>> vowel_count('Harry')  2  >>> vowel_count('HAIRY')  3  """  # replace pass below with your code  pass  def syllable_count(word): """  Returns the number of syllables in the word.  For this exercise, assume that syllables are determined as follows:  Each sequence of vowels a e i o u y, except for the last e in a word, is a vowel.  However, if that algorithm yields a count of 0, change it to 1.   :param word: the word whose syllables are being counted.   >>> syllable_count('Harry')  2  >>> syllable_count('HAIRY')  2  >>> syllable_count('hare')  1  >>> syllable_count('the')  1  """  # replace pass below with your code  pass  def filter_dict(filename, min, max): """  From the specified dictionary file containing 1 word per line,  return a list of words whose lengths are within the user-specified  bounds. So for instance, if the min is 3 and max is 7,  then only words with length >= 3 and length <= 7 will be  returned in the list.   :param filename: the dictionary file containing 1 word per line  :param min: the min length (inclusive) of words to return  :param max: the max length (inclusive) of words to return   >>> filter_dict('small_dict.txt', 3, 5)  ['acted', 'bios', 'coder', 'find', 'gore', 'knife', 'racer']   >>> filter_dict('small_dict.txt', 7, 10)  ['debased', 'shameful']  """  # replace pass below with your code  pass  def gematria(word_to_match, filename): """  Takes a word and the name of a dictionary file, and then  returns (a list of) all the entries from the dictionary that  Gematrically match the given word.   "Gematria is the act of assigning numeric values to letters in an  alphabet"  -- (https://en.wikipedia.org/wiki/Gematria,  last access 10/7/2017).  Once each letter is assigned a value you can compute the value of  a word or phrase by simply summing the values of each letter in  the word/phrase. Using a mapping of a=1, b=2, c=3, ..., z=26,  "Phil" has a value of P=16 + h=8 + i=9 + l=12 == 45.  Note that the case of a letter does not change its value.   :param word_to_match: the word for which you are trying to find a Gematric match  :param filename: the dictionary file containing other candidate words   >>> gematria('Phil', 'small_dict.txt')  ['bios', 'coder', 'gore', 'knife', 'racer']  """  # replace pass below with your code  pass  

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2017 Skopje Macedonia September 18 22 2017 Proceedings Part 3 Lnai 10536

Authors: Yasemin Altun ,Kamalika Das ,Taneli Mielikainen ,Donato Malerba ,Jerzy Stefanowski ,Jesse Read ,Marinka Zitnik ,Michelangelo Ceci ,Saso Dzeroski

1st Edition

ISBN: 3319712721, 978-3319712727

More Books

Students also viewed these Databases questions

Question

How long is a subnet mask?

Answered: 1 week ago

Question

=+10. How are inflation and unemployment related in the short run?

Answered: 1 week ago

Question

=+8. Why is productivity important?

Answered: 1 week ago