وحدة:Wikidata2/dump
isSubclass
عدلإن كانت قيمة نموذج من (P31) أو صنف فرعي من (P279) للصفحة التي وضع فيها الكود أو للصفحة في الوسيط |id=
مساوية للوسيط |parent=
ينتج 'true' غير ذلك لا ينتج شيئاً.
كامل الخيارات:{{#invoke:Wikidata2{{#تبديل:{{SUBPAGENAME}}|ملعب=/ملعب}} |isSubclass|parent=|maxDepth=1|property=|id=|exitItem=}}
- مطلوب:
|parent=
مثلاً إنسان (Q5) |maxDepth=
عمق البحث في الصفحات.|property=
الخاصية المطلوبه (افتراضياً نموذج من (P31)، وصنف فرعي من (P279))|id=
الصفحة المطلوب البحث فيها.|exitItem=
مثال:
{{#invoke:Wikidata2|isSubclass|maxDepth=1|id=Q76|parent=Q5}}
← true
{{#invoke:Wikidata2|isSubclass|maxDepth=5|id=Q76|parent=Q45}}
←
Dump
عدلمثال: {{#invoke:Wikidata2{{#تبديل:{{SUBPAGENAME}}|ملعب=/ملعب}} |Dump|claims|P19}}
- مثال2:
{{#invoke:Wikidata2{{#تبديل:{{SUBPAGENAME}}|ملعب=/ملعب}} |Dump|id=Q76|claims|P19}}
مثال
table#1 {
table#2 {
["id"] = "Q76$6c5e3740-4ca4-de6a-1557-b623372dc93a",
["mainsnak"] = table#3 {
["datatype"] = "wikibase-item",
["datavalue"] = table#4 {
["type"] = "wikibase-entityid",
["value"] = table#5 {
["entity-type"] = "item",
["id"] = "Q6366688",
["numeric-id"] = 6366688,
},
},
["property"] = "P19",
["snaktype"] = "value",
},
["qualifiers"] = table#6 {
["P1932"] = table#7 {
table#8 {
["datatype"] = "string",
["datavalue"] = table#9 {
["type"] = "string",
["value"] = "Kapiolani Maternity & Gynecological Hospital",
},
["hash"] = "6fd68e03eb688ae2bc3065f585acd78edbe8fa5b",
["property"] = "P1932",
["snaktype"] = "value",
},
},
["P6375"] = table#10 {
table#11 {
["datatype"] = "monolingualtext",
["datavalue"] = table#12 {
["type"] = "monolingualtext",
["value"] = table#13 {
["language"] = "en",
["text"] = "6085 Kalanianaole Highway",
},
},
["hash"] = "2e9be82b6a3154de13d7196988eb8b40dc8f0252",
["property"] = "P6375",
["snaktype"] = "value",
},
},
["P7452"] = table#14 {
table#15 {
["datatype"] = "wikibase-item",
["datavalue"] = table#16 {
["type"] = "wikibase-entityid",
["value"] = table#17 {
["entity-type"] = "item",
["id"] = "Q71536040",
["numeric-id"] = 71536040,
},
},
["hash"] = "f9f842b41f249e5504d48025c7ad6d7b5bfc7496",
["property"] = "P7452",
["snaktype"] = "value",
},
},
},
["qualifiers-order"] = table#18 {
"P6375",
"P1932",
"P7452",
},
["rank"] = "preferred",
["references"] = table#19 {
table#20 {
["hash"] = "e91a853ea4e0b372b26f82a616b87eb645b0aff3",
["snaks"] = table#21 {
["P248"] = table#22 {
table#23 {
["datatype"] = "wikibase-item",
["datavalue"] = table#24 {
["type"] = "wikibase-entityid",
["value"] = table#25 {
["entity-type"] = "item",
["id"] = "Q14527788",
["numeric-id"] = 14527788,
},
},
["property"] = "P248",
["snaktype"] = "value",
},
},
},
["snaks-order"] = table#26 {
"P248",
},
},
},
["type"] = "statement",
},
table#27 {
["id"] = "Q76$7ba7f268-4c19-b92f-7254-f8ed65aed53f",
["mainsnak"] = table#28 {
["datatype"] = "wikibase-item",
["datavalue"] = table#29 {
["type"] = "wikibase-entityid",
["value"] = table#30 {
["entity-type"] = "item",
["id"] = "Q18094",
["numeric-id"] = 18094,
},
},
["property"] = "P19",
["snaktype"] = "value",
},
["rank"] = "normal",
["references"] = table#31 {
table#32 {
["hash"] = "207f35a0ea83b330f87438c914b0ab24558d2868",
["snaks"] = table#33 {
["P227"] = table#34 {
table#35 {
["datatype"] = "external-id",
["datavalue"] = table#36 {
["type"] = "string",
["value"] = "132522136",
},
["property"] = "P227",
["snaktype"] = "value",
},
},
["P248"] = table#37 {
table#38 {
["datatype"] = "wikibase-item",
["datavalue"] = table#39 {
["type"] = "wikibase-entityid",
["value"] = table#40 {
["entity-type"] = "item",
["id"] = "Q36578",
["numeric-id"] = 36578,
},
},
["property"] = "P248",
["snaktype"] = "value",
},
},
["P407"] = table#41 {
table#42 {
["datatype"] = "wikibase-item",
["datavalue"] = table#43 {
["type"] = "wikibase-entityid",
["value"] = table#44 {
["entity-type"] = "item",
["id"] = "Q188",
["numeric-id"] = 188,
},
},
["property"] = "P407",
["snaktype"] = "value",
},
},
["P813"] = table#45 {
table#46 {
["datatype"] = "time",
["datavalue"] = table#47 {
["type"] = "time",
["value"] = table#48 {
["after"] = 0,
["before"] = 0,
["calendarmodel"] = "http://www.wikidata.org/entity/Q1985727",
["precision"] = 11,
["time"] = "+2021-06-06T00:00:00Z",
["timezone"] = 0,
},
},
["property"] = "P813",
["snaktype"] = "value",
},
},
},
["snaks-order"] = table#49 {
"P248",
"P227",
"P407",
"P813",
},
},
},
["type"] = "statement",
},
}
- مثال موسع:
{{#invoke:Wikidata2{{#تبديل:{{SUBPAGENAME}}|ملعب=/ملعب}} |Dump|claims|P1791|1|references|1|snaks|P244|1|datavalue|value}}
local p = {}
local function isvalid(x)
if x and x ~= "" and x ~= "لا" then return x end
return nil
end
local function isntvalid(x)
if not x or x == "" or x == nil then return true end
return false
end
local function getEntityFromId(id)
return isvalid(id) and mw.wikibase.getEntity(id) or mw.wikibase.getEntity()
end
function p.Subclass(options)
if options then
Frame_args = options
end
local parent = options.parent or ""
local id = options.id or ""
local Entity = getEntityFromId(id)
if Entity then
id = Entity.id
end
local property = options.property or "P31"
if isntvalid(parent) or isntvalid(id) or isntvalid(property) then
return false
end
local tab = mw.text.split(options.parent, ",")
local result = mw.wikibase.getReferencedEntityId(id, property, tab) -- { "Q5", "Q2095" } )
if result == nil and property == "P31" then
result = mw.wikibase.getReferencedEntityId(id, "P279", tab)
end
if result then
return true
end
end
function p.isSubclass(frame)
return p.Subclass(frame.args)
end
function p.ViewSomething(frame) -- from en:Module:Wikidata
local f = (frame.args[1] or frame.args.id) and frame or frame:getParent()
local aa
if isvalid(f.args.id) then
aa = f.args.id
end
local data = mw.wikibase.getEntity(aa)
if data == nil then
return nil
end
local i = 1
while true do
local index = f.args[i]
if index == nil then
if type(data) == "table" then
return mw.text.jsonEncode(data, mw.text.JSON_PRESERVE_KEYS + mw.text.JSON_PRETTY)
else
return tostring(data)
end
end
data = data[index] or data[tonumber(index)]
if data == nil then
return
end
i = i + 1
end
end
function p.Dump(frame)
local warnDump = "[[تصنيف:Called function 'Dump' from module Wikidata]]"
local f = (frame.args[1] or frame.args.id) and frame or frame:getParent()
local aa
if isvalid(f.args.id) then
aa = f.args.id
end
local data = mw.wikibase.getEntity(aa)
if data == nil then
return warnDump
end
local i = 1
while true do
local index = f.args[i]
if index == nil then
return frame:extensionTag("source", mw.dumpObject(data), { lang = "lua" }) .. warnDump
end
data = data[index] or data[tonumber(index)]
if data == nil then
return warnDump
end
i = i + 1
end
end
return p