ماژول:Wikidata2/tax
نما
توضیحات این پودمان میتواند در ماژول:Wikidata2/tax/توضیحات قرار گیرد.
-- This module implements [[template:تصنيف كائن/تصنيف علمي ويكي بيانات]].
local p = {}
local Cash = require('Module:Wikidata2/tax/cash')
local Cash2 = {}
local colors = {
['Q808'] = '#EE82EE', -- فيروس
['Q10872'] = '#ECD2D2', -- عتائق
['Q10876'] = '#D3D3D3', -- بكتيريا
['Q10892'] = '#F0E68C', -- طلائعيات
['Q862296'] = '#ADEE3F', -- أسناخ
['Q756'] = '#90EE90', -- نبات
['Q764'] = '#ADD8E6', -- فطر
['Q729'] = '#D3D3A4', -- حيوان
['Q855740'] = '#E1CCFC', --جذراوات
['Q1205126'] = '#E0D0B0', -- قمعيات
['Q473809'] = '#FFC8A0', --متموريات
--[''] = '#FAF0E6', -- غير محدد
[''] = '',
}
local taxP105= {
--[''] = 'محدوده',
['Q22666877'] = 'جور محدوده', -- نطاق
['Q19858692'] = 'جور قلمرو',
['Q36732'] = 'قلمرو', -- مملکه
['Q38348'] = 'چله', -- شعبه
['Q37517'] = 'رجه', -- طائفة
['Q36602'] = 'راسته', -- رتبه
['Q35409'] = 'خانواده', -- فصيلة
['Q34740'] = 'جنس', -- سرده یا جنس
['Q7432'] = 'تی', -- نوع
['Q2752679'] = 'جیر قلمرو', -- عولیم
['Q3150876'] = 'فرعی قلمرو', --مملكة فرعية
['Q3978005'] = 'جور چله', -- شعبة عليا
['Q334460'] = 'چلّه', -- شعبه
['Q1153785'] = 'جیر چله',
['Q2361851'] = 'فرعی چله',
['Q3504061'] = 'جور رجه',
['Q5867051'] = 'جیر رجه', -- زیررده یا طويئفة
['Q2007442'] = 'فرعی رجه',
['Q6054237'] = 'پیل راسته',
['Q5868144'] = 'جور راسته',
['Q6462265'] = 'گت راسته',
['Q21074316'] = 'میون راسته',
['Q7506274'] = 'میونه راسته',
['Q6311258'] = 'پچیک راسته',
['Q2889003'] = 'فرعی راسته',
['Q5867959'] = 'جیر راسته',
['Q164280'] = 'جیر خانواده',
['Q2455704'] = 'جیر خانواده',
['Q68947'] = 'جیر تی',
['Q2136103'] = 'جور خانواده',
['Q10296147'] = 'اضافی خانواده',
['Q767728'] = 'جوره',
['Q227936'] = 'تبار',
['Q3238261'] = 'جیر جنس',
['Q3181348'] = 'بخش',
['Q3965313'] = 'جیر تبار',
['Q279749'] = 'شكل',
['Q3025161'] = 'سری',
['Q5998839'] = 'جیر بخش',
['Q4886'] = 'رقم',
['Q3825509'] = 'شكل خاص',
['Q4150646'] = 'گروه',
['Q14817220'] = 'فرا تبار',
['Q10861426'] = 'بخشه',
['Q3491997'] = 'جیر دسته',
['Q855769'] = 'سویه',
['Q13198444'] = 'جیر سری',
['Q21559275'] = 'جور بخشه',
['Q2981883'] = 'همزاد',
['Q10861375'] = 'جیر بخش',
['Q630771'] = 'جیر جوره',
['Q6541077'] = 'جیر گروه',
['Q6054425'] = 'جور گروه',
['Q42621'] = 'دِ رگ',
['Q4226087'] = 'فرعی گروه',
['Q26857882'] = 'پچیک قلمرو',
['Q3798630'] = 'فرعی تبار',
['Q3491996'] = 'جیر محدوده',
}
function add_Tracking_Category(prop,options)
return prop .. addTrackingCategory(options)
--return prop
end
function foo(iid, formatting, p)
if not iid or iid =='' then return nil end
so = nil
st = formatStatements( {property=p , entityId=iid, enlabelcate='t', noref='t', firstvalue='true', formatting=formatting})
if st and st ~= '' then
so = st
end
return so
end
function GetP171id( id )
if not id or id =='' then return nil end
----------------
if Cash[id] and Cash[id]["P171"] and Cash[id]["P171"] ~= ""
then
st = Cash[id]["P171"]
else
st = formatStatements( {property ='P171' , entityId = id,rank='best', noref ='t', firstvalue='true',formatting="raw"})
if not Cash2[id] then Cash2[id] = {} end
if st and st ~= "" then
Cash2[id]["P171"] = st
end
end
return st
end
function taxcolours2( id , options)
--local id = GetP171id( id )
i = 0
ccc = ""
while ccc == "" and i < 30 do
e = foo( id , "raw" , 'P105')
if e and e ~= '' then
if e == 'Q36732' then
if colors[id] and colors[id] ~= "" then
ccc = colors[id]
end
end
end
id = GetP171id( id )
i = i + 1
end
---------------------------
if ccc == "" and options.colour and options.colour ~= ""
then
ccc = options.colour
end
---------------------------
return ccc
---------------------------
end
function taxonrank(iid)
vvv = nil
if not iid or iid =='' then return nil end
------------------------
local rank_raw;
local rank_lab;
if Cash[iid] and Cash[iid]["P105"] and Cash[iid]["P105"] ~= "" then
rank_raw = Cash[iid]["P105"]
else
rank_raw = formatStatements( {property ='P105' , entityId = iid, enlabelcate='t', noref ='t', firstvalue='true',formatting='raw'})
if not Cash2[iid] then Cash2[iid] = {} end
Cash2[iid]["P105"] = rank_raw
end
if not rank_raw or rank_raw =='' then return nil end
------------------------
if taxP105[rank_raw] and taxP105[rank_raw] ~= "" then
vvv = add_Tracking_Category(taxP105[rank_raw] ,{property='P105', entityId = iid,noicon='t'})
else
rank_lab = formatStatements( {property ='P105' , entityId = iid, enlabelcate='t', noref ='t', firstvalue='true',formatting=''})
if rank_lab and rank_lab ~= '' then
mw.log("Module:Wikidata2/tax: taxP105['" .. rank_raw .. "'] = '" .. rank_lab .. "'" )
vvv = add_Tracking_Category(rank_lab .. '' ,{property='P105', entityId = iid,noicon='t'})
end
end
------------------------
return vvv
end
function pro1(id)
if not id or id =='' then return nil end
----------------
id_r = formatStatements( {property ='P171' , entityId = id, enlabelcate='t', noref ='t', firstvalue='true',formatting='raw'})
if id_r and id_r ~= "" then
if Cash[id_r] and Cash[id_r]["label"] and Cash[id_r]["label"] ~= ""
then
label = Cash[id_r]["label"]
else
label = formatStatements( {property ='P171' , entityId = id,enlabelcate='t',noref ='e', firstvalue='true'})
if not Cash2[id_r] then Cash2[id_r] = {} end
if label and label ~= "" then Cash2[id_r]["label"] = label end
end
end
return label
end
function dd(id, taxo_id )
-- taxolabel : موجود
-- d : طبقهبندی هکردن
if id and id ~= '' then
taxolabel = pro1( taxo_id )
d = taxonrank(id)
----------------
if not d or d == '' then
--d = foo( id , '' , 'P31' )
--mw.log( "Module:Wikidata2/tax: foo[" .. id .. "] = " .. d)
return nil
end
----------------
if taxolabel and taxolabel ~= '' then
if d and d ~= ''
then
return d .. '||'.. taxolabel
else
return taxolabel
end
end
end
end
function dd_old(id, taxolabel )
-- taxolabel : موجود
-- d : طبقهبندی هکردن
if id and id ~= '' then
d = taxonrank(id) -- طبقهبندی هکردن
----------------
if not d or d == ''
then return nil --'' -- nil
end
----------------
if taxolabel and taxolabel ~= '' then
if d and d ~= ''
then
return d .. '||'.. taxolabel
else
return taxolabel
end
end
end
end
function gettax( value_id, coo, lll, options)
local P = {}
local number = 1
local id_1 = value_id or ""
----------
mw.log("id_1 :" .. id_1)
P[0] = dd_old(value_id, lll )
----------
while number < 31 do
s_id = GetP171id( id_1 )
P[number] = dd(s_id, id_1 )
id_1 = s_id
number = number + 1
end
------------------------
for k, v in pairs(Cash2) do
if (v["P171"] and v["P171"] ~= "") and ( v["P105"] and v["P105"] ~= "") then
mw.log( "Module:Wikidata2/tax: Cash['" .. k .. "']= {['P105'] = '" ..( v["P105"] or "" ).. "' , ['P171'] = '" .. (v["P171"] or "") .. "' , ['label'] = '" .. (v["label"] or "") .. "' }" )
end
end
----------------
ti = 'علمی طبقهبندی'
title = 'colspan=\"2\" style=\"text-align: center;background-color:' ..coo..';" | ' .. add_Tracking_Category(ti ,options)
head = '{| class="infobox biota" style="text-align: right; width: 200px; font-size: 100%%"'
End = '}'
----------------
local taxon1 = {
P[30] or "" , P[29] or "" , P[28] or "" ,
P[27] or "" , P[26] or "" , P[25] or "" , P[24] or "" ,
P[23] or "" , P[22] or "" , P[21] or "" , P[20] or "" ,
P[19] or "" , P[18] or "" , P[17] or "" , P[16] or "" ,
P[15] or "" , P[14] or "" , P[13] or "" , P[12] or "" ,
P[11] or "" , P[10] or "" , P[9] or "" , P[8] or "" ,
P[7] or "" , P[6] or "" , P[5] or "" , P[4] or "" ,
P[3] or "" , P[2] or "" , P[1] or "" , P[0] or "" ,
}
----------------
local q = {}
--table.insert( q,head )
table.insert( q, title )
for i,j in ipairs( taxon1 ) do
e = i..j
if j and j ~= ''
then table.insert( q,j )
end
end
----------------
--table.insert( q,End )
taxonSections = table.concat( q, "\n|-\n|")
result = string.format([[%s
|-
!%s
|-
|%s
%s]], head, title, taxonSections, End )
----------------
return taxonSections --result
end
function p.tax( datavalue, datatype, options)
local value_id = datavalue.value.id
local colour = taxcolours2( value_id , options)
local lll = formatEntityId( value_id , options ).value
return gettax( value_id, colour, lll, options)
end
function p.taxcolour( datavalue, datatype, options)
--return taxcolours(datavalue.value.id, options)
return taxcolours2(datavalue.value.id, options)
end
function p.gg(frame)
return gettax( frame.args[1] ,"#ffffff", "test" , frame.args)
end
return p