Assignment 8: Nintendo America (30 Points)

Chris Tralie

Due Friday 5/8/2020



Overview / Logistics

This is the final assignment in this spring's CS 173 class, and it will serve as a segue into CS 174. The purpose of this assignment is to get you practice with classes, objects, and some of the basic data structures we talked about in the most recent modules: namely ArrayList and HashMap. In particular, you will be extracting information from a collection of about 2000 tweets from the Nintendo America twitter account between October 2018 and this month.

Click here to download the skeleton code for this assignment. You will be editing src/Tweet.java.

What to submit:

When you are finished, you should submit Tweet.java to Canvas. Please also submit answers to the following questions: (you can simply number your answers from 1 to 6 as a comment on Canvas)

  1. Did you work with a buddy on this assignment? If so, who?
  2. Did you use any resources outside of the class textbook and provided links to help you complete the assignment? Please list them here.
  3. Are you using up any grace points to buy lateness days? If so, how many?
  4. Approximately how many hours it took you to finish this assignment (I will not judge you for this at all...I am simply using it to gauge if the assignments are too easy or hard)
  5. Your overall impression of the assignment. Did you love it, hate it, or were you neutral? One word answers are fine, but if you have any suggestions for the future let me know.
  6. Any other concerns that you have. For instance, if you have a bug that you were unable to solve but you made progress, write that here. The more you articulate the problem the more partial credit you will receive (fine to leave this blank)

Part 1: The Tweet object and toString() (5 Points)

At this point, you should familiarize yourself with the Tweet class. A static method getAllTweets has been provided to load in all of the tweets into an array.

In the first task, you should create a toString() method of the Tweet class, so that all of the information about a tweet is returned in an organized, printable fashion. The string should be formatted as follows:

date, time
retweets =  number of retweets
likes =  number of likes
text
You should then fill in a loop in the printFirstFive method to loop through and print the first five tweets. If you've done this properly, you should see the output below. Note how they're not in any particular order. We will address this in the next task.

    2018/10/04, 16:40:06
    retweets: 148
    likes: 880
    The raid event Loyalty's Requiem is now available in #DragaliaLost! This marks the appearance of Celiera, an adventurer who will join your party if you increase your Friendship level with her. 
    
    2019/10/08, 18:59:28
    retweets: 303
    likes: 2403
    "Our vision for this game during development was to create a diorama world in which Link would be a 10cm-or-so tall figurine."  Read more from Graphic Refining Director Yoshiki Haruhana on the visuals for the Legend of #Zelda: Link's Awakening.    
    
    2019/03/20, 20:30:00
    retweets: 130
    likes: 1255
    Don’t flip out! #CaptainToad: Treasure Tracker – Special Episode turns things upside down with new courses and challenges. Which course is your favorite so far? 
    
    2019/02/09, 16:33:29
    retweets: 138
    likes: 1250
    The competition is heating up and the first of the #SmashBrosUltimate #NintendoNAO19 Qualifier Finals are starting in just a half hour! Tune into the stream and see who will be the first to qualify for the Grand Finals at #PAXEast!  📺    
    
    2020/03/26, 21:59:22
    retweets: 346
    likes: 2304
    As a special #PokemonSwordShieldEX early-purchase bonus, you can receive Leon’s cap and tights upon release of The Isle of Armor! Select the option to receive a Mystery Gift via the internet when the expansion releases to receive and use the items.   
    

Part 2: Sorting By Date (6 Points)

For the second task, you should create a comparator in the Tweet class to sort the tweets in ascending order of date. Sort first by the date String, and if there's a tie, sort by the time String. Once you've done this, use Arrays.sort to sort the array, and print out the first 5 tweets in order, as well as the last tweet, in the printFirstFiveByDate method. If this worked properly, you should see the tweets below. Notice how tweet 2-5 tie on the date, but they are sorted properly by time. Noticed how the last tweet occurred last week (which is when I started creating this assignment)

    2018/10/01, 21:49:14
    retweets: 439
    likes: 2912
    Yoshi and Bowser are keeping the Mushroom Kingdom bakeries busy in the Pie Hard minigame! #SuperMarioParty arrives on #NintendoSwitch 10/5!   

    2018/10/02, 15:00:00
    retweets: 485
    likes: 2554
    The legendary Blue Bomber returns in a new side-scrolling adventure that blends classic, challenging 2D platforming action with a fresh look. Mega Man 11 for #NintendoSwitch is available now!  

    2018/10/02, 16:00:40
    retweets: 77
    likes: 621
    The #FEHeroes Voting Gauntlet: Fathers and Daughters is here! During the event you can also earn Battle Flags along with Orbs, Sacred Coins, and Refining Stones via quests.  View current status of the event here:  

    2018/10/02, 17:30:05
    retweets: 66
    likes: 590
    See which creations were selected as Grand Prize winners for the #NintendoLabo Creators Contest No. 2!   

    2018/10/02, 18:00:00
    retweets: 742
    likes: 4376
    It’s almost game time! #SuperMarioParty launches on #NintendoSwitch in just 3 days! 


    ...

    2020/04/21, 20:31:56
    retweets: 1168
    likes: 8829
    The Nature Day event runs from 4/23 to 5/4, and it’s a great opportunity to help your island flourish with foliage! Fulfill special limited time Nature Day activities to earn extra Nook Miles, like planting shrub starts, water plants, and more. #ACNH #AnimalCrossing 

