Spaces:
Runtime error
Runtime error
Update ✨Entity Linking Application✨.py
Browse files
✨Entity Linking Application✨.py
CHANGED
|
@@ -16,11 +16,6 @@ import sys
|
|
| 16 |
from googlesearch import search
|
| 17 |
|
| 18 |
|
| 19 |
-
headers = {
|
| 20 |
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
|
| 21 |
-
}
|
| 22 |
-
|
| 23 |
-
|
| 24 |
folder_path = '/home/user/app/qids_folder'
|
| 25 |
|
| 26 |
if not os.path.exists(folder_path):
|
|
@@ -61,7 +56,7 @@ async def fetch_json(url, session):
|
|
| 61 |
return await response.json()
|
| 62 |
|
| 63 |
async def combination_method(name, session):
|
| 64 |
-
async with aiohttp.ClientSession(
|
| 65 |
data = set()
|
| 66 |
new_name = name.split()
|
| 67 |
x = itertools_combinations(new_name, 2)
|
|
@@ -74,7 +69,7 @@ async def combination_method(name, session):
|
|
| 74 |
return data
|
| 75 |
|
| 76 |
async def single_method(name, session):
|
| 77 |
-
async with aiohttp.ClientSession(
|
| 78 |
data = set()
|
| 79 |
new_name = name.replace("-", " ").replace("/", " ").split()
|
| 80 |
for i in new_name:
|
|
@@ -89,11 +84,12 @@ async def mains(name, single, combi):
|
|
| 89 |
disam_data = set()
|
| 90 |
qids = set()
|
| 91 |
|
| 92 |
-
async with aiohttp.ClientSession(
|
| 93 |
url = f"{name} site:en.wikipedia.org inurl:/wiki/ -inurl:?"
|
| 94 |
s = search(url, num_results = 30, lang="en")
|
| 95 |
for i in s:
|
| 96 |
data.add(i.split("/")[-1])
|
|
|
|
| 97 |
|
| 98 |
wikipedia_url = f"https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch={name}&srlimit=1&srprop=&srenablerewrites=True&srinfo=suggestion&format=json"
|
| 99 |
json_data = await fetch_json(wikipedia_url, session)
|
|
@@ -178,7 +174,7 @@ def cleaner(text):
|
|
| 178 |
return text
|
| 179 |
|
| 180 |
async def retriever(qid):
|
| 181 |
-
async with aiohttp.ClientSession(
|
| 182 |
list_with_sent = []
|
| 183 |
|
| 184 |
query_label = f"""SELECT ?subjectLabel
|
|
|
|
| 16 |
from googlesearch import search
|
| 17 |
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
folder_path = '/home/user/app/qids_folder'
|
| 20 |
|
| 21 |
if not os.path.exists(folder_path):
|
|
|
|
| 56 |
return await response.json()
|
| 57 |
|
| 58 |
async def combination_method(name, session):
|
| 59 |
+
async with aiohttp.ClientSession() as session:
|
| 60 |
data = set()
|
| 61 |
new_name = name.split()
|
| 62 |
x = itertools_combinations(new_name, 2)
|
|
|
|
| 69 |
return data
|
| 70 |
|
| 71 |
async def single_method(name, session):
|
| 72 |
+
async with aiohttp.ClientSession() as session:
|
| 73 |
data = set()
|
| 74 |
new_name = name.replace("-", " ").replace("/", " ").split()
|
| 75 |
for i in new_name:
|
|
|
|
| 84 |
disam_data = set()
|
| 85 |
qids = set()
|
| 86 |
|
| 87 |
+
async with aiohttp.ClientSession() as session:
|
| 88 |
url = f"{name} site:en.wikipedia.org inurl:/wiki/ -inurl:?"
|
| 89 |
s = search(url, num_results = 30, lang="en")
|
| 90 |
for i in s:
|
| 91 |
data.add(i.split("/")[-1])
|
| 92 |
+
print(i)
|
| 93 |
|
| 94 |
wikipedia_url = f"https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch={name}&srlimit=1&srprop=&srenablerewrites=True&srinfo=suggestion&format=json"
|
| 95 |
json_data = await fetch_json(wikipedia_url, session)
|
|
|
|
| 174 |
return text
|
| 175 |
|
| 176 |
async def retriever(qid):
|
| 177 |
+
async with aiohttp.ClientSession() as session:
|
| 178 |
list_with_sent = []
|
| 179 |
|
| 180 |
query_label = f"""SELECT ?subjectLabel
|