File size: 869 Bytes
1eb9619
 
 
57a7e0b
1eb9619
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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()