Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -24,16 +24,19 @@
|
|
24 |
|
25 |
|
26 |
import os
|
|
|
27 |
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
28 |
import gradio as gr
|
29 |
from nltk.tokenize import sent_tokenize
|
30 |
from difflib import SequenceMatcher
|
31 |
|
32 |
# Ensure the necessary NLTK data is downloaded
|
33 |
-
|
|
|
|
|
34 |
|
35 |
# Load a pre-trained T5 model specifically fine-tuned for grammar correction
|
36 |
-
tokenizer = T5Tokenizer.from_pretrained("prithivida/grammar_error_correcter_v1")
|
37 |
model = T5ForConditionalGeneration.from_pretrained("prithivida/grammar_error_correcter_v1")
|
38 |
|
39 |
# Function to perform grammar correction
|
@@ -80,7 +83,7 @@ interface = gr.Interface(
|
|
80 |
"In the past, did you have a similar experience where you found something valuable or interesting? Tell the story. Describe what you found, what you did with it, and how you felt about your decision.\n\n"
|
81 |
"Remember to use past tense in your writing.\n\n"
|
82 |
"<b>A student's sample answer:</b>\n"
|
83 |
-
"<blockquote>When I was 10, I
|
84 |
)
|
85 |
)
|
86 |
|
|
|
24 |
|
25 |
|
26 |
import os
|
27 |
+
import nltk
|
28 |
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
29 |
import gradio as gr
|
30 |
from nltk.tokenize import sent_tokenize
|
31 |
from difflib import SequenceMatcher
|
32 |
|
33 |
# Ensure the necessary NLTK data is downloaded
|
34 |
+
nltk.download('punkt')
|
35 |
+
nltk.download('averaged_perceptron_tagger')
|
36 |
+
nltk.download('wordnet')
|
37 |
|
38 |
# Load a pre-trained T5 model specifically fine-tuned for grammar correction
|
39 |
+
tokenizer = T5Tokenizer.from_pretrained("prithivida/grammar_error_correcter_v1", legacy=False)
|
40 |
model = T5ForConditionalGeneration.from_pretrained("prithivida/grammar_error_correcter_v1")
|
41 |
|
42 |
# Function to perform grammar correction
|
|
|
83 |
"In the past, did you have a similar experience where you found something valuable or interesting? Tell the story. Describe what you found, what you did with it, and how you felt about your decision.\n\n"
|
84 |
"Remember to use past tense in your writing.\n\n"
|
85 |
"<b>A student's sample answer:</b>\n"
|
86 |
+
"<blockquote>When I was 10, I found an old coin in my backyard. I kept it for a while and showed it to my friends. They were impressed and said it might be valuable. Later, I took it to a local antique shop, and the owner told me it was very old. I decided to give it to the museum in my town. The museum was happy and put it on display. I felt proud of my decision.<br><br><i>Copy and paste to try.</i></blockquote>"
|
87 |
)
|
88 |
)
|
89 |
|