Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i am having difficulty to code this in python, can i please get help. Overview and Requirements Write a program twitter sort.py) that merges and

image text in transcribed
image text in transcribed
image text in transcribed
i am having difficulty to code this in python, can i please get help.
Overview and Requirements Write a program twitter sort.py) that merges and sorts two twitter feeds. At a high level, your program is going to perform the following: 1. Read in two files containing twitter feeds that are sorted in reverse chronological order (most recent first). 2. Merge the twitter feeds in reverse chronological order (most recent first), 3. Write the merged feeds to an output file. 4. Provide some basic summary information about the files. The names of the files will be passed in to your program via command line arguments. Use the following input files to test your program: tweet1.bt and tweet2.c The output of your program includes the following: 1. Console A. The name of the file that contained the most tweets followed by the number of tweets tweeted. In the event of a tie, print both filenames along with the number of tweets (Note: a fle may be empty). B. The five earliest tweets along with the tweeter. 2. sorted_tweets.txt: the lines from the inputted files sorted in reverse chronological order (most recent tweets first and earliest tweets at the end) Program Details File Format Each input file will contain a list of records with one record appearing on each line of the file. The format of a record is as follows: TWEETER "TWEET" YEAR MONTH DAY HRN:SC Your lob will be to read in each file and for each line in the file, create a record with the above information. In the above format, a tweet is a string that can contain a list of tokens. Also, HR:MN: SC should be treated as a single field of the record, the time Note: you should remove the symbol from each tweeter's name. Parsing Tweets You may use Python's re regular expression) module or the provided Scanner class in the scanner.py module to help you parse different fields from the Tweets Functions to ens Type here to search VO Parsing Tweets You may use Python's re regular expression) module or the provided Scanner class in the scanner by module to help you parse different fields from the tweets Functions to Define Define the following functions in your code: .main(): the main function that drives the program. The function interprets command line arguments for filenames, calls functions described below, and outputs results to the console read records(): a function that given a filename creates a record for each line in the file and returns a list containing the records. Each record can be implemented as a list or dictionary containing the fields in each line. Note: the "@" symbol should be removed from the tweeter's name . is_more_recent(): a function that compares two records based on date and returns True If the first record is more recent than the second and False otherwise merge_and_sort_tweets(): a function that merges two lists of sorted records placing more recent records before earlier records and returns the merged records as a single list write_records(): a function that takes in a list of records and writes to the file output each record on its own line. Example Run File 1 (tweetidemo.txt): @poptardsarefamous "Sometimes I wonder 2 - bor !(2 -- b) 2013 101 1 6:42 now I have no idea what my cs prof is saying" 2013 10 1 12:07:14 pythondiva "Hy wory is great 468 android" 2013 10 1 1016111 enig is so clever, y code is even unreadable to me!" 2013 101 00:27:00 Fle2 weet2_demo.ba Bocd programmer 140 character list so i cant write y variable names" 2013 101 1118:01 caffeine life ZZZZZZZZZZZZZZ Z ZETTTTttt 2011 10 2 02153147 Run the program python twitter_sort.py tweeti demo.txt tweet demo.txt sorted e tt Example Console Output Reading files... tweeti demo.txt contained the most tweets with 4. e @ G here to search @ocd_programmer "140 character limit? so i cant write my variable names" 2013 10 1 13:18:01 @caffeinetlife "BBBBZZZZzzzzzzzzzzzzzzzzzzzZZZZZTTTTttt" 2011 19 2 02:53:47 Run the program: python twitter_sort.py tweeti demo.txt tweet2 demo.txt sorted demo.txt Example Console Output Reading files... tweeti demo.txt contained the most tweets with 4. Merging files... Writing file... File written. Displaying 5 earliest tweeters and tweets. caffeineslife "BBBBZZZZZZZZZZZZZZZZzzzzZ2272222TTTTttt" enigna "in so clever, my code is even unreadable to me!" pythondiva "My memory is great

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: 3

blur-text-image

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

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions

Question

What is behavioral persuasion in advertising designed to do?

Answered: 1 week ago