Python code retrieve empty list when analyzing terms of frequencies using twitter APIs

the result when I run the analysis to the tweets comes empty as below there is nothing wrong with the code but the result is an empty list!

result is below []

import re
import operator
import json
from collections import Counter
from nltk.corpus import stopwords
from nltk import bigrams
import string
from collections import defaultdict
import sys
com = defaultdict(lambda: defaultdict(int))
fname = '/content/covid19.json'
with open(file, 'r') as f:
  count_all = Counter()
  for line in f.readlines():
    if line.startswith('{'):
      tweet = json.loads(line)
      terms_only = [term for term in preprocess(tweet['text']) if term not in stop and not term.startswith(('@', '#'))]
      count_all.update(terms_only)
print(count_all.most_common(5))


Read more here: https://stackoverflow.com/questions/67169240/python-code-retrieve-empty-list-when-analyzing-terms-of-frequencies-using-twitte

Content Attribution

This content was originally published by Ahd Abu Alrob at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: