-- This module is specifically the Wikidata property "prevalence" (P1193), due-- to its particular need for ranges and area-based qualifiers, and the lack of-- support for these in the main Wikidata module.-- Completely untested.localp={}--local wikidata = require( 'Module:Wikidata' )p.main=function(frame)--local entity = mw.wikibase.getEntity( 'Q133087' )localentity=mw.wikibase.getEntity(frame.args.qIdornil)ifentitythenlocalprevalenceClaims=entity.claimsandentity.claims.P1193-- TODO: Get best claim, not always just the first one.-- Probably use getBestStatements.ifprevalenceClaimsthenlocalpRange=''-- Run through all prevalence claimsfori,prevalenceClaiminpairs(prevalenceClaims)dolocalprevalenceValue=prevalenceClaim.mainsnak.datavalue.valueifprevalenceValuethenifstring.len(pRange)>0then-- Split multiple claims-- Maybe line break instead?pRange=pRange..', 'endlocallowerBound=prevalenceValue.lowerBound*100localupperBound=prevalenceValue.upperBound*100pRange=pRange..lowerBoundiflowerBound~=upperBoundthenpRange=pRange..' to '..upperBoundendpRange=pRange..'%'ifprevalenceClaim.qualifiersthen-- Qualifiers for prevalence are currently unstandardized.-- Keep guessing until the right one is found.localquals=prevalenceClaim.qualifiers.P276or-- locationprevalenceClaim.qualifiers.P1001or-- applies to jurisdictionprevalenceClaim.qualifiers.P17-- countryifqualsthenpRange=pRange..' ('fork,qualinpairs(quals)doifk>1thenpRange=pRange..', 'endlocalqualId=qual.datavalue.value['numeric-id']locallink=mw.wikibase.sitelink('Q'..qualId)locallabel=({-- Certain geographic locales might need a-- manual-ish override for labels. [132453]='developed world'})[qualId]ormw.wikibase.label('Q'..qualId)iflinkthenlabel='[['..link..'|'..label..']]'endpRange=pRange..labelendpRange=pRange..')'endendend--[[ -- Todo: References if prevalenceClaim.references then end ]]--endreturnpRangeendendreturn''endreturnp