Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,18 +18,18 @@ folder_path = '/home/user/app/qids_folder'
|
|
| 18 |
|
| 19 |
if not os.path.exists(folder_path):
|
| 20 |
os.mkdir(folder_path)
|
| 21 |
-
print(f"
|
| 22 |
else:
|
| 23 |
-
print(f"
|
| 24 |
|
| 25 |
|
| 26 |
folder_path_1 = '/home/user/app/info_extraction'
|
| 27 |
|
| 28 |
if not os.path.exists(folder_path_1):
|
| 29 |
os.mkdir(folder_path_1)
|
| 30 |
-
print(f"Folder
|
| 31 |
else:
|
| 32 |
-
print(f"
|
| 33 |
|
| 34 |
model = SentenceTransformer("Lajavaness/bilingual-embedding-large", trust_remote_code=True)
|
| 35 |
|
|
@@ -297,8 +297,8 @@ def main_cli():
|
|
| 297 |
st.caption("This Web Application is part of my master dissertation.")
|
| 298 |
|
| 299 |
|
| 300 |
-
input_sentence_user = st.text_input("Enter
|
| 301 |
-
input_mention_user = st.text_input("Enter the
|
| 302 |
single = st.selectbox("Search each word individually?", ['Yes', 'No'], index=1)
|
| 303 |
combi = st.selectbox("Make combinations of each word?", ['Yes', 'No'], index=1)
|
| 304 |
disambi = st.selectbox("Run acronym disambiguation? (Enable it if the mention is nested)", ['Yes', 'No'], index=0)
|
|
@@ -306,7 +306,7 @@ def main_cli():
|
|
| 306 |
|
| 307 |
if st.button("Run Entity Linking"):
|
| 308 |
if input_sentence_user and input_mention_user:
|
| 309 |
-
#
|
| 310 |
if input_mention_user in input_sentence_user:
|
| 311 |
st.write("Applying Data Normalization module... (1/5)")
|
| 312 |
# Data Normalization
|
|
@@ -421,13 +421,13 @@ def main_cli():
|
|
| 421 |
context = i.split(":")[-1].strip()
|
| 422 |
list_with_contexts.append(context)
|
| 423 |
|
| 424 |
-
# Candidate
|
| 425 |
async def big_main(mention, single, combi):
|
| 426 |
mention = mention.split(",")
|
| 427 |
-
st.write("Applying Candidate
|
| 428 |
for i in mention:
|
| 429 |
await mains(i, single, combi)
|
| 430 |
-
st.write("Applying Information
|
| 431 |
for i in mention:
|
| 432 |
await main(i)
|
| 433 |
|
|
@@ -464,7 +464,7 @@ def main_cli():
|
|
| 464 |
lista_1.append({k: emb_mean})
|
| 465 |
|
| 466 |
sorted_data = sorted(lista_1, key=lambda x: list(x.values())[0], reverse=True)
|
| 467 |
-
st.write(f"Applying
|
| 468 |
if sorted_data:
|
| 469 |
sorted_top = sorted_data[0]
|
| 470 |
for k, v in sorted_top.items():
|
|
@@ -510,7 +510,8 @@ def main_cli():
|
|
| 510 |
execution_time = end_time - start_time
|
| 511 |
ETA = time.strftime("%H:%M:%S", time.gmtime(execution_time))
|
| 512 |
st.write(f"Execution time: {ETA}")
|
| 513 |
-
|
|
|
|
| 514 |
folder_path = "qids_folder"
|
| 515 |
for filename in os.listdir(folder_path):
|
| 516 |
file_path = os.path.join(folder_path, filename)
|
|
|
|
| 18 |
|
| 19 |
if not os.path.exists(folder_path):
|
| 20 |
os.mkdir(folder_path)
|
| 21 |
+
print(f"folder created at {folder_path}")
|
| 22 |
else:
|
| 23 |
+
print(f"folder already exists.")
|
| 24 |
|
| 25 |
|
| 26 |
folder_path_1 = '/home/user/app/info_extraction'
|
| 27 |
|
| 28 |
if not os.path.exists(folder_path_1):
|
| 29 |
os.mkdir(folder_path_1)
|
| 30 |
+
print(f"Folder created at {folder_path_1}")
|
| 31 |
else:
|
| 32 |
+
print(f"folder already exists.")
|
| 33 |
|
| 34 |
model = SentenceTransformer("Lajavaness/bilingual-embedding-large", trust_remote_code=True)
|
| 35 |
|
|
|
|
| 297 |
st.caption("This Web Application is part of my master dissertation.")
|
| 298 |
|
| 299 |
|
| 300 |
+
input_sentence_user = st.text_input("Enter a sentence:", "")
|
| 301 |
+
input_mention_user = st.text_input("Enter a textural reference (mention) that is inside the sentence:", "")
|
| 302 |
single = st.selectbox("Search each word individually?", ['Yes', 'No'], index=1)
|
| 303 |
combi = st.selectbox("Make combinations of each word?", ['Yes', 'No'], index=1)
|
| 304 |
disambi = st.selectbox("Run acronym disambiguation? (Enable it if the mention is nested)", ['Yes', 'No'], index=0)
|
|
|
|
| 306 |
|
| 307 |
if st.button("Run Entity Linking"):
|
| 308 |
if input_sentence_user and input_mention_user:
|
| 309 |
+
# check if the mention is in the sentence
|
| 310 |
if input_mention_user in input_sentence_user:
|
| 311 |
st.write("Applying Data Normalization module... (1/5)")
|
| 312 |
# Data Normalization
|
|
|
|
| 421 |
context = i.split(":")[-1].strip()
|
| 422 |
list_with_contexts.append(context)
|
| 423 |
|
| 424 |
+
# Candidate Retrieval & Information Gathering
|
| 425 |
async def big_main(mention, single, combi):
|
| 426 |
mention = mention.split(",")
|
| 427 |
+
st.write("Applying Candidate Retrieval module... (2/5)")
|
| 428 |
for i in mention:
|
| 429 |
await mains(i, single, combi)
|
| 430 |
+
st.write("Applying Information Gathering module... (3/5)")
|
| 431 |
for i in mention:
|
| 432 |
await main(i)
|
| 433 |
|
|
|
|
| 464 |
lista_1.append({k: emb_mean})
|
| 465 |
|
| 466 |
sorted_data = sorted(lista_1, key=lambda x: list(x.values())[0], reverse=True)
|
| 467 |
+
st.write(f"Applying Candidate Matching module... (4/5) [{number}/{len(list_with_full_names)}]")
|
| 468 |
if sorted_data:
|
| 469 |
sorted_top = sorted_data[0]
|
| 470 |
for k, v in sorted_top.items():
|
|
|
|
| 510 |
execution_time = end_time - start_time
|
| 511 |
ETA = time.strftime("%H:%M:%S", time.gmtime(execution_time))
|
| 512 |
st.write(f"Execution time: {ETA}")
|
| 513 |
+
|
| 514 |
+
# i think this part can be removed now
|
| 515 |
folder_path = "qids_folder"
|
| 516 |
for filename in os.listdir(folder_path):
|
| 517 |
file_path = os.path.join(folder_path, filename)
|