Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,29 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
from
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import spacy
|
| 3 |
+
from transformers import pipeline
|
| 4 |
|
| 5 |
+
# Load models
|
| 6 |
+
nlp = spacy.load("en_core_web_lg")
|
| 7 |
+
vocab_model = pipeline("text-classification", model="roberta-base")
|
| 8 |
+
|
| 9 |
+
def analyze_essay(essay):
|
| 10 |
+
# Vocabulary analysis
|
| 11 |
+
vocab_score = vocab_model(essay)[0]['score'] * 9
|
| 12 |
+
|
| 13 |
+
# Grammar check (simple version)
|
| 14 |
+
grammar_score = 9 - min(8, essay.count(' ') // 50) # Mock grammar score
|
| 15 |
+
|
| 16 |
+
return {
|
| 17 |
+
"Vocabulary Band": round(vocab_score, 1),
|
| 18 |
+
"Grammar Band": grammar_score,
|
| 19 |
+
"Overall Band": round((vocab_score + grammar_score) / 2, 1)
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
with gr.Blocks() as demo:
|
| 23 |
+
gr.Markdown("## IELTS Writing Evaluator")
|
| 24 |
+
essay_input = gr.Textbox(label="Paste Your Essay", lines=10)
|
| 25 |
+
output = gr.JSON()
|
| 26 |
+
submit = gr.Button("Evaluate")
|
| 27 |
+
submit.click(analyze_essay, inputs=essay_input, outputs=output)
|
| 28 |
+
|
| 29 |
+
demo.launch()
|