Question
Background Assume youre working on a contract where a company is building an e-mailing list by analyzing e-mail messages to pull out some addresses. Your
BackgroundAssume youre working on a contract where a company is building an e-mailing list by analyzing e-mail messages to pull out some addresses. Your task is to write a python program that reads a file (stored in the current working directory) called message.dat testing each word in the file to determine if the word is an email address. The program then outputs, to a separate file called mailing_list.dat, one per line, every real e-mail address contained inside the file as it runs across them. For this assignment, our words are white space delimited, and if a word has an embedded commercial at sign (@) inside it (that is, interior to the string), we shall consider it a possible e-mail address.
To determine if it a real email address and worthy of your companys mailing list, you will need to process the emails a little further. First, you should trim any trailing commas (,). Thus, the string BillyBob@mtsu.edu, must appear in the output file as BillyBob@mtsu.edu with the trailing comma removed. Only commas at the end of a string are considered trailing; do not remove non-trailing commas. Also, some email addresses may contain angle brackets (aka chevrons ) surrounding them. These should be removed; thus, the string " would become GhostDiet@BooLean.bit with the angle brackets removed. Aside from these two bits of processing, do not worry about any other punctuation; only remove trailing commas, the preceding angle bracket . After doing the processing you can test the possible e-mail address to determine if it is, in fact, real. For this assignment, a real e-mail address MUST HAVE a period within the final 5 characters of the string. Example: PythonRules@place.com is a valid email address because there is a period in the string ce.com while C++ForLyfe@house.rules is NOT because there is no period in the string rules.
Implementation NotesThere is NO starter file for this assignment. Make sure you use as your source file name spammer.py. Dont forget to head your source file with the standard title line and global comments we use for all programming assignments. Be sure to have your program close() both files that you opened.
Input/OutputYou should create your own data file(s) to initially test your program. After you think it is working, you may link the file $PUB/message.dat into your work area and use it. To link it, type the command $ ln -s $PUB/message.dat message.dat into the terminal. (Be sure you link the file by using the above command NOT by using cp to copy it.) This link will create a symbolic link to the message.dat file in $PUB and you will be able to test your program with message.dat as the input file.
For your output, file use the filename mailing_list.dat.DO NOT write anything to standard output (stdout), which means NO print() function calls.The first 12 lines of output in your mailing_list.dat file should like:
mikkiflower@gcmail.com
mikkiflower@gcmail.com
f72991ad0702230813u7ca6c4ebm9c708c6dbe3e8a30@mail.gcmail.com
Mikki_Flower@siggraph.org
mikkiflower@gcmail.com
info@academart.edu
alvarolanchart@apanimationschool.com
dst@asu.edu
GhostDiet@Boolean.bit
PythonRules@place.com
mthomas@aracademy.edu
sberkan@artcenter.edu
SubmissionYou are to electronically submit the source program, a source program listing, and the execution results obtained from running your program against the input file $PUB/message.dat. Once you have a working program, the following UNIX commands will do what is required:
$ script ola10.log
$ rm -f message.dat mailing_list.dat
$ ln -s $PUB/message.dat message.dat
$ cat -n spammer.py
$ python3 spammer.py
$ cat -n mailing_list.dat
$ exit
$ handin ola10 spammer.py ola10.log
message.dat file:
info@academart.edu, alvarolanchart@apanimationschool.com, dst@asu.edu, , BillyBob@mtsu, PythonRules@place.com, C++ForLyfe@house.rules, mthomas@aracademy.edu, sberkan@artcenter.edu, lcoper@artcenter.edu, cbar@artcenter.edu, rclayon@artcenter.edu, azerad@artcenter.edu, aicafadm@aii.edu, thome@saic.edu, Deiseberg@saic.edu, sfare@saic.edu, ne11@fac.aii.edu, jeses@aii.edu, grifitc@aii.edu, aippres@aii.edu, chapelm@aii.edu, nmclarence@aii.edu, sye@aii.edu, dheap@aii.edu, wwake@aii.edu, hestman@aii.edu, dma81@fac.aii.edu, crohd@aii.edu, shughes@aii.edu, aiadm@aii.edu, oliver.biber@medien.uni-weimar.de, sclarof@cs.bu.edu, bilmark@cs.utexas.edu, pflower@uarts.edu, zeml@cs.toronto.edu, "hanish,frank"@wsi-gris.uni-tuebingen.de, ansen@cs.utah.edu, mrj3@ber.ac.uk, sales@cs.washington.edu, curles@cs.washington.edu, weghor@u.washington.edu, counselling@uwo.ca, smith@uwsp.edu, schoolse@uvsc.edu, al@mcap.ca, inf@vanarts.com, art@vcu.edu, jhseip@vcu.edu, jgabard@vt.edu, nfo@sc.waseda.ac.jp, gary.scid@washburn.edu, heroes@earthlink.net, ksingh@mail.arch.wsu.edu, rish@wellesley.edu, por@wellesley.edu, gorham@wvu.edu, geor@wilamette.edu, karuhr@wilamette.edu, rwscat.com@gcmail.com,>@boolean.bit>
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started