Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -7,19 +7,22 @@ spell_corrector = pipeline("text2text-generation", model=model_id, max_length=10
|
|
7 |
|
8 |
|
9 |
|
10 |
-
|
|
|
11 |
d = Differ()
|
12 |
if text is None:
|
13 |
text = ""
|
14 |
-
corrected = spell_corrector(text)[0]['generated_text']
|
15 |
-
|
|
|
|
|
|
|
16 |
return [
|
17 |
(token[2:], token[0] if token[0] != " " else None)
|
18 |
-
for token in d.compare(text,
|
19 |
], corrected
|
20 |
|
21 |
|
22 |
-
|
23 |
demo = gr.Interface(
|
24 |
correct_spell,
|
25 |
[
|
|
|
7 |
|
8 |
|
9 |
|
10 |
+
|
11 |
+
def correct_spell(text, num_sequence=3):
|
12 |
d = Differ()
|
13 |
if text is None:
|
14 |
text = ""
|
15 |
+
# corrected = spell_corrector(text, num_return_sequences=3)[0]['generated_text']
|
16 |
+
corrected = spell_corrector(text,num_beams=5, num_return_sequences=num_sequence)
|
17 |
+
first_suggestion = corrected[0]['generated_text']
|
18 |
+
corrected = "\n\n".join([c['generated_text'] for c in corrected])
|
19 |
+
|
20 |
return [
|
21 |
(token[2:], token[0] if token[0] != " " else None)
|
22 |
+
for token in d.compare(text, first_suggestion)
|
23 |
], corrected
|
24 |
|
25 |
|
|
|
26 |
demo = gr.Interface(
|
27 |
correct_spell,
|
28 |
[
|