Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from happytransformer import HappyTextToText, TTSettings
|
3 |
+
|
4 |
+
def check_grammar(sentence):
|
5 |
+
happy_tt = HappyTextToText("T5", "leslyarun/grammatical-error-correction")
|
6 |
+
args = TTSettings(num_beams=5, min_length=1)
|
7 |
+
# Add the prefix "grammar: " before each input
|
8 |
+
result = happy_tt.generate_text("grammar: " + sentence, args=args)
|
9 |
+
return result
|
10 |
+
|
11 |
+
demo = gr.Interface(check_grammar, inputs=['text'],
|
12 |
+
outputs="text",
|
13 |
+
title = "English Grammar Corrector")
|
14 |
+
|
15 |
+
if __name__ == "__main__":
|
16 |
+
demo.launch(debug=True)
|