Spaces:
Runtime error
Runtime error
Hugo Pitorro
commited on
Commit
·
a2f49fc
1
Parent(s):
98ce4ad
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,8 +35,13 @@ def id_replace_complex(s, threshold=0.2):
|
|
| 35 |
|
| 36 |
masked = [s[:s.index(t)] + '<mask>' + s[s.index(t)+len(t):] for t in compl_tok]
|
| 37 |
cands = fill_pipe(masked)
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
for i, el in enumerate(compl_tok):
|
| 41 |
idx = s.index(el)
|
| 42 |
s = s[:idx] + replacements[i] + s[idx+len(el):]
|
|
|
|
| 35 |
|
| 36 |
masked = [s[:s.index(t)] + '<mask>' + s[s.index(t)+len(t):] for t in compl_tok]
|
| 37 |
cands = fill_pipe(masked)
|
| 38 |
+
# structure is different in 1 vs n complex words
|
| 39 |
+
replacements = [el['token_str'] if type(
|
| 40 |
+
el) == dict else el[0]['token_str'] for el in cands]
|
| 41 |
+
# some tokens get prefixed with space
|
| 42 |
+
replacements = [tok if tok.find(' ') == -1 else tok[1:]
|
| 43 |
+
for tok in replacements]
|
| 44 |
+
|
| 45 |
for i, el in enumerate(compl_tok):
|
| 46 |
idx = s.index(el)
|
| 47 |
s = s[:idx] + replacements[i] + s[idx+len(el):]
|