Spaces:
Runtime error
Runtime error
Update ✨Entity Linking Application✨.py
Browse files- ✨Entity Linking Application✨.py +16 -16
✨Entity Linking Application✨.py
CHANGED
|
@@ -13,7 +13,7 @@ import streamlit as st
|
|
| 13 |
import time
|
| 14 |
from openai import OpenAI
|
| 15 |
import sys
|
| 16 |
-
from googlesearch import search
|
| 17 |
import time
|
| 18 |
|
| 19 |
|
|
@@ -47,11 +47,11 @@ async def combination_method(name, session):
|
|
| 47 |
x = itertools_combinations(new_name, 2)
|
| 48 |
for i in x:
|
| 49 |
new_word = (i[0] + " " + i[1])
|
| 50 |
-
url = f"
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
for i in
|
| 54 |
-
data.add(i.
|
| 55 |
return data
|
| 56 |
|
| 57 |
async def single_method(name, session):
|
|
@@ -59,11 +59,11 @@ async def single_method(name, session):
|
|
| 59 |
data = set()
|
| 60 |
new_name = name.replace("-", " ").replace("/", " ").split()
|
| 61 |
for i in new_name:
|
| 62 |
-
url = f"
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
for i in
|
| 66 |
-
data.add(i.
|
| 67 |
return data
|
| 68 |
|
| 69 |
async def mains(name, single, combi):
|
|
@@ -72,11 +72,11 @@ async def mains(name, single, combi):
|
|
| 72 |
qids = set()
|
| 73 |
|
| 74 |
async with aiohttp.ClientSession() as session:
|
| 75 |
-
url = f"
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
for i in
|
| 79 |
-
data.add(i.
|
| 80 |
|
| 81 |
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"
|
| 82 |
json_data = await fetch_json(wikipedia_url, session)
|
|
|
|
| 13 |
import time
|
| 14 |
from openai import OpenAI
|
| 15 |
import sys
|
| 16 |
+
#from googlesearch import search
|
| 17 |
import time
|
| 18 |
|
| 19 |
|
|
|
|
| 47 |
x = itertools_combinations(new_name, 2)
|
| 48 |
for i in x:
|
| 49 |
new_word = (i[0] + " " + i[1])
|
| 50 |
+
url = f"https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch={new_word}&srlimit=10&srprop=&srenablerewrites=True&srinfo=suggestion&format=json"
|
| 51 |
+
json_suggestion = await fetch_json(suggested_url, session)
|
| 52 |
+
results = json_suggestion.get('query', {}).get('search')
|
| 53 |
+
for i in results:
|
| 54 |
+
data.add(i.get('title'))
|
| 55 |
return data
|
| 56 |
|
| 57 |
async def single_method(name, session):
|
|
|
|
| 59 |
data = set()
|
| 60 |
new_name = name.replace("-", " ").replace("/", " ").split()
|
| 61 |
for i in new_name:
|
| 62 |
+
url = f"https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch={i}&srlimit=10&srprop=&srenablerewrites=True&srinfo=suggestion&format=json"
|
| 63 |
+
json_suggestion = await fetch_json(suggested_url, session)
|
| 64 |
+
results = json_suggestion.get('query', {}).get('search')
|
| 65 |
+
for i in results:
|
| 66 |
+
data.add(i.get('title'))
|
| 67 |
return data
|
| 68 |
|
| 69 |
async def mains(name, single, combi):
|
|
|
|
| 72 |
qids = set()
|
| 73 |
|
| 74 |
async with aiohttp.ClientSession() as session:
|
| 75 |
+
url = f"https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch={name}&srlimit=15&srprop=&srenablerewrites=True&srinfo=suggestion&format=json"
|
| 76 |
+
json_suggestion = await fetch_json(suggested_url, session)
|
| 77 |
+
results = json_suggestion.get('query', {}).get('search')
|
| 78 |
+
for i in results:
|
| 79 |
+
data.add(i.get('title'))
|
| 80 |
|
| 81 |
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"
|
| 82 |
json_data = await fetch_json(wikipedia_url, session)
|