A library to collect tweets, clean it (pre-processing), translate it, and create analytics with Textblob and VADER methods.
- Python 3.6+
pip install feelingtweets
Unfortunately, this library requires some experimental versions of twint, you should install with this cmd:
pip3 install --upgrade git+https://github.com/twintproject/twint.git#egg=twint
import feelingtweets as ft
config = Config(input_collect_language="es")
collector = ft.TweetCollector(config)
cleaner = ft.Cleaner(config)
traductor = ft.Traductor(config)
analizer = ft.Analizer()
# Twitter API search
search = "(ECUADOR OR TRI OR FEF) AND (FUTBOL OR FÚTBOL OR partido OR selección OR seleccion OR copa OR mundial)"
query = ft.Query(search, date_start="2021-09-06", limit_tweets=100)
# collecting phase
collected_data = collector.collect(query, True)
# pre-processing phase
cleaned_data = cleaner.clean(collected_data, True)
# translateting phase
translate_data = traductor.traduce(cleaned_data, True)
if translate_data is not None:
# analize with both methods
analized_data = analizer.analize(translate_data["traduced"])
# standard pandas DataFrame with text, texblob_score, vader_score
print(analized_data)
# analize with textblob method
analized_data = analizer.analize_with_textblob(translate_data["traduced"])
# standard pandas DataFrame with text, score
print(analized_data)
# analize with VADER method
analized_data = analizer.analize_with_vader(translate_data["traduced"])
# standard pandas DataFrame with text, score
print(analized_data)
This project has made for educational purposes, to practice about data mining techniques and get some useful experience on Python, and libs related to data science.