Spaces:
Build error
Build error
Commit
Β·
d9adf81
1
Parent(s):
49db3a9
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,10 +18,17 @@ def get_first_subword(word):
|
|
| 18 |
except:
|
| 19 |
return tokenizer(word, add_special_tokens=False)['input_ids'][0]
|
| 20 |
|
| 21 |
-
word_to_lookup =
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
hits
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
except:
|
| 19 |
return tokenizer(word, add_special_tokens=False)['input_ids'][0]
|
| 20 |
|
| 21 |
+
def search(word_to_lookup, num_neighbors=20):
|
| 22 |
+
word_to_lookup = "##lity"
|
| 23 |
+
i = get_first_subword(word_to_lookup)
|
| 24 |
+
_ , I = index.search(input_embeddings[i:i+1], num_neighbors)
|
| 25 |
+
hits = lookup_table.take(I[0])
|
| 26 |
+
return hits.values
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
iface = gr.Interface(
|
| 30 |
+
fn=search,
|
| 31 |
+
inputs=gr.Textbox(lines=1, placeholder="Enter token..."),
|
| 32 |
+
outputs=gr.Textbox(label="Results"),
|
| 33 |
+
)
|
| 34 |
+
iface.launch(enable_queue=True, debug=True, show_error=True)
|