How to use the wikidata-sdk.simplifyPropertyClaims 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 maxlath / wikidata-filter / lib / valid_claims.js View on Github external
const { P, QHash, negatedProp, filterByClaimValue } = claimsFilterData
  // filter-out this entity unless it has claims of the desired property
  var propClaims = claims[P]

  if (propClaims && propClaims.length > 0) {
    if (negatedProp && !filterByClaimValue) return false
  } else {
    if (!negatedProp) return false
  }

  // let the possibility to let the claim value unspecified
  // ex: wikidata-filter --claim P184
  if (filterByClaimValue) {
    // filter-out this entity unless it has a claim
    // of the desired property with the desired value
    propClaims = wdk.simplifyPropertyClaims(propClaims)
    if (haveAMatch(QHash, propClaims)) {
      if (negatedProp) return false
    } else {
      if (!negatedProp) return false
    }
  }
  return true
}