Spaces:
Running
Running
Initial commit
Browse files
app.py
CHANGED
@@ -14,7 +14,8 @@ import time
|
|
14 |
import os
|
15 |
|
16 |
def start_server():
|
17 |
-
os.system("python -m spacy download en_core_web_sm")
|
|
|
18 |
os.system("uvicorn InferenceServer:app --port 8080 --host 0.0.0.0 --workers 1")
|
19 |
|
20 |
def load_models():
|
@@ -161,43 +162,43 @@ def get_correction(input_text):
|
|
161 |
|
162 |
|
163 |
if __name__ == "__main__":
|
164 |
-
if not st.session_state['models_loaded']:
|
165 |
-
load_models()
|
166 |
-
|
167 |
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
|
|
|
|
|
|
201 |
|
202 |
|
203 |
|
|
|
14 |
import os
|
15 |
|
16 |
def start_server():
|
17 |
+
os.system("python -m spacy download en_core_web_sm")
|
18 |
+
spacy.load('en_core_web_sm')
|
19 |
os.system("uvicorn InferenceServer:app --port 8080 --host 0.0.0.0 --workers 1")
|
20 |
|
21 |
def load_models():
|
|
|
162 |
|
163 |
|
164 |
if __name__ == "__main__":
|
|
|
|
|
|
|
165 |
|
166 |
+
st.title('Gramformer')
|
167 |
+
st.subheader('A framework for correcting english grammatical errors')
|
168 |
+
st.markdown("Built for fun with π by Prithivi Da, The maker of [WhatTheFood](https://huggingface.co/spaces/prithivida/WhatTheFood), [Styleformer](https://github.com/PrithivirajDamodaran/Styleformer) and [Parrot paraphraser](https://github.com/PrithivirajDamodaran/Parrot_Paraphraser) | βοΈ [@prithivida](https://twitter.com/prithivida) |[[GitHub]](https://github.com/PrithivirajDamodaran)", unsafe_allow_html=True)
|
169 |
+
|
170 |
+
examples = [
|
171 |
+
"what be the reason for everyone leave the comapny",
|
172 |
+
"The girls's backpacks are gone in the morning",
|
173 |
+
"I am doing fine. How is you?",
|
174 |
+
"Each of you all should run fast",
|
175 |
+
"Matt like fish",
|
176 |
+
"the collection of letters was original used by the ancient Romans",
|
177 |
+
"We enjoys horror movies",
|
178 |
+
"Anna and Mike is going skiing",
|
179 |
+
"I walk to the store and I bought milk",
|
180 |
+
" We all eat the fish and then made dessert",
|
181 |
+
"I will eat fish for dinner and drank milk",
|
182 |
+
]
|
183 |
+
|
184 |
+
if not st.session_state['models_loaded']:
|
185 |
+
load_models()
|
186 |
+
|
187 |
+
nlp = spacy.load('en_core_web_sm')
|
188 |
+
annotator = errant.load('en', nlp)
|
189 |
+
|
190 |
+
input_text = st.selectbox(
|
191 |
+
label="Choose an example",
|
192 |
+
options=examples
|
193 |
+
)
|
194 |
+
st.write("(or)")
|
195 |
+
input_text = st.text_input(
|
196 |
+
label="Bring your own sentence",
|
197 |
+
value=input_text
|
198 |
+
)
|
199 |
+
|
200 |
+
if input_text.strip():
|
201 |
+
get_correction(input_text)
|
202 |
|
203 |
|
204 |
|