<jupyter_start><jupyter_text>Import all the required modules<jupyter_code># json for dumping json object to json 
# twitter api for getting info from your twitter handler
# collections for handling collections
# to install twitter pip install python-twitter 
import json
import twitter
import collections
# get your own keys,secret and tokens from https://developer.twitter.com/
customer_key = "<KEY>"
customer_secret ="<KEY>"
access_token = "<KEY>"
access_token_secret = "<KEY>"
api = twitter.Api(consumer_key=customer_key,
                  consumer_secret=customer_secret,
                  access_token_key=access_token,
                  access_token_secret=access_token_secret)
# get your followers and following infos 
followers = api.GetFollowers()
following = api.GetFriends()
# follower and following jsons to save locally
follower_json = {}
following_json = {}
for u in followers:
  follower_json[u.id_str] = json.loads(str(u))
for u in following:
  following_json[u.id_str] = json.loads(str(u))
# save followers info into followers.json
with open("followers.json", "w") as file:
    json.dump(follower_json, file)
# save followers info into following.json
with open("following.json", "w") as file:
    json.dump(following_json, file)
# I use my own stop words from stop_words.txt to filter 
stop_words = []
f = open("stop_words.txt", encoding='utf-8', mode='r+')
for x in f:
  stop_words.append(x.lower().strip())<jupyter_output><empty_output><jupyter_text>Analyze the following users info<jupyter_code># concat all users description and filter all stops words from the concatenated user descrition
description = ' '.join([user.description.lower().strip() for user in following ])
description = ' '.join([word for word in description_str.split() if word not in stop_words]).replace(".","")
# create a dictionary of words along with their count in description string
words = dict(collections.Counter(description_str.split()))
# sort the words with respective to their count value
sorted_x = sorted(words.items(), key=lambda kv: kv[1])[::-1]
#get top fifty words and their count 
#print the top fifty result
#print(sorted_x[0:50])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10599078341013825, 'fraction_numerical': 0.0027649769585253456, 'mean_word_length': 5.167613636363637, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '615778', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 656, 'n_tokens_neox': 635, 'n_words': 209, 'path': 'Twitter user analysis.ipynb', 'repo_name': 'jigyasup/twitter_user_analysis', 'size': '2267'}