How to use the wikidata-sdk.simplifyClaims 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 larsgw / citation.js / src / wikidata.Citation-0.1.js View on Github external
, QProgress
  
  if ( progressBar ) { QProgress = new progress(
    '[:bar] Processing entity :current/:total: :q (eta :etas)',
    {
      complete: '='.green,
      width: 20,
      total: entKeys.length
    }
  ) } else console.log( 'Processing recieved entity data...' )
  
  for ( var entIndex = 0; entIndex < entKeys.length; entIndex++ ) {
    var entKey = entKeys [ entIndex ]
      , entity = entities[ entKey   ]
    
    entities[ entKey ] = wdk.simplifyClaims( entity.claims )
    
        entity = entities[ entKey   ]
    
    var json  = { wikiID: entKey, id: entKey }
      , props = Object.keys( entity )
    
    for ( var propIndex = 0; propIndex < props.length; propIndex++ ) {
      var prop  = props[ propIndex ]
        , value = entity[ prop ]
	
      var resp = parseProp( prop, value, lang )
      
      json[ resp[ 0 ] ] = resp[ 1 ]
      
      // Removing empty responses
      delete json[ '' ]
github larsgw / citation.js / src / parse / modules / wikidata / json.js View on Github external
return Promise.all(Object.keys(data.entities).map(async function (entityKey) {
    const {labels, claims} = data.entities[entityKey]
    const entity = wdk.simplifyClaims(claims, null, null, true)
    const json = {
      _wikiId: entityKey,
      id: entityKey
    }

    await Promise.all(Object.keys(entity).map(async prop => {
      const field = await parseWikidataPropAsync(prop, entity[prop], 'en')
      if (field) {
        const [fieldName, fieldValue] = field

        if (Array.isArray(json[fieldName])) {
          json[fieldName] = json[fieldName].concat(fieldValue)
        } else if (fieldValue !== undefined) {
          json[fieldName] = fieldValue
        }
      }
github larsgw / citation.js / src / parse / wikidata / async / json.js View on Github external
return Promise.all(Object.keys(data.entities).map(async function (entityKey) {
    const {labels, claims} = data.entities[entityKey]
    const entity = wdk.simplifyClaims(claims, null, null, true)
    const json = {
      _wikiId: entityKey,
      id: entityKey
    }

    await Promise.all(Object.keys(entity).map(async prop => {
      const field = await parseWikidataPropAsync(prop, entity[prop], 'en')
      if (field) {
        const [fieldName, fieldValue] = field

        if (Array.isArray(json[fieldName])) {
          json[fieldName] = json[fieldName].concat(fieldValue)
        } else if (fieldValue !== undefined) {
          json[fieldName] = fieldValue
        }
      }