Spaces:
Runtime error
Runtime error
Raphaël Bournhonesque
commited on
Commit
•
f19a6c4
1
Parent(s):
bbd081e
update app
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import requests
|
2 |
import streamlit as st
|
3 |
-
from annotated_text import annotated_text
|
4 |
|
5 |
|
6 |
@st.cache_data
|
@@ -16,30 +15,6 @@ def send_autocomplete_request(q: str, lang: str, taxonomy_names: list[str], size
|
|
16 |
).json()
|
17 |
|
18 |
|
19 |
-
def get_product(barcode: str):
|
20 |
-
r = requests.get(f"https://world.openfoodfacts.org/api/v2/product/{barcode}")
|
21 |
-
|
22 |
-
if r.status_code == 404:
|
23 |
-
return None
|
24 |
-
|
25 |
-
return r.json()["product"]
|
26 |
-
|
27 |
-
|
28 |
-
def display_ner_tags(text: str, entities: list[dict]):
|
29 |
-
spans = []
|
30 |
-
previous_idx = 0
|
31 |
-
for entity in entities:
|
32 |
-
score = entity["score"]
|
33 |
-
lang = entity["lang"]["lang"]
|
34 |
-
start_idx = entity["start"]
|
35 |
-
end_idx = entity["end"]
|
36 |
-
spans.append(text[previous_idx:start_idx])
|
37 |
-
spans.append((text[start_idx:end_idx], f"score={score:.3f} | lang={lang}"))
|
38 |
-
previous_idx = end_idx
|
39 |
-
spans.append(text[previous_idx:])
|
40 |
-
annotated_text(spans)
|
41 |
-
|
42 |
-
|
43 |
def run(
|
44 |
query: str,
|
45 |
taxonomy_names: list[str],
|
|
|
1 |
import requests
|
2 |
import streamlit as st
|
|
|
3 |
|
4 |
|
5 |
@st.cache_data
|
|
|
15 |
).json()
|
16 |
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
def run(
|
19 |
query: str,
|
20 |
taxonomy_names: list[str],
|