Spaces:
Sleeping
Sleeping
Download utils/classifier_utils.py from vishal1232006/MemeScope: direct link, hf CLI and curl.
- Browser
- Download file 1.6 kB
-
https://huggingface.co/spaces/vishal1232006/MemeScope/resolve/main/utils/classifier_utils.py
- Command line
-
hf download hf://spaces/vishal1232006/MemeScope/utils/classifier_utils.py
-
curl -L -o classifier_utils.py https://huggingface.co/spaces/vishal1232006/MemeScope/resolve/main/utils/classifier_utils.py
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" | |