ZeeAI1's picture
Update app.py
6243b99 verified
raw
history blame
1.99 kB
import streamlit as st
from transformers import pipeline
# App Title
st.title("πŸ§‘β€πŸŽ“ Advanced AI English Correction & Improvement")
# Load Google's FLAN-T5-LARGE model (cached)
@st.cache_resource
def load_correction_model():
return pipeline("text2text-generation", model="google/flan-t5-large")
correction_model = load_correction_model()
# User input
user_text = st.text_area("Enter your sentence, paragraph, or text here:", height=200)
# Correction and analysis logic
if st.button("Correct & Improve"):
if not user_text.strip():
st.warning("⚠️ Please enter text to analyze!")
else:
prompt = f"Correct the grammar, punctuation, and improve readability: {user_text}"
corrected_output = correction_model(prompt, max_length=512, clean_up_tokenization_spaces=True)
improved_text = corrected_output[0]['generated_text']
# Display Results
st.subheader("βœ… Corrected & Improved Text:")
st.write(improved_text)
# Provide detailed explanation (AI-based)
st.subheader("πŸ“ What's improved:")
if user_text != improved_text:
st.markdown("- Improved sentence structure & readability.")
st.markdown("- Corrected grammar & punctuation.")
st.markdown("- Enhanced clarity & coherence.")
st.info("Review the corrected text carefully to better understand punctuation, grammar rules, and style improvements.")
else:
st.success("No issues found. Excellent writing!")
# Learning recommendations
st.subheader("πŸ“š Tips to Learn & Improve:")
st.markdown("""
- Review punctuation usage (commas, question marks, exclamation points).
- Practice sentence structuring for clarity and readability.
- Use resources like [Grammarly](https://www.grammarly.com/blog/category/handbook/) and [Purdue OWL](https://owl.purdue.edu/owl/purdue_owl.html) to enhance your writing skills.
""")