File size: 879 Bytes
ced22e1
 
 
 
4c32405
ced22e1
 
 
 
 
 
 
 
 
 
5077404
 
 
 
 
 
 
 
 
ced22e1
 
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
import streamlit as st
from transformers import pipeline

# تحميل النموذج
classifier = pipeline("zero-shot-classification", model="cross-encoder/nli-distilroberta-base")

# عنوان التطبيق
st.title("Text Classification App")

# إدخال النص
text = st.text_area("Enter your text here:")

# زر التصنيف
if st.button("Classify"):
    if text:
        # تحديد الفئات التي تريد تصنيف النص إليها
        categories = ["shopping", "gaming", "streaming"]
        result = classifier(text, categories)
        
        # الحصول على الفئة الأكثر احتمالاً
        best_category = result['labels'][0]
        score = round(result['scores'][0], 2)
        
        st.write(f"Classification Result: {best_category} (Confidence: {score})")
    else:
        st.warning("Please enter some text!")