Spaces:
Sleeping
Sleeping
Commit
Β·
42bee4e
1
Parent(s):
ca7aa50
Update code: fix app.py, paragraph_checker.py and add README config
Browse files- README.md +26 -0
- app.py +2 -4
- paragraph_checker.py +4 -1
README.md
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Convomate Paragraph Checker
|
3 |
+
emoji: π
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: purple
|
6 |
+
sdk: docker
|
7 |
+
sdk_version: "3.8.2"
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
---
|
11 |
+
|
12 |
+
# π Convomate Paragraph Checker
|
13 |
+
|
14 |
+
This Space runs a Flask app for grammar and tense correction using:
|
15 |
+
|
16 |
+
- `language_tool_python` for grammar fixes
|
17 |
+
- T5 Transformer (`Vamsi/T5_Paraphrase_Paws`) for tense rewriting
|
18 |
+
|
19 |
+
### π How to Use
|
20 |
+
|
21 |
+
Send a POST request to `/correct_text` with:
|
22 |
+
|
23 |
+
```json
|
24 |
+
{
|
25 |
+
"paragraph": "your incorrect sentence here"
|
26 |
+
}
|
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
from flask import Flask, request, jsonify
|
2 |
-
from paragraph_checker import correct_paragraph
|
3 |
|
4 |
app = Flask(__name__)
|
5 |
|
@@ -30,8 +30,6 @@ def correct_text():
|
|
30 |
}), 500
|
31 |
|
32 |
if __name__ == '__main__':
|
33 |
-
# Initialize models at startup
|
34 |
-
from paragraph_checker import initialize_models
|
35 |
print("Loading ML models...")
|
36 |
try:
|
37 |
initialize_models()
|
@@ -39,4 +37,4 @@ if __name__ == '__main__':
|
|
39 |
except Exception as e:
|
40 |
print(f"Error loading models: {str(e)}")
|
41 |
|
42 |
-
app.run(host="0.0.0.0", port=5001, debug=True)
|
|
|
1 |
from flask import Flask, request, jsonify
|
2 |
+
from paragraph_checker import correct_paragraph, initialize_models
|
3 |
|
4 |
app = Flask(__name__)
|
5 |
|
|
|
30 |
}), 500
|
31 |
|
32 |
if __name__ == '__main__':
|
|
|
|
|
33 |
print("Loading ML models...")
|
34 |
try:
|
35 |
initialize_models()
|
|
|
37 |
except Exception as e:
|
38 |
print(f"Error loading models: {str(e)}")
|
39 |
|
40 |
+
app.run(host="0.0.0.0", port=5001, debug=True)
|
paragraph_checker.py
CHANGED
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
1 |
import language_tool_python
|
2 |
from transformers import T5ForConditionalGeneration, T5Tokenizer
|
3 |
|
@@ -64,4 +67,4 @@ def correct_paragraph(text):
|
|
64 |
fully_corrected = tense_correction(grammatically_correct)
|
65 |
print("After Grammar + Tense Correction:", fully_corrected)
|
66 |
|
67 |
-
return fully_corrected
|
|
|
1 |
+
import os
|
2 |
+
os.environ['TRANSFORMERS_CACHE'] = '/tmp/huggingface'
|
3 |
+
|
4 |
import language_tool_python
|
5 |
from transformers import T5ForConditionalGeneration, T5Tokenizer
|
6 |
|
|
|
67 |
fully_corrected = tense_correction(grammatically_correct)
|
68 |
print("After Grammar + Tense Correction:", fully_corrected)
|
69 |
|
70 |
+
return fully_corrected
|