python 3 question 3b the best words 4 points write a function count occurences jsonu 5154067
PYTHON 3
Question 3b: The Best Words [4 points] Write a function count occurences ( jsonurl, word) that counts the number of times that word occurs across all of the given tweets. This should be case insensitive, but for simplicity, you only need to match whole words. Make sure you match whole words only, and not substrings. For example, if word =”dont”, then “dont”, “DONT”, and “dOnT” would all count, but “perioDONTal” should not. Remove all punctuation in the text of the tweet (if there is any). “don't” should be correctly counted for word=”dont”. n [42]from string import punctuation print(“Remove all of these symbols from the tweets: “, punctuation) “#$8&' ),-./: ;<=>?@ [ ]^_* { | }> Remove all of these symbols from the tweets import json import urllib.request from string import punctuation n[45] def count_occurences (jsonurl,word): resp requests.get(jsonurl) data-resp.json() count-0 in data: text-k['text'] text-text.split () for k for v in text: if word.lower)==v.1lower): count +=1 return count count occurences('https://dl.dropboxusercontent.com/s/mihdrns gb6 ebauf/trump_tweets.json', 'crooked') n [46] == 232 ut [ 46 ] : False n [12]count_occurences('https://dl.dropboxusercontent.com/s/mihdrnsgb6ebauf/trump_tweets.json', great') =603 ut [ 12 ] : False n [13]:count occurences('https://dl.dropboxusercontent.com/s/mihdrns gb6 ebauf/trump tweets.json', 'big')– 164 ut [ 13 ]: False n 371: count occurences'https://dl.dropboxusercontent.com/s/mihdrnsqb6 ebauf/trump tweets.json', 'words' ==24