How to use the wikidata-sdk.getManyEntities 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 osmlab / name-suggestion-index / build_wikidata.js View on Github external
});
} catch (err) { /* ignore */ }


// what to fetch
let _brands = fileTree.read('brands');
let _wikidata = gatherQIDs(_brands);
let _qids = Object.keys(_wikidata);
let _total = _qids.length;
if (!_total) {
  console.log('Nothing to fetch');
  process.exit();
}

// split into several wikidata requests
let _urls = wdk.getManyEntities({
  ids: _qids,
  languages: ['en'],
  props: ['info', 'labels', 'descriptions', 'claims'],
  format: 'json'
});

let _errors = [];
doFetch().then(finish);


function gatherQIDs(brands) {
  let wikidata = {};
  Object.keys(brands).forEach(kvnd => {
    ['brand:wikidata', 'operator:wikidata'].forEach(t => {
      let qid = brands[kvnd].tags[t];
      if (qid && /^Q\d+$/.test(qid)) {
github osmlab / name-suggestion-index / check_wikiTags.js View on Github external
let _brands = fileTree.read('brands');

let _errors = [];
let _wrongFormat = [];
let _deletedWikidata = [];
let _deletedWikipedia = [];
let _foundSitelink = [];
let _wrongLink = [];
let _wrongEntity = [];
let _missingInstance = [];
let _missingReferences = [];

let _data = gatherData(_brands);

let _urls = {
    wikidata: wdk.getManyEntities({
        ids: Object.keys(_data.wikidata),
        languages: ['en'],
        props: ['info', 'claims', 'sitelinks'],
        format: 'json',
        redirects: false
    }),
    wikipedia: getWikipediaUrls(
      Object.keys(_data.wikipedia)
    )
};

process.stdout.write('\nchecking and validating');

doFetch(null, _urls.wikidata, checkWikidata)
  .then(doFetch(null, _urls.wikipedia, checkWikipedia))
  .then(finish);