Commit
Β·
da7878b
1
Parent(s):
fa288e9
update app
Browse files
app.py
CHANGED
|
@@ -11,6 +11,7 @@ print("Model loaded successfully!")
|
|
| 11 |
|
| 12 |
def disambiguate_sentence(sentence):
|
| 13 |
results = []
|
|
|
|
| 14 |
for sentence in [sentence]:
|
| 15 |
outputs = model.generate(
|
| 16 |
**tokenizer([sentence], return_tensors="pt"),
|
|
@@ -20,8 +21,10 @@ def disambiguate_sentence(sentence):
|
|
| 20 |
)
|
| 21 |
decoded = tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
| 22 |
results.append(decoded)
|
|
|
|
|
|
|
| 23 |
print(f"Decoded: {decoded}")
|
| 24 |
-
return
|
| 25 |
|
| 26 |
|
| 27 |
def nel_app_interface():
|
|
@@ -33,7 +36,7 @@ def nel_app_interface():
|
|
| 33 |
"entity should be surrounded by `[START]` and `[END]`. // "
|
| 34 |
"!Only one entity per sentence is supported at the moment!",
|
| 35 |
)
|
| 36 |
-
output_entities = gr.HighlightedText(label="
|
| 37 |
|
| 38 |
# Interface definition
|
| 39 |
interface = gr.Interface(
|
|
|
|
| 11 |
|
| 12 |
def disambiguate_sentence(sentence):
|
| 13 |
results = []
|
| 14 |
+
entities = []
|
| 15 |
for sentence in [sentence]:
|
| 16 |
outputs = model.generate(
|
| 17 |
**tokenizer([sentence], return_tensors="pt"),
|
|
|
|
| 21 |
)
|
| 22 |
decoded = tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
| 23 |
results.append(decoded)
|
| 24 |
+
entities.append({"label": decoded[0]})
|
| 25 |
+
|
| 26 |
print(f"Decoded: {decoded}")
|
| 27 |
+
return {"text": sentence, "entities": entities}
|
| 28 |
|
| 29 |
|
| 30 |
def nel_app_interface():
|
|
|
|
| 36 |
"entity should be surrounded by `[START]` and `[END]`. // "
|
| 37 |
"!Only one entity per sentence is supported at the moment!",
|
| 38 |
)
|
| 39 |
+
output_entities = gr.HighlightedText(label="Linked Entities")
|
| 40 |
|
| 41 |
# Interface definition
|
| 42 |
interface = gr.Interface(
|