File size: 1,204 Bytes
15f0a29
cacd28d
 
15f0a29
 
 
 
 
 
 
 
 
f9f151f
cacd28d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d7064e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import streamlit as st
from transformers import pipeline

@st.cache_resource
def load_classifier():
    return pipeline(
        "zero-shot-classification",
        model="joeddav/xlm-roberta-large-xnli",  # or use a smaller model
        cache_dir="./hf_cache"
    )

classifier = load_classifier()

CATEGORIES = {
    "Family": "కుటుంబం",
    "Friendship": "స్నేహం",
    "Morality": "నీతి",
    "Hard Work": "శ్రమ",
    "Knowledge": "జ్ఞానం",
    "Devotion": "భక్తి",
    "Culture": "సంస్కృతి",
    "Literature": "సాహిత్యం",
    "Humility": "వినయం",
    "Patience": "సహనం",
    "Courage": "ధైర్యం",
    "Arrogance": "అహంకారం",
    "Love": "ప్రేమ",
    "Greed": "దురాశ",
    "Wisdom": "ఆలోచన",
    "Responsibility": "బాధ్యత",
    "Satire": "వ్యంగ్యం",
    "Politics": "రాజకీయం",
    "Wealth": "ధనము",
    "Time": "సమయం"
}

def classify_proverb(text):
    result = classifier(text, list(CATEGORIES.keys()))
    top_label = result["labels"][0]
    return CATEGORIES[top_label]