How to use the wikidata-sdk.normalizeId 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 nichtich / wikidata-taxonomy / wdtaxonomy.js View on Github external
action: function (wid, env, error) {
    wid = wid.replace(/^.*[^0-9A-Z]([QP][0-9]+)([^0-9].*)?$/i, '$1')

    if (env.brief) {
      env.instancecount = false
      env.sitecount = false
    }

    try {
      var id = normalizeId(wid)
    } catch (err) {
      error(1, 'invalid id: %s', wid)
    }

    const serializeOptions = {
      chalk: env.chalk,
      uris: env.uris,
      instancecount: env.instancecount,
      sitecount: env.sitecount
    }

    env.property = env.property || ''
    var match = env.property.match(/^([pP]?([0-9]+))?([/,][pP]?([0-9]+))?/)
    if (match) {
      var qid = id.substr(0, 1) === 'Q'
      env.property = [
github nichtich / wikidata-taxonomy / lib / wikidata-taxonomy.js View on Github external
wdt.normalizeId = (id) => {
  try {
    return wdk.normalizeId(id)
  } catch (err) {
    return
  }
}