添加837字节
、 2020年12月31日 (四) 16:16
p = {}
function p.keys_to_table(set)
local res = {}
for k, v in ipairs(set) do
table.insert(set, k)
end
return res
end
function p.query_inherited_property(anchor_property, query_property, parent_list)
local results = {}
for idx, parent in ipairs(parent_list) do
local anchor_query = "[["..anchor_property.."::"..parent.."]]"
local property_query = "[[" .. query_property .. "::+]]"
local content_query = "?"..query_property
local query = anchor_query .. property_query .. "|" ..content_query .. "|format=plainlist"
local res = mw.smw.getQueryResult(query)
for j, r in ipairs(res.results) do
for k, t in ipairs(r.printouts[query_property]) do
results[t] = true
end
end
end
return results
end
return p