Spaces:
Sleeping
Sleeping
import streamlit as st | |
from transformers import pipeline | |
from langdetect import detect | |
import language_tool_python | |
# Initialize models | |
summarizer = pipeline("summarization") | |
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-ur") | |
corrector = language_tool_python.LanguageTool('en-US') | |
st.set_page_config(page_title="CSS AI Assistant by Komal", layout="wide") | |
st.title("π CSS AI Assistant π΅π°") | |
st.write("Helping students with news summaries, precis, essays & more β for free!") | |
menu = st.sidebar.radio("Select Feature", [ | |
"Daily News Summary", | |
"Precis Evaluation", | |
"Essay Feedback", | |
"Saved Notes" | |
]) | |
# --- Daily News Summary --- | |
if menu == "Daily News Summary": | |
st.header("π° AI-Powered News Summarizer") | |
user_news = st.text_area("Paste or write today's news:", height=200) | |
lang = st.radio("Language", ["English", "Urdu"]) | |
if st.button("Summarize") and user_news: | |
summary = summarizer(user_news, max_length=100, min_length=30, do_sample=False)[0]['summary_text'] | |
if lang == "Urdu": | |
translation = translator(summary)[0]['translation_text'] | |
st.success("Summary in Urdu:") | |
st.write(translation) | |
else: | |
st.success("Summary in English:") | |
st.write(summary) | |
# --- Precis Evaluation --- | |
elif menu == "Precis Evaluation": | |
st.header("βοΈ Precis Evaluation Tool") | |
precis_input = st.text_area("Enter your precis for evaluation:", height=200) | |
if st.button("Evaluate Precis") and precis_input: | |
matches = corrector.check(precis_input) | |
corrected = language_tool_python.utils.correct(precis_input, matches) | |
st.success("β Corrected Precis:") | |
st.write(corrected) | |
st.warning("β οΈ Mistakes Highlighted:") | |
for m in matches: | |
st.write(f"- {m.ruleId}: {m.message} (at position {m.offset})") | |
# --- Essay Feedback --- | |
elif menu == "Essay Feedback": | |
st.header("ποΈ Essay Evaluation Tool") | |
essay_input = st.text_area("Paste your essay here:", height=300) | |
if st.button("Evaluate Essay") and essay_input: | |
matches = corrector.check(essay_input) | |
corrected = language_tool_python.utils.correct(essay_input, matches) | |
st.success("β Suggestions:") | |
st.write(corrected) | |
st.info(f"π {len(matches)} grammar/style issues found.") | |
for m in matches: | |
st.write(f"- {m.message} (Rule: {m.ruleId})") | |
# --- Saved Notes (Stub) --- | |
elif menu == "Saved Notes": | |
st.header("πΎ Saved Notes") | |
st.info("Note saving functionality coming soon!") | |
st.write("You will be able to store and download your summaries and corrected answers here.") |