Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program Behavior In this assignment, you'll implement classes that analyze tweets and present analysis results to users. This analysis will be driven by two classes

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Program Behavior In this assignment, you'll implement classes that analyze tweets and present analysis results to users. This analysis will be driven by two classes that work in tandem to read in tweets, store a collection of them, analyze them, and present the analysis to the user. Part 1 - Tweet Bot To start analyzing tweets, we first need to read in and manage the state of tweets. To do this, create a class called . A should have the following constructor and methods: TweetBot TweetBot Constructor public TweetBot(List tweets) Given a of tweets, initialize a tweet list containing all tweets from the given collection. Note that you should not initialize your tweet list to the given reference. You should create a new data structure and copy over all of the tweets from the given, leaving the given unmodified after the constructor is finished executing. List List List List Throws an if the size of the given collection is less than 1. IllegalArgumentException You may assume the given collection contains only non-empty and distinct strings. Methods public int numTweets() Returns the number of tweets currently in the tweet list. public void addTweet(String tweet) Adds the given tweet to the end of the tweet list. You may assume that the given tweet does not already exist in the 's list of tweets. TweetBot public String nextTweet() Returns the next tweet from the tweet list. If all the tweets in the list are exhausted, cycle around to the start of the list. For example, the following code snippet should produce the output in the comments. Suppose that stores a list of Tweets. tweets ["A tweet about something controversial", "Remember to vote!", "Look at this meme :0"] TweetBot bot - new TweetBot(tweets); System.out.println(bot.nextTweet()); // A tweet about something controversial System.out.println(bot. nextTweet()); // Remember to vote! System.out.println(bot.nextTweet()); // Look at this meme :0 System.out.println(bot.nextTweet()); // A tweet about something controversial Think about how to get the next tweet from the list of tweets, and how you can cycle around to the start once you've gone through all the tweets! One Special Case! As you're working on your and testing your implementation, you'll likely start thinking about different cases that your will need to handle. There is one specific special case whose behavior is particularly tricky, so we wanted to talk about it more in desth. TweetBot TweetBot One Special Case! As you're working on your and testing your implementation, you'll likely start thinking about different cases that your will need to handle. There is one specific special case whose behavior is particularly tricky, so we wanted to talk about it more in depth. TweetBot TweetBot Consider the case where your is storing a single tweet (referred to as tweet1), and you call on your. Then, you immediately afterwards add in another tweet (referred to as tweet2). On the next call to nextTweet(), your TweetBot should return tweet2 (the tweet that was just added in) -- NOT tweet1. TweetBot nextTweet() TweetBot i Note that the case described here is a tricky one - really there are couple of different ways that a could reasonably handle this situation. But, since you'll be writing code to pass tests that we provide, we're telling you how you should handle this situation for this assignment! TweetBot public void removeTweet(String tweet) Removes the given tweet from the tweet list if it is present. Pay particular attention to making sure that the remove method should preserve the current iteration order of the method above. In particular, using the example tweets from the last method, the following code should produce the output shown in the comments. nextTweet TweetBot bot - new TweetBot(tweets); System.out.println(bot. nextTweet()); // A tweet about something controversial System. out.println(bot. nextTweet()); // Remember to vote! bot. removeTweet("Remember to vote!"); System.out.print ln (bot. nextTweet()); // Look at this meme :0 System.out.println(bot.nextTweet()); // A tweet about something controversial System. out.print ln (bot. nextTweet()); // Look at this meme :0 In other words, the method should continue the iteration through the Tweet list, returning the Tweet immediately following the one that was last returned by, continuing with only the removed tweet cut out of the cycle. nextTweet nextTweet Be careful about removing a tweet that is not in the . In this case, the state of the should be unchanged. TwitterBot TwitterBot public void reset() Resets the iteration state of the such that subsequent calls to start back at the beginning. TweetBot nextTweet Part 2 - Twitter Trends Now that we have a class that maintains the state of our tweets, we can analyze them. We will ask that you implement one example method and then at least one method of your choosing to analyze the Tweets in a . TweetBot All of the methods you implement for this part should make sure that they analyze all of the Tweets in the so that future calls to these methods can start at the first Tweet. TweetBot Constructor public TwitterTrends(TweetBot bot) Initializes this with the given for analysis. TwitterTrends TweetBot Methods public String getMostFrequentWord() Return the most frequent word among all tweets in the we are analyzing. That is, on aggregate, which word is the most frequently used across all the tweets. TweetBot You should process the words in the tweets case-insensitively such that the tokens and are considered the same in terms of counting frequencies. You do not need to handle removing punctuation (i.e., and would be considered different words). The returned should be all lowercase. "Dogs" "dogs" "cats!" "cats?" String Implementation guidelines To count the number of occurrences of each word, iterate through all tweets in the. When working with the, use the method in conjunction with the method to get all tweets from the tweet queue. For each of these tweets, break them up into individual words (or tokens) using the class. For each of these words, count the number of occurrences (what data structure might be helpful here?) and return the word that has the highest count. TweetBot TweetBot numTweets() nextTweet() Scanner Creative Aspect The method is one way for us to analyze tweets. To come up with other analysis results from our tweets, we've decided to crowdsource! Along with your method, you should implement another method that analyzes tweets using this framework. Analyzing tweets in a new way will help you understand the way people on Twitter think, feel, and share! Your method can analyze tweets based on any metrics, but should contain the following elements: getMostFrequentWord getMostFrequentWord - Loop(s) to iterate through tweets. At the end of the method the should be restored to its original state. TweetBot - String parsing/traversals to look through tweet contents To get you started, here are some examples of analysis methods that we came up with: - Trending vs Not Trending: Is some phrase (or word) very popular amongst tweets? - Content Moderation: Are some tweets offensive (define this in any way)? To count the number of occurrences of each word, iterate through all tweets in the. When working with the, use the method in conjunction with the method to get all tweets from the tweet queue. For each of these tweets, break them up into individual words (or tokens) using the class. For each of these words, count the number of occurrences (what data structure might be helpful here?) and return the word that has the highest count. TweetBot TweetBot numTweets() nextTweet() Scanner Creative Aspect The method is one way for us to analyze tweets. To come up with other analysis results from our tweets, we've decided to crowdsource! Along with your method, you should implement another method that analyzes tweets using this framework. Analyzing tweets in a new way will help you understand the way people on Twitter think, feel, and share! Your method can analyze tweets based on any metrics, but should contain the following elements: getMostFrequentWord getMostFrequentWord - Loop(s) to iterate through tweets. At the end of the method the should be restored to its original state. TweetBot - String parsing/traversals to look through tweet contents To get you started, here are some examples of analysis methods that we came up with: - Trending vs Not Trending: Is some phrase (or word) very popular amongst tweets? - Content Moderation: Are some tweets offensive (define this in any way)? - Potential Misinformation Flagging: Prints a disclaimer and link to CDC website after any tweet referencing COVID or the pandemic. Feel free to implement either of these ideas or come up with one from scratch! The more creative the idea is, the more interesting the result Make sure that any method(s) you implement for leave the state of the the same as the beginning of the method call. That way you don't run into any bugs with methods upsetting the state of the after they are over. TwitterTrends TwitterBot TwitterBot Part 3 - Writing a Client Program As part of this assignment, you must also finish the class which contains a method that instantiates and uses your and objects to run the methods you've written on a of tweets. We have written the code to create both of these objects for you. You should use the given objects, calling the method and the creative method that you wrote for the above section to produce some analysis of the tweets. You must finally present the data that you have generated in an organized manner by printing it to the console. You can choose to format this output however you want; however, it must be neat and easy to read. TwitterMain main TwitterTrends TweetBot File getMostFrequentword Assignment Requirements For this assignment, you should follow the Code Quality Guide when writing your code to ensure it is readable and maintainable. In particular, you should focus on the following requirements: - You should make all of your fields and you should reduce the number of fields only to those that are necessary for solving the problem. private - You should comment your code following the Commenting Guide for every file you write. You should write comments with basic info, a class comment, and a comment for every method other than main. Make sure to avoid writing unnecessary implementation details in your comments

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions