politweet / textclassifier /TextClassifier.py
Demea9000's picture
added skeleton to TextClassifier
130dfd8
raw
history blame
1.11 kB
import openai
import regex as re
from twitterscraper import TwitterScraper
from datetime import date
class TextClassifier:
def __init__(self, model_name="text-davinci-002", from_date='2022-01-01', to_date=str(date.today()), num_tweets=100):
"""
Initializes the TextClassifier.
:param model_name: name of the model from openai.
:param from_date: string of the format 'YYYY-MM-DD'.
:param to_date: string of the format 'YYYY-MM-DD'.
:param num_tweets: integer value of the maximum number of tweets to be scraped.
"""
self.model_name = model_name
self.df = TwitterScraper.TwitterScraper(from_date, to_date, num_tweets)
self.api_key = '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'
def classify_sentiment(self, text: str):
"""
Classifies the sentiment of a text.
"""
def classify_topics(self, text: str):
"""
Classifies the topics of a text.
"""
def __repr__(self):
return f"TextClassifier(df={self.df}, col={self.col}, model_name={self.model_name})"