import gradio as gr import spacy from transformers import pipeline # Load models nlp = spacy.load("en_core_web_lg") vocab_model = pipeline("text-classification", model="roberta-base") def analyze_essay(essay): # Vocabulary analysis vocab_score = vocab_model(essay)[0]['score'] * 9 # Grammar check (simple version) grammar_score = 9 - min(8, essay.count(' ') // 50) # Mock grammar score return { "Vocabulary Band": round(vocab_score, 1), "Grammar Band": grammar_score, "Overall Band": round((vocab_score + grammar_score) / 2, 1) } with gr.Blocks() as demo: gr.Markdown("## IELTS Writing Evaluator") essay_input = gr.Textbox(label="Paste Your Essay", lines=10) output = gr.JSON() submit = gr.Button("Evaluate") submit.click(analyze_essay, inputs=essay_input, outputs=output) demo.launch()