teatwots commited on
Commit
f8c1b24
1 Parent(s): 700ece2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -9
app.py CHANGED
@@ -1,4 +1,7 @@
1
  # app.py
 
 
 
2
  from transformers import T5Tokenizer, T5ForConditionalGeneration
3
  import gradio as gr
4
  import nltk
@@ -6,11 +9,6 @@ from nltk.tokenize import sent_tokenize, word_tokenize
6
  from nltk.corpus import wordnet as wn
7
  from difflib import SequenceMatcher
8
 
9
- # Download necessary resources
10
- nltk.download('punkt')
11
- nltk.download('averaged_perceptron_tagger')
12
- nltk.download('wordnet')
13
-
14
  # Load a pre-trained T5 model specifically fine-tuned for grammar correction
15
  tokenizer = T5Tokenizer.from_pretrained("prithivida/grammar_error_correcter_v1")
16
  model = T5ForConditionalGeneration.from_pretrained("prithivida/grammar_error_correcter_v1")
@@ -73,14 +71,13 @@ def grammar_check(text):
73
 
74
  verb_forms_str = "\n".join(verb_forms_list)
75
 
76
- # Return combined result
77
- return f"{corrected_text}\n\n<b>Revised Verb Forms:</b>\n{verb_forms_str}"
78
 
79
  # Create Gradio interface with a writing prompt
80
  interface = gr.Interface(
81
  fn=grammar_check,
82
  inputs="text",
83
- outputs="html", # Change output type to HTML
84
  title="Grammar Checker",
85
  description=(
86
  "Enter text to check for grammar mistakes.\n\n"
@@ -93,4 +90,3 @@ interface = gr.Interface(
93
 
94
  # Launch the interface
95
  interface.launch()
96
-
 
1
  # app.py
2
+ import os
3
+ os.system('python download.py')
4
+
5
  from transformers import T5Tokenizer, T5ForConditionalGeneration
6
  import gradio as gr
7
  import nltk
 
9
  from nltk.corpus import wordnet as wn
10
  from difflib import SequenceMatcher
11
 
 
 
 
 
 
12
  # Load a pre-trained T5 model specifically fine-tuned for grammar correction
13
  tokenizer = T5Tokenizer.from_pretrained("prithivida/grammar_error_correcter_v1")
14
  model = T5ForConditionalGeneration.from_pretrained("prithivida/grammar_error_correcter_v1")
 
71
 
72
  verb_forms_str = "\n".join(verb_forms_list)
73
 
74
+ return corrected_text, verb_forms_str
 
75
 
76
  # Create Gradio interface with a writing prompt
77
  interface = gr.Interface(
78
  fn=grammar_check,
79
  inputs="text",
80
+ outputs=["html", "text"], # Two output boxes: HTML for corrected text, Text for verb forms list
81
  title="Grammar Checker",
82
  description=(
83
  "Enter text to check for grammar mistakes.\n\n"
 
90
 
91
  # Launch the interface
92
  interface.launch()