Tips

  • You may want to go back and review the module on comparators and sorting.
  • The String class has a built-in comparator, so you should at some point call s1.compareTo(s2), where s1 and s2 are some strings.

Part 3: Most/Least Popular Tweets (7 Points)

In this part of the assignment, you should fill in the getMostPopularTweet method to return the tweet with the most likes. Then, create a similar method getLeastPopularTweet to return the one with the least likes. To check to make sure this works correctly, the most popular tweet should have over 350,000 likes, while the least popular one should have under 300.

Part 4: Most Used Words (12 Points)

In this part of the assignment, you should print out the top 200 most used words across the text of all tweets. The easiest way to do this is to use a HashMap whose key is a word and whose value is the number of times that word showed up across all tweets (i.e. the "word count"). To fill in this map, loop through all of the words across all tweets (see the hint below on how to setup such a loop). If you've seen the word key before, change the value to be previous count plus 1. Otherwise, if this is your first time seeing it, create an entry for the word in the map, and initialize its count to be 1.

Once you're finished filling out the map, you can copy all of the information from the map over to an array. It's easiest if you create a new class (e.g. class Word) with a private member variable for the word and a private member variable for the count, and then you have a comparator that sorts in decreasing order by the count. Then, you can use Arrays.sort to sort the array of words.

If you've done this properly and followed the hints below, then the most 200 used words, in descending order of count, should be as below. Notice how the most used words are pretty standard filler words (the/and/to/in/of/..), but that they start to become more topical after this.

the: 3377
and: 1854
to: 1841
in: 1497
of: 1412
a: 1282
on: 1130
for: 879
your: 771
you: 708
with: 695
is: 585
new: 523
#nintendoswitch: 469
this: 448
from: 387
available: 381
at: 342
now: 329
be: 315
are: 311
nintendo: 306
will: 287
out: 251
game: 240
as: 232
can: 232
get: 231
up: 225
games: 219
when: 217
some: 216
#nintendoswitch!: 202
have: 189
more: 187
all: 186
special: 180
or: 179
by: 172
play: 171
                                        
that: 171
an: 169
pokémon: 149
it: 147
super: 145
has: 138
what: 133
coming: 132
check: 125
three: 121
take: 118
one: 117
about: 116
kit: 115
legend: 113
–: 109
ready: 106
into: 106
time: 103
his: 99
world: 98
like: 98
sure: 95
battle: 95
it’s: 94
now!: 94
their: 94
find: 94
adventure: 93
but: 92
if: 91
see: 91
off: 90
through: 89
just: 88
-: 86
team: 86
way: 86
#smashbrosultimate: 86
join: 86
#feheroes: 85
which: 84
make: 83
how: 83
krysta: 83
who: 81
you’ll: 80
#zelda:: 80
latest: 80
also: 79
episode: 78
experience: 78
#fireemblem:: 76
fun: 75
hero: 75
first: 74
look: 72
learn: 72
we: 72
heroes: 72
watch: 71
so: 71
day: 70
only: 70
free: 69
back: 68
they: 66
know: 66
been: 66
action: 66
#nintendoswitch.: 65
great: 65
pt: 65
mario: 65
you’re: 65
#supermariomaker2: 65
even: 65
friends: 64
tune: 64
them: 63
    
comes: 63
ultimate: 61
island: 60
use: 60
#eshop!: 60
releases: 59
featuring: 59
#pokemonswordshield: 59
favorite: 59
chance: 59
these: 58
start: 57
don’t: 57
3: 56
its: 56
full: 56
launches: 56
here:: 56
during: 56
set: 56
save: 55
#animalcrossing:: 55
black: 54
next: 54
help: 54
#nintendotreehouselive: 53
pre-purchase: 53
fight: 53
online: 53
other: 53
over: 53
week’s: 52
#nintendoswitchonline: 52
#indieworld: 51
system: 51
do: 50
arrives: 50
event: 50
until: 50
link’s: 49
most: 49
go: 48
houses: 48
own: 48
edition: 48
story: 48
there’s: 48
share: 47
explore: 47
looking: 47
starting: 47
#nintendopower: 47
playing: 47
2019: 47
definitive: 47
might: 46
legendary: 46
he: 45
there: 45
fire: 45
celebrate: 45
3:: 44
stop: 44
today: 44
#nintendominute: 44
indie: 44
exclusively: 44
switch: 44
including: 43
two: 43
alliance: 43
everyone: 43
together: 43
age: 43
vr: 42
download: 42
characters: 42
galar: 42
4: 41
dlc: 41
    

Tips

  • Loop Hint: We want each word to be lowercase so that it gets counted as the same word regardless of capitalization. Here's how you should start off a loop that pulls out the lowercase version of every word in every tweet, and which also takes care of empty words

  • Recall that for some HashMap mapHashMap> will create an ArrayList that contains all of the keys in a HashMap. You can use this to pull out a full "vocabulary" of all of the words used across all tweets. Here, type is most likely String, since your map should have a String as a key and an Integer as a value.