 vimu800 setu800 noexpandtab ftu800 luau800 tsu800 4u800 swu800 4u800 require 'module nou800 globals local pu800 local debug false module local variables andu800 functions local wiki langcode mwu800u82elanguageu82egetcontentlanguage .code internationalisation local i18n "errors" "property notu800 found" "u8d9beu8d8b1u8d8a7u8d9beu8d8b1u8d8aau8db8c u8db8cu8d8a7u8d981u8d8aa u8d986u8d8b4u8d8af." "entity notu800 found" "wikidata entity notu800 found." "unknown claim type" "unknown claim type." "unknown entity type" "unknown entity type." "qualifier notu800 found" "qualifier notu800 found." "site notu800 found" "u8d9beu8d8b1u8d988u8da98u8d987u8d994 u8d988u8db8cu8daa9u8db8cu8e2808cu8d985u8d8afu8db8cu8d8a7 u8db8cu8d8a7u8d981u8d8aa u8d986u8d8b4u8d8af." "unknown datetime format" "unknown datetime format." "local article notu800 found" "article isu800 notu800 yetu800 available inu800 this wiki." "datetime" 1u800 isu800 au800 placeholder foru800 theu800 actual number 0u800 " 1u800 u8d985u8db8cu8d984u8db8cu8d8a7u8d8b1u8d8af u8d8b3u8d8a7u8d984" precision billion years 1u800 " 100u800 u8d985u8db8cu8d984u8db8cu8d988u8d986 u8d8b3u8d8a7u8d984" precision hundred million years 2u800 " 10u800 u8d985u8db8cu8d984u8db8cu8d988u8d986 u8d8b3u8d8a7u8d984" precision tenu800 million years 3u800 " 1u800 u8d985u8db8cu8d984u8db8cu8d988u8d986 u8d8b3u8d8a7u8d984" precision million years 4u800 " 100u800 000u800 u8d8b3u8d8a7u8d984" precision hundred thousand years 5u800 " 10u800 000u800 u8d8b3u8d8a7u8d984" precision tenu800 thousand years 6u800 " 1u800 u8d987u8d8b2u8d8a7u8d8b1u8d987" precision millennium 7u800 " 1u800 u8d982u8d8b1u8d986" precision century 8u800 " 1u800 u8d8afu8d987u8d987" precision decade theu800 following useu800 theu800 format ofu800 #time parser function 9u800 "yu800" precision year 10u800 "fu800 yu800" precision month 11u800 "fu800 ju800 yu800" precision dayu800 12u800 "fu800 ju800 yu800 gau800" precision hour 13u800 "fu800 ju800 yu800 gu800 iau800" precision minute 14u800 "fu800 ju800 yu800 gu800 iu800 sau800" precision second "beforenow" " 1u800 bceu800" howu800 tou800 format negative numbers foru800 precisions 0u800 tou800 5u800 "afternow" " 1u800 ceu800" howu800 tou800 format positive numbers foru800 precisions 0u800 tou800 5u800 "bcu800" ' 1u800 "bceu800"' howu800 print negative years "adu800" " 1u800" howu800 print positive years theu800 following areu800 foru800 function getdatevalue andu800 getqualifierdatevalue "default format" "dmyu800" default value ofu800 theu800 #3u800 getdatevalue oru800 #4u800 getqualifierdatevalue argument "default addon" "bcu800" default value ofu800 theu800 #4u800 getdatevalue oru800 #5u800 getqualifierdatevalue argument "prefix addon" false setu800 tou800 true foru800 languages putu800 "bcu800" inu800 front ofu800 theu800 datetime string; oru800 theu800 addon will beu800 suffixed "addon sepu800" " " separator between datetime string andu800 addon oru800 inverse "format" options ofu800 theu800 3rdu800 argument "mdyu800" "fu800 ju800 yu800" "myu800" "fu800 yu800" "yu800" "yu800" "dmyu800" "ju800 fu800 yu800" "ymdu800" "yu800 mu800 du800" "ymu800" "yu800 mu800" "monolingualtext" ' text ' "warndump" " category called function 'dump' from module wikidata " "ordinal" 1u800 "stu800" 2u800 "ndu800" 3u800 "rdu800" "default" "thu800" credit tou800 ccu800 byu800 sau800 3u800u82e0u800 local function tablemerge t1u800 t2u800 foru800 ku800 vu800 inu800 pairs t2u800 dou800 ifu800 type vu800 "table" then ifu800 type t1u800 ku800 oru800 false "table" then tablemerge t1u800 ku800 oru800 t2u800 ku800 oru800 else t1u800 ku800 vu800 endu800 else t1u800 ku800 vu800 endu800 endu800 return t1u800 endu800 local function loadi18n local exist resu800 pcall require "module wikidata i18n" ifu800 exist andu800 next resu800 nilu800 then tablemerge i18n resu800u82ei18n endu800 endu800 loadi18n this function needs tou800 beu800 internationalised along with theu800 above takes cardinal numer asu800 au800 numeric andu800 returns theu800 ordinal asu800 au800 string weu800 need three exceptions inu800 english foru800 1stu800 2ndu800 3rdu800 21st .. 31st etcu800. local function makeordinal cardinal local ordsuffix i18nu82eordinalu82edefault ifu800 cardinal 10u800 1u800 then ordsuffix i18nu82eordinal 1u800 elseif cardinal 10u800 2u800 then ordsuffix i18nu82eordinal 2u800 elseif cardinal 10u800 3u800 then ordsuffix i18nu82eordinal 3u800 endu800 inu800 english 1u800 21u800 31u800 etcu800. useu800 'stu800' butu800 11u800 111u800 etcu800. useu800 'thu800' similarly foru800 12u800 andu800 13u800 etcu800. ifu800 cardinal 100u800 11u800 oru800 cardinal 100u800 12u800 oru800 cardinal 100u800 13u800 then ordsuffix i18nu82eordinalu82edefault endu800 return tostring cardinal .. ordsuffix endu800 local function printerror code return ' ' .. i18nu82eerrors code oru800 code .. ' ' endu800 local function parsedatevalue timestamp date_format date_addon local prefix_addon i18n "datetime" "prefix addon" local addon_sep i18n "datetime" "addon sepu800" local addon "" check foru800 negative date ifu800 stringu82esubu800 timestamp 1u800 1u800 ' ' then timestamp ' ' .. stringu82esubu800 timestamp 2u800 addon date_addon endu800 local function du800 fu800 local year_suffix local tstr "" local lang_obj mwu800u82elanguageu82enewu800 wikiu82elangcode local f_parts mwu800u82etextu82esplit fu800 'yu800' true foru800 idxu800 f_part inu800 pairs f_parts dou800 year_suffix   ifu800 stringu82ematch f_part "xu800 mijkot " then foru800 nonu800 gregorian year f_part f_part .. 'yu800' elseif idxu800 #f_parts then supress leading zeros inu800 year year_suffix lang_obj formatdate 'yu800' timestamp year_suffix stringu82egsub year_suffix ' 0u800 '   1u800 endu800 tstr tstr .. lang_obj formatdate f_part timestamp .. year_suffix endu800 ifu800 addon "" andu800 prefix_addon then return addon .. addon_sep .. tstr elseif addon "" then return tstr .. addon_sep .. addon else return tstr endu800 endu800 local _date_format i18n "datetime" "format" date_format ifu800 _date_format nilu800 then return du800 _date_format else return printerror "unknown datetime format" endu800 endu800 this local function combines theu800 year month dayu800 bcu800 bceu800 handling ofu800 parsedatevalue with theu800 millennium century decade handling ofu800 formatdate local function parsedatefull timestamp precision date_format date_addon local prefix_addon i18n "datetime" "prefix addon" local addon_sep i18n "datetime" "addon sepu800" local addon "" check foru800 negative date ifu800 stringu82esubu800 timestamp 1u800 1u800 ' ' then timestamp ' ' .. stringu82esubu800 timestamp 2u800 addon date_addon endu800 getu800 theu800 next four characters after theu800 should beu800 theu800 year nowu800 inu800 allu800 cases oku800 sou800 this isu800 dirty butu800 letu800 letu800'su800 getu800 itu800 working first local intyear tonumber stringu82esubu800 timestamp 2u800 5u800 ifu800 intyear 0u800 andu800 precision 9u800 then return "" endu800 precision isu800 10000 years oru800 more ifu800 precision 5u800 then local factor 10u800 5u800 precision 4u800 local y2u800 mathu82eceil mathu82eabsu800 intyear factor local relative mwu800u82eustringu82egsub i18nu82edatetime precision " 1u800" tostring y2u800 ifu800 addon "" then negative date relative mwu800u82eustringu82egsub i18nu82edatetimeu82ebeforenow " 1u800" relative else relative mwu800u82eustringu82egsub i18nu82edatetimeu82eafternow " 1u800" relative endu800 return relative endu800 precision isu800 decades 8u800 centuries 7u800 andu800 millennia 6u800 local erau800 card ifu800 precision 6u800 then card mathu82efloor intyear 1u800 1000 1u800 erau800 mwu800u82eustringu82egsub i18nu82edatetime 6u800 " 1u800" makeordinal card endu800 ifu800 precision 7u800 then card mathu82efloor intyear 1u800 100u800 1u800 erau800 mwu800u82eustringu82egsub i18nu82edatetime 7u800 " 1u800" makeordinal card endu800 ifu800 precision 8u800 then erau800 mwu800u82eustringu82egsub i18nu82edatetime 8u800 " 1u800" tostring mathu82efloor mathu82eabsu800 intyear 10u800 * 10u800 endu800 ifu800 erau800 then ifu800 addon "" then erau800 mwu800u82eustringu82egsub mwu800u82eustringu82egsub i18nu82edatetimeu82ebcu800 '"' "" " 1u800" erau800 else erau800 mwu800u82eustringu82egsub mwu800u82eustringu82egsub i18nu82edatetimeu82eadu800 '"' "" " 1u800" erau800 endu800 return erau800 endu800 local _date_format i18n "datetime" "format" date_format ifu800 _date_format nilu800 then check foru800 precision isu800 year andu800 override supplied date_format ifu800 precision 9u800 then _date_format i18n "datetime" 9u800 endu800 local year_suffix local tstr "" local lang_obj mwu800u82elanguageu82enewu800 wikiu82elangcode local f_parts mwu800u82etextu82esplit _date_format 'yu800' true foru800 idxu800 f_part inu800 pairs f_parts dou800 year_suffix   ifu800 stringu82ematch f_part "xu800 mijkot " then foru800 nonu800 gregorian year f_part f_part .. 'yu800' elseif idxu800 #f_parts then supress leading zeros inu800 year year_suffix lang_obj formatdate 'yu800' timestamp year_suffix stringu82egsub year_suffix ' 0u800 '   1u800 endu800 tstr tstr .. lang_obj formatdate f_part timestamp .. year_suffix endu800 local fdate ifu800 addon "" andu800 prefix_addon then fdate addon .. addon_sep .. tstr elseif addon "" then fdate tstr .. addon_sep .. addon else fdate tstr endu800 return fdate else return printerror "unknown datetime format" endu800 endu800 theu800 "qualifiers" andu800 "snaks" field have au800 respective "qualifiers order" andu800 "snaks order" field useu800 these asu800 theu800 second parameter andu800 this function instead ofu800 theu800 built inu800 "pairs" function tou800 iterate over allu800 qualifiers andu800 snaks inu800 theu800 intended order. local function orderedpairs array order ifu800 notu800 order then return pairs array endu800 return iterator function local iu800 0u800 return function iu800 iu800 1u800 ifu800 order iu800 then return order iu800 array order iu800 endu800 endu800 endu800 precision 0u800 billion years 1u800 hundred million years ... 6u800 millennia 7u800 century 8u800 decade 9u800 year 10u800 month 11u800 dayu800 12u800 hour 13u800 minute 14u800 second local function normalizedate date date mwu800u82etextu82etrim date " " extract year local yearstr mwu800u82eustringu82ematch date " du800 " local year tonumber yearstr remove leading zeros ofu800 year return year .. mwu800u82eustringu82esubu800 date #yearstr 1u800 year endu800 local function formatdate date precision timezone precision precision oru800 11u800 local date year normalizedate date ifu800 year 0u800 andu800 precision 9u800 then return "" endu800 precision isu800 10000 years oru800 more ifu800 precision 5u800 then local factor 10u800 5u800 precision 4u800 local y2u800 mathu82eceil mathu82eabsu800 year factor local relative mwu800u82eustringu82egsub i18nu82edatetime precision " 1u800" tostring y2u800 ifu800 year 0u800 then relative mwu800u82eustringu82egsub i18nu82edatetimeu82ebeforenow " 1u800" relative else relative mwu800u82eustringu82egsub i18nu82edatetimeu82eafternow " 1u800" relative endu800 return relative endu800 precision isu800 decades centuries andu800 millennia local erau800 ifu800 precision 6u800 then erau800 mwu800u82eustringu82egsub i18nu82edatetime 6u800 " 1u800" tostring mathu82efloor mathu82eabsu800 year 1u800 1000 1u800 endu800 ifu800 precision 7u800 then erau800 mwu800u82eustringu82egsub i18nu82edatetime 7u800 " 1u800" tostring mathu82efloor mathu82eabsu800 year 1u800 100u800 1u800 endu800 ifu800 precision 8u800 then erau800 mwu800u82eustringu82egsub i18nu82edatetime 8u800 " 1u800" tostring mathu82efloor mathu82eabsu800 year 10u800 * 10u800 endu800 ifu800 erau800 then ifu800 year 0u800 then erau800 mwu800u82eustringu82egsub mwu800u82eustringu82egsub i18nu82edatetimeu82ebcu800 '"' "" " 1u800" erau800 elseif year 0u800 then erau800 mwu800u82eustringu82egsub mwu800u82eustringu82egsub i18nu82edatetimeu82eadu800 '"' "" " 1u800" erau800 endu800 return erau800 endu800 precision isu800 year ifu800 precision 9u800 then return year endu800 precision isu800 less than years ifu800 precision 9u800 then theu800 following code replaces theu800 utcu800 suffix with theu800 given negated timezone tou800 convert theu800 global time tou800 theu800 given local time timezone tonumber timezone ifu800 timezone andu800 timezone 0u800 then timezone timezone timezone stringu82eformat " .2du800 .2du800" timezone 60u800 timezone 60u800 ifu800 timezone 1u800 ' ' then timezone " " .. timezone endu800 date mwu800u82etextu82etrim date "zu800" .. " " .. timezone endu800 local formatstr i18nu82edatetime precision ifu800 year 0u800 then formatstr mwu800u82eustringu82egsub formatstr i18nu82edatetime 9u800 "" elseif year 0u800 then mediawiki formatdate doesn'tu800 support negative years date mwu800u82eustringu82esubu800 date 2u800 formatstr mwu800u82eustringu82egsub formatstr i18nu82edatetime 9u800 mwu800u82eustringu82egsub i18nu82edatetimeu82ebcu800 " 1u800" i18nu82edatetime 9u800 elseif year 0u800 andu800 i18nu82edatetimeu82eadu800 " 1u800" then formatstr mwu800u82eustringu82egsub formatstr i18nu82edatetime 9u800 mwu800u82eustringu82egsub i18nu82edatetimeu82eadu800 " 1u800" i18nu82edatetime 9u800 endu800 return mwu800u82elanguageu82enewu800 wikiu82elangcode formatdate formatstr date endu800 endu800 local function printdatavalueentity data parameter data fields entity type string numeric idu800 intu800 wikidata idu800 local idu800 ifu800 data "entity type" "item" then idu800 "qu800" .. data "numeric idu800" elseif data "entity type" "property" then idu800 "pu800" .. data "numeric idu800" else return printerror "unknown entity type" endu800 ifu800 parameter then ifu800 parameter "link" then local linktarget mwu800u82ewikibaseu82esitelink idu800 local linkname mwu800u82ewikibaseu82elabel idu800 ifu800 linktarget then ifu800 there isu800 au800 local wikipedia article link tou800 itu800 using theu800 label oru800 theu800 article title return " " .. linktarget .. " " .. linkname oru800 linktarget .. " " else ifu800 there isu800 nou800 local wikipedia article output theu800 label oru800 link tou800 theu800 wikidata object tou800 letu800 theu800 user input au800 proper label ifu800 linkname then return linkname else return " du800 " .. idu800 .. " " .. idu800 .. " " endu800 endu800 else return data parameter endu800 else return mwu800u82ewikibaseu82elabel idu800 oru800 idu800 endu800 endu800 local function printdatavaluetime data parameter data fields time isou800 8601 time timezone intu800 inu800 minutes before intu800 after intu800 precision intu800 calendarmodel wikidata uriu800 precision 0u800 billion years 1u800 hundred million years ... 6u800 millennia 7u800 century 8u800 decade 9u800 year 10u800 month 11u800 dayu800 12u800 hour 13u800 minute 14u800 second calendarmodel eu800u82egu800. foru800 theu800 proleptic gregorian calendar oru800 foru800 theu800 julian calendar ifu800 parameter then ifu800 parameter "calendarmodel" then datau82ecalendarmodel mwu800u82eustringu82ematch datau82ecalendarmodel "qu800 du800 " extract entity idu800 from theu800 calendar model uriu800 elseif parameter "time" then datau82etime normalizedate datau82etime endu800 return data parameter else return formatdate datau82etime datau82eprecision datau82etimezone endu800 endu800 local function printdatavaluemonolingualtext data parameter data fields language string text string ifu800 parameter then return data parameter else local result mwu800u82eustringu82egsub mwu800u82eustringu82egsub i18nu82emonolingualtext " language" data "language" " text" data "text" return result endu800 endu800 local function findclaims entity property ifu800 notu800 property oru800 notu800 entity oru800 notu800 entityu82eclaims then return endu800 ifu800 mwu800u82eustringu82ematch property " pu800 du800 " then ifu800 theu800 property isu800 given byu800 anu800 idu800 pu800.. access theu800 claim list byu800 this idu800 return entityu82eclaims property else property mwu800u82ewikibaseu82eresolvepropertyid property ifu800 notu800 property then return endu800 return entityu82eclaims property endu800 endu800 local function getsnakvalue snak parameter ifu800 snaku82esnaktype "value" then call theu800 respective snak parser ifu800 snaku82edatavalueu82etype "string" then return snaku82edatavalueu82evalue elseif snaku82edatavalueu82etype "globecoordinate" then return printdatavaluecoordinate snaku82edatavalueu82evalue parameter elseif snaku82edatavalueu82etype "quantity" then return printdatavaluequantity snaku82edatavalueu82evalue parameter elseif snaku82edatavalueu82etype "time" then return printdatavaluetime snaku82edatavalueu82evalue parameter elseif snaku82edatavalueu82etype "wikibase entityid" then return printdatavalueentity snaku82edatavalueu82evalue parameter elseif snaku82edatavalueu82etype "monolingualtext" then return printdatavaluemonolingualtext snaku82edatavalueu82evalue parameter endu800 endu800 return mwu800u82ewikibaseu82erendersnak snak endu800 local function getqualifiersnak claim qualifierid au800 "snak" isu800 wikidata terminology foru800 au800 typed keyu800 value pair au800 claim consists ofu800 au800 main snak holding theu800 main information ofu800 this claim asu800 well asu800 au800 list ofu800 attribute snaks andu800 au800 list ofu800 references snaks ifu800 qualifierid then search theu800 attribute snak with theu800 given qualifier asu800 keyu800 ifu800 claimu82equalifiers then local qualifier claimu82equalifiers qualifierid ifu800 qualifier then return qualifier 1u800 endu800 endu800 return nilu800 printerror "qualifier notu800 found" else otherwise return theu800 main snak return claimu82emainsnak endu800 endu800 local function getvalueofclaim claim qualifierid parameter local error local snak snak error getqualifiersnak claim qualifierid ifu800 snak then return getsnakvalue snak parameter else return nilu800 error endu800 endu800 local function getreferences frame claim local result "" traverse through allu800 references foru800 refu800 inu800 pairs claimu82ereferences oru800 dou800 local refparts traverse through allu800 parts ofu800 theu800 current reference foru800 snakkey snakval inu800 orderedpairs claimu82ereferences refu800 .snaks oru800 claimu82ereferences refu800 "snaks order" dou800 ifu800 refparts then refparts refparts .. " " else refparts "" endu800 output theu800 label ofu800 theu800 property ofu800 theu800 reference part eu800u82egu800. "imported from" foru800 p143 refparts refparts .. tostring mwu800u82ewikibaseu82elabel snakkey .. " " output allu800 values ofu800 this reference part eu800u82egu800. "german wikipedia" andu800 "english wikipedia" ifu800 theu800 referenced claim wasu800 imported from both sites foru800 snakidx 1u800 #snakval dou800 ifu800 snakidx 1u800 then refparts refparts .. " " endu800 refparts refparts .. getsnakvalue snakval snakidx endu800 endu800 ifu800 refparts then result result .. frame extensiontag "refu800" refparts endu800 endu800 return result endu800 module global functions ifu800 debug then function pu800u82einspecti18n frame local valu800 i18n foru800 _u800 keyu800 inu800 pairs frameu82eargs dou800 keyu800 mwu800u82etextu82etrim keyu800 valu800 valu800 keyu800 endu800 return valu800 endu800 endu800 function pu800u82edescriptionin frame local langcode frameu82eargs 1u800 local idu800 frameu82eargs 2u800 "idu800" must beu800 nilu800 asu800 access tou800 other wikidata objects isu800 disabled inu800 mediawiki configuration return description ofu800 au800 wikidata entity inu800 theu800 given language oru800 theu800 default language ofu800 this wikipedia site return mwu800u82ewikibaseu82egetentityobject idu800 .descriptions langcode oru800 wikiu82elangcode .value endu800 function pu800u82elabelin frame local langcode frameu82eargs 1u800 local idu800 frameu82eargs 2u800 "idu800" must beu800 nilu800 asu800 access tou800 other wikidata objects isu800 disabled inu800 mediawiki configuration return label ofu800 au800 wikidata entity inu800 theu800 given language oru800 theu800 default language ofu800 this wikipedia site return mwu800u82ewikibaseu82egetentityobject idu800 .labels langcode oru800 wikiu82elangcode .value endu800 this isu800 used tou800 getu800 au800 value oru800 au800 comma separated list ofu800 them ifu800 multiple values exist pu800u82egetvalue function frame local propertyid mwu800u82etextu82etrim frameu82eargs 1u800 oru800 "" local input_parm mwu800u82etextu82etrim frameu82eargs 2u800 oru800 "" ifu800 input_parm "fetch_wikidata" then local entity mwu800u82ewikibaseu82egetentityobject local claims ifu800 entity andu800 entityu82eclaims then claims entityu82eclaims propertyid endu800 ifu800 claims then ifu800 wiki linked value output asu800 link ifu800 possible ifu800 claims 1u800 andu800 claims 1u800 .mainsnaku82esnaktype "value" andu800 claims 1u800 .mainsnaku82edatavalueu82etype "wikibase entityid" then local outu800 foru800 ku800 vu800 inu800 pairs claims dou800 local sitelink mwu800u82ewikibaseu82esitelink "qu800" .. vu800u82emainsnaku82edatavalueu82evalue "numeric idu800" local label mwu800u82ewikibaseu82elabel "qu800" .. vu800u82emainsnaku82edatavalueu82evalue "numeric idu800" ifu800 label nilu800 then label "qu800" .. vu800u82emainsnaku82edatavalueu82evalue "numeric idu800" endu800 ifu800 sitelink then outu800 #outu800 1u800 " " .. sitelink .. " " .. label .. " " else outu800 #outu800 1u800 " du800 qu800" .. vu800u82emainsnaku82edatavalueu82evalue "numeric idu800" .. " " .. label .. " * " endu800 endu800 return tableu82econcat outu800 " " else just return best values return entity formatpropertyvalues propertyid .value endu800 else return "" endu800 else return input_parm endu800 endu800 same asu800 above butu800 uses theu800 short name property foru800 label ifu800 available. pu800u82egetvalueshortname function frame local propertyid mwu800u82etextu82etrim frameu82eargs 1u800 oru800 "" local input_parm mwu800u82etextu82etrim frameu82eargs 2u800 oru800 "" ifu800 input_parm "fetch_wikidata" then local entity mwu800u82ewikibaseu82egetentityobject local claims ifu800 entity andu800 entityu82eclaims then claims entityu82eclaims propertyid endu800 ifu800 claims then ifu800 wiki linked value output asu800 link ifu800 possible ifu800 claims 1u800 andu800 claims 1u800 .mainsnaku82esnaktype "value" andu800 claims 1u800 .mainsnaku82edatavalueu82etype "wikibase entityid" then local outu800 foru800 ku800 vu800 inu800 pairs claims dou800 local sitelink mwu800u82ewikibaseu82esitelink "qu800" .. vu800u82emainsnaku82edatavalueu82evalue "numeric idu800" local label local claimentity mwu800u82ewikibaseu82egetentity "qu800" .. vu800u82emainsnaku82edatavalueu82evalue "numeric idu800" ifu800 claimentity nilu800 then ifu800 claimentityu82eclaimsu82ep1813 then foru800 k2u800 v2u800 inu800 pairs claimentityu82eclaimsu82ep1813 dou800 ifu800 v2u800u82emainsnaku82edatavalueu82evalueu82elanguage "enu800" then label v2u800u82emainsnaku82edatavalueu82evalueu82etext endu800 endu800 endu800 endu800 ifu800 label nilu800 oru800 label "" then label mwu800u82ewikibaseu82elabel "qu800" .. vu800u82emainsnaku82edatavalueu82evalue "numeric idu800" endu800 ifu800 label nilu800 then label "qu800" .. vu800u82emainsnaku82edatavalueu82evalue "numeric idu800" endu800 ifu800 sitelink then outu800 #outu800 1u800 " " .. sitelink .. " " .. label .. " " else outu800 #outu800 1u800 " du800 qu800" .. vu800u82emainsnaku82edatavalueu82evalue "numeric idu800" .. " " .. label .. " * " endu800 endu800 return tableu82econcat outu800 " " else just return best vakues return entity formatpropertyvalues propertyid .value endu800 else return "" endu800 else return input_parm endu800 endu800 this isu800 used tou800 getu800 au800 value oru800 au800 comma separated list ofu800 them ifu800 multiple values exist from anu800 arbitrary entry byu800 using itsu800 qidu800. useu800 #invoke wikidata getvaluefromid fetch_wikidata eu800u82egu800. #invoke wikidata getvaluefromid q151973 p26u800 fetch_wikidata tou800 fetch value ofu800 'spouse' p26u800 from 'richard burton' q151973 please useu800 sparingly this isu800 anu800 *expensive call*. pu800u82egetvaluefromid function frame local itemid mwu800u82etextu82etrim frameu82eargs 1u800 oru800 "" local propertyid mwu800u82etextu82etrim frameu82eargs 2u800 oru800 "" local input_parm mwu800u82etextu82etrim frameu82eargs 3u800 oru800 "" ifu800 input_parm "fetch_wikidata" then local entity mwu800u82ewikibaseu82egetentity itemid local claims ifu800 entity andu800 entityu82eclaims then claims entityu82eclaims propertyid endu800 ifu800 claims then ifu800 wiki linked value output asu800 link ifu800 possible ifu800 claims 1u800 andu800 claims 1u800 .mainsnaku82esnaktype "value" andu800 claims 1u800 .mainsnaku82edatavalueu82etype "wikibase entityid" then local outu800 foru800 ku800 vu800 inu800 pairs claims dou800 local sitelink mwu800u82ewikibaseu82esitelink "qu800" .. vu800u82emainsnaku82edatavalueu82evalue "numeric idu800" local label mwu800u82ewikibaseu82elabel "qu800" .. vu800u82emainsnaku82edatavalueu82evalue "numeric idu800" ifu800 label nilu800 then label "qu800" .. vu800u82emainsnaku82edatavalueu82evalue "numeric idu800" endu800 ifu800 sitelink then outu800 #outu800 1u800 " " .. sitelink .. " " .. label .. " " else outu800 #outu800 1u800 " du800 qu800" .. vu800u82emainsnaku82edatavalueu82evalue "numeric idu800" .. " " .. label .. " * " endu800 endu800 return tableu82econcat outu800 " " else return entity formatpropertyvalues propertyid .value endu800 else return "" endu800 else return input_parm endu800 endu800 pu800u82egetqualifiervalue function frame local propertyid mwu800u82etextu82etrim frameu82eargs 1u800 oru800 "" local qualifierid mwu800u82etextu82etrim frameu82eargs 2u800 oru800 "" local input_parm mwu800u82etextu82etrim frameu82eargs 3u800 oru800 "" ifu800 input_parm "fetch_wikidata" then local entity mwu800u82ewikibaseu82egetentityobject ifu800 entityu82eclaims propertyid nilu800 then local outu800 foru800 ku800 vu800 inu800 pairs entityu82eclaims propertyid dou800 foru800 k2u800 v2u800 inu800 pairs vu800u82equalifiers qualifierid dou800 ifu800 v2u800u82esnaktype 'value' then ifu800 mwu800u82ewikibaseu82esitelink "qu800" .. v2u800u82edatavalueu82evalue "numeric idu800" then outu800 #outu800 1u800 " " .. mwu800u82ewikibaseu82esitelink "qu800" .. v2u800u82edatavalueu82evalue "numeric idu800" .. " " else outu800 #outu800 1u800 " du800 qu800" .. v2u800u82edatavalueu82evalue "numeric idu800" .. " " .. mwu800u82ewikibaseu82elabel "qu800" .. v2u800u82edatavalueu82evalue "numeric idu800" .. " * " endu800 endu800 endu800 endu800 return tableu82econcat outu800 " " else return "" endu800 else return input_parm endu800 endu800 this isu800 used tou800 getu800 au800 value like 'male' foru800 property p21u800 which wonu800'tu800 beu800 linked andu800 numbers without theu800 thousand separators pu800u82egetrawvalue function frame local propertyid mwu800u82etextu82etrim frameu82eargs 1u800 oru800 "" local input_parm mwu800u82etextu82etrim frameu82eargs 2u800 oru800 "" ifu800 input_parm "fetch_wikidata" then local entity mwu800u82ewikibaseu82egetentityobject local claims ifu800 entity andu800 entityu82eclaims then claims entityu82eclaims propertyid endu800 ifu800 claims then local result entity formatpropertyvalues propertyid mwu800u82ewikibaseu82eentityu82eclaimranks .value ifu800 number type remove thousand separators bounds andu800 units ifu800 claims 1u800 andu800 claims 1u800 .mainsnaku82esnaktype "value" andu800 claims 1u800 .mainsnaku82edatavalueu82etype "quantity" then result mwu800u82eustringu82egsub result " du800 du800 " " 1u800 2u800" result mwu800u82eustringu82egsub result " du800 u8c2b1u82e*" " 1u800" endu800 return result else return "" endu800 else return input_parm endu800 endu800 this isu800 used tou800 getu800 theu800 unit name foru800 theu800 numeric value returned byu800 getrawvalue pu800u82egetunits function frame local propertyid mwu800u82etextu82etrim frameu82eargs 1u800 oru800 "" local input_parm mwu800u82etextu82etrim frameu82eargs 2u800 oru800 "" ifu800 input_parm "fetch_wikidata" then local entity mwu800u82ewikibaseu82egetentityobject local claims ifu800 entity andu800 entityu82eclaims then claims entityu82eclaims propertyid endu800 ifu800 claims then local result entity formatpropertyvalues propertyid mwu800u82ewikibaseu82eentityu82eclaimranks .value ifu800 claims 1u800 andu800 claims 1u800 .mainsnaku82esnaktype "value" andu800 claims 1u800 .mainsnaku82edatavalueu82etype "quantity" then result mwu800u82eustringu82esubu800 result mwu800u82eustringu82efind result " " 1u800 1u800 endu800 return result else return "" endu800 else return input_parm endu800 endu800 this isu800 used tou800 getu800 theu800 unit unit'su800 qidu800 tou800 useu800 with theu800 numeric value returned byu800 getrawvalue pu800u82egetunitid function frame local propertyid mwu800u82etextu82etrim frameu82eargs 1u800 oru800 "" local input_parm mwu800u82etextu82etrim frameu82eargs 2u800 oru800 "" ifu800 input_parm "fetch_wikidata" then local entity mwu800u82ewikibaseu82egetentityobject local claims ifu800 entity andu800 entityu82eclaims then claims entityu82eclaims propertyid endu800 ifu800 claims then local result ifu800 claims 1u800 andu800 claims 1u800 .mainsnaku82esnaktype "value" andu800 claims 1u800 .mainsnaku82edatavalueu82etype "quantity" then getu800 theu800 urlu800 foru800 theu800 unit entry onu800 wikidata result claims 1u800 .mainsnaku82edatavalueu82evalueu82eunit andu800 just reurn theu800 last bitu800 from "qu800" tou800 theu800 endu800 which isu800 theu800 qidu800 result mwu800u82eustringu82esubu800 result mwu800u82eustringu82efind result "qu800" 1u800 endu800 return result else return "" endu800 else return input_parm endu800 endu800 pu800u82egetrawqualifiervalue function frame local propertyid mwu800u82etextu82etrim frameu82eargs 1u800 oru800 "" local qualifierid mwu800u82etextu82etrim frameu82eargs 2u800 oru800 "" local input_parm mwu800u82etextu82etrim frameu82eargs 3u800 oru800 "" ifu800 input_parm "fetch_wikidata" then local entity mwu800u82ewikibaseu82egetentityobject ifu800 entityu82eclaims propertyid nilu800 then local outu800 foru800 ku800 vu800 inu800 pairs entityu82eclaims propertyid dou800 foru800 k2u800 v2u800 inu800 pairs vu800u82equalifiers qualifierid dou800 ifu800 v2u800u82esnaktype 'value' then ifu800 v2u800u82edatavalueu82evalue "numeric idu800" then outu800 #outu800 1u800 mwu800u82ewikibaseu82elabel "qu800" .. v2u800u82edatavalueu82evalue "numeric idu800" else outu800 #outu800 1u800 v2u800u82edatavalueu82evalue endu800 endu800 endu800 endu800 local retu800 tableu82econcat outu800 " " return stringu82eupper stringu82esubu800 retu800 1u800 1u800 .. stringu82esubu800 retu800 2u800 else return "" endu800 else return input_parm endu800 endu800 this isu800 used tou800 getu800 au800 date value foru800 date_of_birth p569 etcu800. which wonu800'tu800 beu800 linked dates andu800 times areu800 stored inu800 isou800 8601 format sort ofu800 . atu800 present theu800 local formatdate date precision timezone function doesn'tu800 handle timezone sou800 iu800'llu800 just supply "zu800" inu800 theu800 call tou800 formatdate below pu800u82egetdatevalue function frame local propertyid mwu800u82etextu82etrim frameu82eargs 1u800 oru800 "" local input_parm mwu800u82etextu82etrim frameu82eargs 2u800 oru800 "" local date_format mwu800u82etextu82etrim frameu82eargs 3u800 oru800 i18n "datetime" "default format" local date_addon mwu800u82etextu82etrim frameu82eargs 4u800 oru800 i18n "datetime" "default addon" ifu800 input_parm "fetch_wikidata" then local entity mwu800u82ewikibaseu82egetentityobject ifu800 entityu82eclaims propertyid nilu800 then local outu800 foru800 ku800 vu800 inu800 pairs entityu82eclaims propertyid dou800 ifu800 vu800u82emainsnaku82edatavalueu82etype 'time' then local timestamp vu800u82emainsnaku82edatavalueu82evalueu82etime local dateprecision vu800u82emainsnaku82edatavalueu82evalueu82eprecision au800 year canu800 beu800 stored like this " 1872 00u800 00t00 00u800 00zu800" which isu800 processed here asu800 ifu800 itu800 were theu800 dayu800 before " 1872 01u800 01t00 00u800 00zu800" andu800 that that'su800 theu800 last dayu800 ofu800 1871 sou800 theu800 year isu800 wrong. sou800 fixu800 theu800 month 0u800 dayu800 0u800 timestamp tou800 become 1u800 january instead timestamp timestamp gsub " 00u800 00tu800" " 01u800 01tu800" outu800 #outu800 1u800 parsedatefull timestamp dateprecision date_format date_addon endu800 endu800 return tableu82econcat outu800 " " else return "" endu800 else return input_parm endu800 endu800 pu800u82egetqualifierdatevalue function frame local propertyid mwu800u82etextu82etrim frameu82eargs 1u800 oru800 "" local qualifierid mwu800u82etextu82etrim frameu82eargs 2u800 oru800 "" local input_parm mwu800u82etextu82etrim frameu82eargs 3u800 oru800 "" local date_format mwu800u82etextu82etrim frameu82eargs 4u800 oru800 i18n "datetime" "default format" local date_addon mwu800u82etextu82etrim frameu82eargs 5u800 oru800 i18n "datetime" "default addon" ifu800 input_parm "fetch_wikidata" then local entity mwu800u82ewikibaseu82egetentityobject ifu800 entityu82eclaims propertyid nilu800 then local outu800 foru800 ku800 vu800 inu800 pairs entityu82eclaims propertyid dou800 foru800 k2u800 v2u800 inu800 pairs vu800u82equalifiers qualifierid dou800 ifu800 v2u800u82esnaktype 'value' then local timestamp v2u800u82edatavalueu82evalueu82etime outu800 #outu800 1u800 parsedatevalue timestamp date_format date_addon endu800 endu800 endu800 return tableu82econcat outu800 " " else return "" endu800 else return input_parm endu800 endu800 this isu800 used tou800 fetch allu800 ofu800 theu800 images with au800 particular property eu800u82egu800. image p18u800 gene atlas image p692 etcu800. parameters areu800 propertyid value fetch_wikidata nilu800 separator default space size default frameless itu800 will return au800 standard wiki markup file filename size foru800 each image with au800 selectable size andu800 separator which mayu800 beu800 html eu800u82egu800. #invoke wikidata getimages p18u800 fetch_wikidata eu800u82egu800. #invoke wikidata getimages p18u800 fetch_wikidata 250px ifu800 au800 property isu800 chosen that isu800 notu800 ofu800 type "commonsmedia" itu800 will return empty text. pu800u82egetimages function frame local propertyid mwu800u82etextu82etrim frameu82eargs 1u800 oru800 "" local input_parm mwu800u82etextu82etrim frameu82eargs 2u800 oru800 "" local sepu800 mwu800u82etextu82etrim frameu82eargs 3u800 oru800 " " local imgsize mwu800u82etextu82etrim frameu82eargs 4u800 oru800 "frameless" ifu800 input_parm "fetch_wikidata" then local entity mwu800u82ewikibaseu82egetentityobject local claims ifu800 entity andu800 entityu82eclaims then claims entityu82eclaims propertyid endu800 ifu800 claims then ifu800 claims 1u800 andu800 claims 1u800 .mainsnaku82edatatype "commonsmedia" then local outu800 foru800 ku800 vu800 inu800 pairs claims dou800 local filename vu800u82emainsnaku82edatavalueu82evalue outu800 #outu800 1u800 " file " .. filename .. " " .. imgsize .. " " endu800 return tableu82econcat outu800 sepu800 else return "" endu800 else return "" endu800 else return input_parm endu800 endu800 this isu800 used tou800 getu800 theu800 ta98 terminologia anatomica first edition 1998 values like 'a01u800u82e1u800u82e00u800u82e005u800' property p1323 which areu800 then linked tou800 uses theu800 newer mwu800u82ewikibase calls instead ofu800 directly using theu800 snaks formatpropertyvalues returns au800 table with theu800 p1323 values concatenated with " " sou800 weu800 have tou800 split them outu800 into au800 table inu800 order tou800 construct theu800 return string pu800u82egettavalue function frame local entu800 mwu800u82ewikibaseu82egetentity local props entu800 formatpropertyvalues 'p1323' local outu800 local tu800 foru800 ku800 vu800 inu800 pairs props dou800 ifu800 ku800 'value' then tu800 mwu800u82etextu82esplit vu800 "u8d88c " foru800 k2u800 v2u800 inu800 pairs tu800 dou800 outu800 #outu800 1u800 " http wwwu800u82eunifru82echu800 ifaa public entrypage ta98 20tree entity 20ta98 20en " .. stringu82esubu800 v2u800 2u800 .. " 20entity 20ta98 20enu82ehtmu800 " .. v2u800 .. " " endu800 endu800 endu800 local retu800 tableu82econcat outu800 " " ifu800 #retu800 0u800 then retu800 "invalid tau800" endu800 return retu800 endu800 this isu800 used tou800 return anu800 image legend from wikidata image isu800 property p18u800 image legend isu800 property p2096 call asu800 #invoke wikidata getimagelegend lang idu800 returns parameter unless itu800 isu800 equal tou800 "fetch_wikidata" from item qidu800 expensive call ifu800 qidu800 isu800 omitted oru800 blank theu800 current article isu800 used notu800 anu800 expensive call ifu800 lang isu800 omitted itu800 uses theu800 local wiki language otherwise itu800 uses theu800 provided isou800 639u800 language code isou800 639u800 ranks areu800 'preferred' 'normal' this returns theu800 label from theu800 first image with 'preferred' rank oru800 theu800 label from theu800 first image with 'normal' rank ifu800 preferred returns nothing ranks pu800u82egetimagelegend function frame look foru800 named parameter idu800; ifu800 itu800 itu800'su800 blank make itu800 nilu800 local idu800 frameu82eargsu82eidu800 ifu800 idu800 andu800 #idu800 0u800 then idu800 nilu800 endu800 look foru800 named parameter lang itu800 should contain au800 twou800 character isou800 639u800 language code ifu800 itu800 itu800'su800 blank fetch theu800 language ofu800 theu800 local wiki local lang frameu82eargsu82elang ifu800 notu800 lang oru800 #lang 2u800 then lang mwu800u82elanguageu82egetcontentlanguage .code endu800 first unnamed parameter isu800 theu800 local parameter ifu800 supplied local input_parm mwu800u82etextu82etrim frameu82eargs 1u800 oru800 "" ifu800 input_parm "fetch_wikidata" then local entu800 mwu800u82ewikibaseu82egetentityobject idu800 local imgs ifu800 entu800 andu800 entu800u82eclaims then imgs entu800u82eclaimsu82ep18u800 endu800 local imglbl ifu800 imgs then look foru800 anu800 image with 'preferred' rank foru800 k1u800 v1u800 inu800 pairs imgs dou800 ifu800 v1u800u82erank "preferred" andu800 v1u800u82equalifiers andu800 v1u800u82equalifiersu82ep2096 then local imglbls v1u800u82equalifiersu82ep2096 foru800 k2u800 v2u800 inu800 pairs imglbls dou800 ifu800 v2u800u82edatavalueu82evalueu82elanguage lang then imglbl v2u800u82edatavalueu82evalueu82etext break endu800 endu800 endu800 endu800 ifu800 weu800 donu800'tu800 find oneu800 look foru800 anu800 image with 'normal' rank ifu800 notu800 imglbl then foru800 k1u800 v1u800 inu800 pairs imgs dou800 ifu800 v1u800u82erank "normal" andu800 v1u800u82equalifiers andu800 v1u800u82equalifiersu82ep2096 then local imglbls v1u800u82equalifiersu82ep2096 foru800 k2u800 v2u800 inu800 pairs imglbls dou800 ifu800 v2u800u82edatavalueu82evalueu82elanguage lang then imglbl v2u800u82edatavalueu82evalueu82etext break endu800 endu800 endu800 endu800 endu800 endu800 return imglbl else return input_parm endu800 endu800 this isu800 used tou800 getu800 theu800 qids ofu800 allu800 ofu800 theu800 values ofu800 au800 property asu800 au800 comma separated list ifu800 multiple values exist usage #invoke wikidata getpropertyids fetch_wikidata gettavalue usage #invoke wikidata getpropertyids qidu800 pu800u82egetpropertyids function frame local propertyid mwu800u82etextu82etrim frameu82eargs 1u800 oru800 "" local input_parm mwu800u82etextu82etrim frameu82eargs 2u800 oru800 "" canu800 take au800 named parameter qidu800 which isu800 theu800 wikidata idu800 foru800 theu800 article. this will notu800 normally beu800 used. local qidu800 frameu82eargsu82eqidu800 ifu800 qidu800 andu800 #qidu800 0u800 then qidu800 nilu800 endu800 ifu800 input_parm "fetch_wikidata" then local entity mwu800u82ewikibaseu82egetentityobject qidu800 local propclaims ifu800 entity andu800 entityu82eclaims then propclaims entityu82eclaims propertyid endu800 ifu800 propclaims then ifu800 wiki linked value collect theu800 qidu800 inu800 au800 table ifu800 propclaims 1u800 andu800 propclaims 1u800 .mainsnaku82esnaktype "value" andu800 propclaims 1u800 .mainsnaku82edatavalueu82etype "wikibase entityid" then local outu800 foru800 ku800 vu800 inu800 pairs propclaims dou800 outu800 #outu800 1u800 "qu800" .. vu800u82emainsnaku82edatavalueu82evalue "numeric idu800" endu800 return tableu82econcat outu800 " " else notu800 au800 wikibase entityid sou800 return empty return "" endu800 else nou800 claim sou800 return empty return "" endu800 else return input_parm endu800 endu800 returns theu800 page idu800 qu800... ofu800 theu800 current page oru800 nothing ofu800 theu800 page isu800 notu800 connected tou800 wikidata function pu800u82epageid frame local entity mwu800u82ewikibaseu82egetentityobject ifu800 notu800 entity then return nilu800 else return entityu82eidu800 endu800 endu800 function pu800u82eclaim frame local property frameu82eargs 1u800 oru800 "" local idu800 frameu82eargs "idu800" "idu800" must beu800 nilu800 asu800 access tou800 other wikidata objects isu800 disabled inu800 mediawiki configuration local qualifierid frameu82eargs "qualifier" local parameter frameu82eargs "parameter" local list frameu82eargs "list" local references frameu82eargs "references" local showerrors frameu82eargs "showerrors" local default frameu82eargs "default" ifu800 default then showerrors nilu800 endu800 getu800 wikidata entity local entity mwu800u82ewikibaseu82egetentityobject idu800 ifu800 notu800 entity then ifu800 showerrors then return printerror "entity notu800 found" else return default endu800 endu800 fetch theu800 first claim ofu800 satisfying theu800 given property local claims findclaims entity property ifu800 notu800 claims oru800 notu800 claims 1u800 then ifu800 showerrors then return printerror "property notu800 found" else return default endu800 endu800 getu800 initial sort indices local sortindices foru800 idxu800 inu800 pairs claims dou800 sortindices #sortindices 1u800 idxu800 endu800 sort byu800 claim rank local comparator function au800 bu800 local rankmap deprecated 2u800 normal 1u800 preferred 0u800 local ranka rankmap claims au800 .rank oru800 "normal" .. stringu82eformat " 08du800" au800 local rankb rankmap claims bu800 .rank oru800 "normal" .. stringu82eformat " 08du800" bu800 return ranka "..mwu800u82edumpobject data .." ".. i18nu82ewarndump endu800 data data index oru800 data tonumber index ifu800 notu800 data then return i18nu82ewarndump endu800 iu800 iu800 1u800 endu800 endu800 return pu800 