Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from transformers import pipeline | |
| # Load grammar correction model | |
| corrector = pipeline("text2text-generation", model="vennify/t5-base-grammar-correction") | |
| explainer = pipeline("text2text-generation", model="google/flan-t5-base") | |
| st.title("🧠 English Sentence Helper") | |
| st.write("Improve your grammar, get feedback, and learn from your mistakes.") | |
| user_input = st.text_area("✍️ Enter a sentence you want to check:") | |
| if st.button("Analyze"): | |
| if user_input: | |
| with st.spinner("Analyzing your sentence..."): | |
| corrected = corrector(user_input)[0]['generated_text'] | |
| explanation_prompt = f"Explain the grammatical errors in this sentence: {user_input}" | |
| improvement_prompt = f"Suggest improvements in grammar, vocabulary, or structure: {user_input}" | |
| explanation = explainer(explanation_prompt)[0]['generated_text'] | |
| improvements = explainer(improvement_prompt)[0]['generated_text'] | |
| st.success("✅ Analysis Complete!") | |
| st.markdown(f"**Original Sentence:** {user_input}") | |
| st.markdown(f"**Corrected Sentence:** {corrected}") | |
| st.markdown(f"**Grammar Explanation:** {explanation}") | |
| st.markdown(f"**Improvement Suggestions:** {improvements}") | |
| else: | |
| st.warning("Please enter a sentence.") | |