Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getEntitySourceURI(queryString) {
// the wdk used below, actually uses the wikidata php api
return wdk.searchEntities({
search: queryString,
format: 'json',
language: 'en',
limit: 5
})
}
function nextMatch() {
_currIndex = clamp(_currIndex, 0, _toMatch.length - 1);
_currKey = _toMatch[_currIndex];
clearConsole();
console.log(colors.yellow.bold(`[${_currIndex+1}/${_total}]: ${_currKey}`));
const name = _currKey.split('|', 2)[1];
const lang = 'en';
const searchURL = wdk.searchEntities({
search: name, lang: lang, limit: MAXCHOICE, format: 'json', uselang: 'en'
});
let choices = [];
fetch(searchURL)
.then(response => response.json())
.then(result => {
if (!result.search.length) {
throw new Error(`"${name}" not found`);
}
let queue = [];
result.search.forEach((entity) => {
choices.push(entity);
entity.lang = lang;
queue.push(
fetch(wdk.sparqlQuery(instancesSPARQL(entity)))
async function findWiki(name) {
const APIurl = wdk.searchEntities({
search: name,
format: 'json',
})
const search = await fetch(APIurl)
const response = await search.json()
if (response && response.search.length) {
const fetchingInstances = response.search.map(({ id }) => fetchInstance(id))
const instances = await Promise.all(fetchingInstances)
const results = response.search.map((result, index) => ({
...result,
instances: instances[index],
}))
const orgInstances = results.filter(
result => result.instances && result.instances.includes(WIKI_ORGANIZATION)