Update ✨Entity Linking Application✨.py
Browse files- ✨Entity Linking Application✨.py +16 -10
✨Entity Linking Application✨.py
CHANGED
|
@@ -55,11 +55,14 @@ async def combination_method(name, session):
|
|
| 55 |
x = itertools_combinations(new_name, 2)
|
| 56 |
for i in x:
|
| 57 |
new_word = (i[0] + " " + i[1])
|
| 58 |
-
url = f"https://
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
| 63 |
return data
|
| 64 |
|
| 65 |
async def single_method(name, session):
|
|
@@ -67,11 +70,14 @@ async def single_method(name, session):
|
|
| 67 |
data = set()
|
| 68 |
new_name = name.replace("-", " ").replace("/", " ").split()
|
| 69 |
for i in new_name:
|
| 70 |
-
url = f"https://
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
| 75 |
return data
|
| 76 |
|
| 77 |
async def mains(name, single, combi):
|
|
|
|
| 55 |
x = itertools_combinations(new_name, 2)
|
| 56 |
for i in x:
|
| 57 |
new_word = (i[0] + " " + i[1])
|
| 58 |
+
url = f"https://www.google.com/search?q={new_word} site:en.wikipedia.org inurl:/wiki/ -inurl:? -inurl:Category: -inurl:File: -inurl:Special: -inurl:Help:&num=5"
|
| 59 |
+
html = requests.get(url, headers=headers)
|
| 60 |
+
soup = BeautifulSoup(html.text, "html.parser")
|
| 61 |
+
elements_with_href = soup.find_all(href=True)
|
| 62 |
+
href_links = [element['href'] for element in elements_with_href]
|
| 63 |
+
for link in href_links:
|
| 64 |
+
if link.startswith('https://en.wikipedia.org/wiki/'):
|
| 65 |
+
data.add(link.split("/")[-1])
|
| 66 |
return data
|
| 67 |
|
| 68 |
async def single_method(name, session):
|
|
|
|
| 70 |
data = set()
|
| 71 |
new_name = name.replace("-", " ").replace("/", " ").split()
|
| 72 |
for i in new_name:
|
| 73 |
+
url = f"https://www.google.com/search?q={i} site:en.wikipedia.org inurl:/wiki/ -inurl:? -inurl:Category: -inurl:File: -inurl:Special: -inurl:Help:&num=5"
|
| 74 |
+
html = requests.get(url, headers=headers)
|
| 75 |
+
soup = BeautifulSoup(html.text, "html.parser")
|
| 76 |
+
elements_with_href = soup.find_all(href=True)
|
| 77 |
+
href_links = [element['href'] for element in elements_with_href]
|
| 78 |
+
for link in href_links:
|
| 79 |
+
if link.startswith('https://en.wikipedia.org/wiki/'):
|
| 80 |
+
data.add(link.split("/")[-1])
|
| 81 |
return data
|
| 82 |
|
| 83 |
async def mains(name, single, combi):
|