Update ✨Entity Linking Application✨.py
Browse files
✨Entity Linking Application✨.py
CHANGED
@@ -288,9 +288,6 @@ def main_cli():
|
|
288 |
|
289 |
if "disabled" not in st.session_state:
|
290 |
st.session_state.disabled = False
|
291 |
-
|
292 |
-
def disable_inputs():
|
293 |
-
st.session_state.disabled = True
|
294 |
|
295 |
input_sentence_user = st.text_input("Enter a sentence:", "", disabled=st.session_state.disabled)
|
296 |
input_mention_user = st.text_input("Enter a textural reference (mention) that is inside the sentence:", "", disabled=st.session_state.disabled)
|
@@ -298,11 +295,10 @@ def main_cli():
|
|
298 |
combi = st.selectbox("Make combinations of each word? (Useful for difficult mentions)", ['Yes', 'No'], index=1, disabled=st.session_state.disabled)
|
299 |
disambi = st.selectbox("Run acronym disambiguation? (Enable it if the mention include an acronym or if it is nested)", ['Yes', 'No'], index=0, disabled=st.session_state.disabled)
|
300 |
|
301 |
-
if st.button("Run Entity Linking"):
|
302 |
if input_sentence_user and input_mention_user:
|
303 |
# check if the mention is in the sentence
|
304 |
if input_mention_user in input_sentence_user:
|
305 |
-
disable_inputs()
|
306 |
with st.spinner("Applying Data Normalization module... (1/5)"):
|
307 |
# Data Normalization
|
308 |
start_time = time.time()
|
@@ -437,7 +433,7 @@ def main_cli():
|
|
437 |
lista = []
|
438 |
lista_1 = []
|
439 |
my_bar = st.progress(0)
|
440 |
-
for
|
441 |
qid = element.get("qid")
|
442 |
link = f"https://www.wikidata.org/wiki/{qid}"
|
443 |
label = element.get("label")
|
@@ -447,7 +443,7 @@ def main_cli():
|
|
447 |
desc_emb = model.encode([description])
|
448 |
|
449 |
lista.append({link: [label_emb, desc_emb]})
|
450 |
-
my_bar.progress((
|
451 |
print(qid)
|
452 |
|
453 |
label_dataset_emb = model.encode([i])
|
|
|
288 |
|
289 |
if "disabled" not in st.session_state:
|
290 |
st.session_state.disabled = False
|
|
|
|
|
|
|
291 |
|
292 |
input_sentence_user = st.text_input("Enter a sentence:", "", disabled=st.session_state.disabled)
|
293 |
input_mention_user = st.text_input("Enter a textural reference (mention) that is inside the sentence:", "", disabled=st.session_state.disabled)
|
|
|
295 |
combi = st.selectbox("Make combinations of each word? (Useful for difficult mentions)", ['Yes', 'No'], index=1, disabled=st.session_state.disabled)
|
296 |
disambi = st.selectbox("Run acronym disambiguation? (Enable it if the mention include an acronym or if it is nested)", ['Yes', 'No'], index=0, disabled=st.session_state.disabled)
|
297 |
|
298 |
+
if st.button("Run Entity Linking", key="disabled"):
|
299 |
if input_sentence_user and input_mention_user:
|
300 |
# check if the mention is in the sentence
|
301 |
if input_mention_user in input_sentence_user:
|
|
|
302 |
with st.spinner("Applying Data Normalization module... (1/5)"):
|
303 |
# Data Normalization
|
304 |
start_time = time.time()
|
|
|
433 |
lista = []
|
434 |
lista_1 = []
|
435 |
my_bar = st.progress(0)
|
436 |
+
for index, element in enumerate(json_file):
|
437 |
qid = element.get("qid")
|
438 |
link = f"https://www.wikidata.org/wiki/{qid}"
|
439 |
label = element.get("label")
|
|
|
443 |
desc_emb = model.encode([description])
|
444 |
|
445 |
lista.append({link: [label_emb, desc_emb]})
|
446 |
+
my_bar.progress((index + 1) / len(json_file))
|
447 |
print(qid)
|
448 |
|
449 |
label_dataset_emb = model.encode([i])
|