Question: Python assignment with this format: --------------------- Enter your module docstring with a one-line overview here and a more detailed description here. import string

Python assignment with this format:

---------------------

"""

Enter your module docstring with a one-line overview here

and a more detailed description here.

"""

import string

SPAM_WORDS = {'opportunity', 'inheritance', 'money', 'rich', 'dictator',

'discount', 'save', 'free', 'offer', 'credit',

'loan', 'winner', 'warranty', 'lifetime', 'medicine',

'claim', 'now', 'urgent', 'expire', 'top',

'plan', 'prize', 'congratulations', 'help', 'widow'}

def spam_indicator(text):

"""

Enter your function docstring here

"""

# This function returns the spam indicator rounded to two decimals

def classify(indicator):

"""

Enter your function docstring here

"""

# This function prints the spam classification

def get_input():

"""

Enter your function docstring here

"""

# Prompt the user for input repeatedly and return the input

def main():

# Get the user input and save it in a variable

# Call spam_indicator to compute the spam indicator and save it

# Print the spam_indicator

# Call classify to print the classification

if __name__ == '__main__':

main()

-----------------

Python assignment with this format: --------------------- """ Enter your module docstring witha one-line overview here and a more detailed description here. """ import

string SPAM_WORDS = {'opportunity', 'inheritance', 'money', 'rich', 'dictator', 'discount', 'save', 'free', 'offer',

'credit', 'loan', 'winner', 'warranty', 'lifetime', 'medicine', 'claim', 'now', 'urgent', 'expire', 'top', 'plan',

Your task this week is to write a very simple spam classifier in Python. It will classify messages as either SPAM (unwanted) or HAM (wanted). The program will have a set of SPAM_WORDS, words that are known to appear in spam messages. That set is included in the template file spam.py D. You will also define a spam threshold which reflects the allowed percentage of spam words in the message. You'll compute a 'spam indicator', which is the ratio of spam words to the total number of unique words in the message. You will round the spam indicator to two decimals. If the spam indicator exceeds the spam threshold, the message is classified as spam. Otherwise it is classified as ham. We'll assume that the spam threshold is a constant and has a value of 0.10. Your program will prompt the user for a message and then will print the corresponding classification. The program will be case insensitive. The spam words are detected whether they are in lower case or upper case or mixed case. Each word, spam or not, is counted once (even if it appears multiple times in the message.) The program will remove punctuation from the message before identifying the words and computing the spam indicator. For example 'now!!!' must be identified as the spam word 'now

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!