Spaces:
Running
Running
File size: 1,351 Bytes
e830305 cfd7476 e830305 cfd7476 e830305 7c8ae88 cfd7476 7c8ae88 e830305 cfd7476 39efac9 cfd7476 7c8ae88 cfd7476 7c8ae88 cfd7476 |
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 |
import streamlit as st
from agent import classify_emoji_text
# ✅ 页面配置
st.set_page_config(page_title="Emoji Offensive Text Detector", page_icon="🚨", layout="wide")
# ✅ 页面标题
st.title("🧠 Emoji-based Offensive Language Classifier")
st.markdown("""
This application translates emojis in a sentence and classifies whether the final sentence is offensive or not using two AI models.
- The **first model** translates emoji or symbolic phrases into standard Chinese text.
- The **second model** performs offensive language detection.
""")
# ✅ 输入区域
default_text = "你是🐷"
text = st.text_area("✍️ Input your sentence here:", value=default_text, height=150)
# ✅ 触发按钮
if st.button("🚦 Analyze"):
with st.spinner("🔍 Processing..."):
try:
translated, label, score = classify_emoji_text(text)
# 输出结果显示(修复多行字符串语法)
st.markdown("### 🔄 Translated sentence:")
st.code(translated, language="text")
st.markdown(f"### 🎯 Prediction: `{label}`")
st.markdown(f"### 📊 Confidence Score: `{score:.2%}`")
except Exception as e:
st.error(f"❌ An error occurred during processing:\n\n{e}")
else:
st.info("👈 Please input text and click the button to classify.")
|