MemeScope / utils /classifier_utils.py
vishal1232006's picture
Update utils/classifier_utils.py
ede87a4 verified
Raw History Blame Contribute Delete
1.6 kB
def classify_text(text: str) -> str:
"""
Extended meme intent classifier with multiple categories.
Uses simple keyword-based matching.
"""
if not text or text.strip() == "":
return "No text found"
text_lower = text.lower()
categories = {
"Humor Meme": ["😂", "🤣", "lol", "funny", "joke", "lmao", "haha"],
"Romantic Meme": ["love", "❤️", "crush", "romance", "kiss", "babe", "darling"],
"Violent Meme": ["kill", "murder", "fight", "blood", "gun", "angry", "😡", "attack"],
"Sad Meme": ["sad", "😭", "lonely", "depressed", "cry", "hurt", "pain", "tears"],
"Motivational Meme": ["success", "never give up", "goal", "dream", "believe", "achieve"],
"Sarcasm Meme": ["sure", "whatever", "yeah right", "sarcasm", "ironic", "duh"],
"Political Meme": ["vote", "president", "minister", "government", "politics"],
"Sports Meme": ["game", "football", "soccer", "basketball", "cricket", "team", "player"],
"Gaming Meme": ["gg", "noob", "gamer", "fps", "level up", "gaming", "console", "pc"],
"Wholesome Meme": ["cute", "wholesome", "puppy", "kitten", "family", "friends", "smile"],
"Dark Meme": ["dark", "evil", "demon", "death", "grave", "hell", "fear"],
"Work/Study Meme": ["office", "boss", "deadline", "exam", "homework", "school", "teacher"],
}
# Check each category
for category, keywords in categories.items():
if any(word in text_lower for word in keywords):
return category
# Default if no match
return "General Meme"