How to use the wikidata-sdk.searchEntities function in wikidata-sdk

To help you get started, we’ve selected a few wikidata-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cwrc / wikidata-entity-lookup / src / index.js View on Github external
function getEntitySourceURI(queryString) {
    // the wdk used below, actually uses the wikidata php api
   return wdk.searchEntities({
        search: queryString,
        format: 'json',
        language: 'en',
        limit: 5
    })
}
github osmlab / name-suggestion-index / match_wikiTags.js View on Github external
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)))
github coala / gci-leaders / lib / scrape.js View on Github external
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)