- TwitterSplitShows(JsonStr, ShowsList)
This function takes a string with a .json file name and a dictionary
ShowsList as inputs and returns a dictionary with the tweets in the .json
file sorted according to the keys in ShowsList.
The inputs of the function are:
- JsonStr: A string referring to a .json file that contains downloaded tweets.
- ShowsList: A dictionary where each key is a TV show abbreviation, and the
corresponding keys are lists of the specific keywords for which
tweets have been downloaded for the TV shows.
The outputs of the function are:
- TVShowsSorted: A dictionary with keys as in ShowsList and where values are
tweets containing one or more of the keywords corresponding
to this key.
Specifically, the above is done by looping over all tweets (lines) in the
.json file. For each tweet, a loop is run over all keys in ShowsLists, and
for each key the keywords (: elements in lists constituting the values in
ShowsList) are compared to the text of the tweet. If any of the keywords are
contained in the tweet, the tweet is appended to the list of tweets
corresponding to this key in TVShowsSorted.