fix 'Hello' in first result
Browse files
app.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from utils import *
|
| 3 |
|
| 4 |
-
def
|
| 5 |
text = character_replacement(text, num_errors=3)
|
| 6 |
-
|
| 7 |
return text
|
| 8 |
|
| 9 |
-
demo = gr.Interface(fn=
|
| 10 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from utils import *
|
| 3 |
|
| 4 |
+
def final_result(text):
|
| 5 |
text = character_replacement(text, num_errors=3)
|
|
|
|
| 6 |
return text
|
| 7 |
|
| 8 |
+
demo = gr.Interface(fn=final_result, inputs="text", outputs="text")
|
| 9 |
demo.launch()
|
utils.py
CHANGED
|
@@ -112,9 +112,9 @@ def character_replacement(text, num_errors=1):
|
|
| 112 |
}
|
| 113 |
|
| 114 |
text = list(text)
|
| 115 |
-
|
| 116 |
indices = random.sample(range(len(text)), num_errors)
|
| 117 |
-
|
| 118 |
|
| 119 |
for index in indices:
|
| 120 |
if text[index].lower() in keyboard:
|
|
@@ -124,7 +124,7 @@ def character_replacement(text, num_errors=1):
|
|
| 124 |
text[index] = replacement_char
|
| 125 |
|
| 126 |
final_text = ''.join(text)
|
| 127 |
-
|
| 128 |
return final_text
|
| 129 |
|
| 130 |
|
|
|
|
| 112 |
}
|
| 113 |
|
| 114 |
text = list(text)
|
| 115 |
+
|
| 116 |
indices = random.sample(range(len(text)), num_errors)
|
| 117 |
+
|
| 118 |
|
| 119 |
for index in indices:
|
| 120 |
if text[index].lower() in keyboard:
|
|
|
|
| 124 |
text[index] = replacement_char
|
| 125 |
|
| 126 |
final_text = ''.join(text)
|
| 127 |
+
|
| 128 |
return final_text
|
| 129 |
|
| 130 |
|