- Simplify entity
- Simplify entities
- Simplify claims
- Simplify labels
- Simplify descriptions
- Simplify aliases
- Simplify sitelinks
- Simplify lemmas
- Simplify forms
- Simplify senses
Applying all simplifiers at once. See next sections for details.
wbk.simplify.entity(entity)
You can also pass options as a second argument, that will then be passed the subfunctions: currently only simplify claims and simplify sitelinks.
const simplificationOptions = {
// claims
entityPrefix: 'wd',
propertyPrefix: 'wdt',
keepRichValues: true,
keepQualifiers: true,
keepReferences: true,
keepIds: true,
keepHashes: true,
keepNonTruthy: true, // For each property, keep claims with preferred rank, or normal rank if no claims has the preferred rank
keepNonDeprecated: true, // For each property, keep all claims with preferred or normal rank
// sitelinks
keepBadges: true,
addUrl: true,
}
wbk.simplify.entity(entity, simplificationOptions)
Same as wbk.simplify.entity
, but accepts all the entities sent by the Wikibase API at once:
const url = wbk.getEntities({ ids: [ 'Q1', 'P2', 'L3' ] })
const { entities } = await fetch(url).then(res => res.json())
const simplifiedEntities = wbk.simplifyEntities(entities)
// Do your thing with those entities data)
That's a huge chunk so it got it's own doc page: simplify claims
wbk.simplify.labels(entity.labels)
Before: { pl: { language: 'pl', value: 'książka' } }
After: { pl: 'książka' }
wbk.simplify.descriptions(entity.descriptions)
Before: { pl: { language: 'pl', value: 'dokument piśmienniczy [...]' } }
After: { pl: 'dokument piśmienniczy [...]' }
wbk.simplify.aliases(entity.aliases)
Before: { pl: [ { language: 'pl', value: 'Tom' }, { language: 'pl', value: 'Tomik' } ] }
After: { pl: [ 'Tom', 'Tomik' ] }
wbk.simplify.sitelinks(entity.sitelinks)
Before: { plwiki: { site: 'plwiki', title: 'Książka', badges: ['Q17437796'] } }
After: { plwiki: 'Książka' }
wbk.simplify.sitelinks(entity.sitelinks, { keepBadges: true })
Before: { plwiki: { site: 'plwiki', title: 'Książka', badges: ['Q17437796'] } }
After: { plwiki: { title: 'Książka', badges: ['Q17437796'] }
NB: setting keepAll
would also imply keeping sitelinks badges
wbk.simplify.sitelinks(entity.sitelinks, { addUrl: true })
Before: { plwiki: { site: 'plwiki', title: 'Książka', badges: [] } }
After: { plwiki: { title: 'Książka', url: 'https://pl.wikipedia.org/wiki/Książka' }
Specific to lexemes
wbk.simplify.lemmas(entity.lemmas)
Before: { pl: { language: 'pl', value: 'książka' } }
After: { pl: 'książka' }
Specific to lexemes
// return an array of simplified forms, that is,
// the forms but with simplified representations and claims
wbk.simplify.forms(entity.forms)
Specific to lexemes
// return an array of simplified senses, that is,
// the senses but with simplified glosses and claims
wbk.simplify.senses(entity.senses)