Difference between revisions of "Module:Sandbox/RexxS/TA98"

From blackwiki
Jump to navigation Jump to search
blackwiki>RexxS
(see the props table)
blackwiki>RexxS
(need to extract individual values from formatted property)
Line 7: Line 7:
 
local props = ent:formatPropertyValues('P1323')
 
local props = ent:formatPropertyValues('P1323')
 
local out = {}
 
local out = {}
 +
local t = {}
 
for k, v in pairs(props) do
 
for k, v in pairs(props) do
-- if k == 'value' then
+
if k == 'value' then
out[#out + 1] = "k = " .. k .. " --- v = " .. v
+
t = mw.text.split( v, ", ")
-- end
+
for k2, v2 in pairs(t) do
 +
out[#out + 1] = "[http://www.unifr.ch/ifaa/Public/EntryPage/TA98%20Tree/Entity%20TA98%20EN/" .. string.sub(v2, 2) .. "%20Entity%20TA98%20EN.htm " .. v2 .. "]"
 +
end
 +
end
 
end
 
end
 
ret = table.concat(out, "<br> ")
 
ret = table.concat(out, "<br> ")

Revision as of 23:08, 21 September 2014

Usage

{{#invoke:Sandbox/RexxS|getTAValue}}

This is used to get the TA98 (Terminologia Anatomica first edition 1998) values (property P1323) - example: 'A01.1.00.005'

These are then linked to the corresponding urls - example: http://www.unifr.ch/ifaa/Public/EntryPage/TA98%20Tree/Entity%20TA98%20EN/01.1.00.005%20Entity%20TA98%20EN.htm

This is a test module, now incorporated into Module:Wikidata



local p = {}

-- This is used to get the TA98 (Terminologia Anatomica first edition 1998) values like 'A01.1.00.005' (property P1323)
-- which are then linked to http://www.unifr.ch/ifaa/Public/EntryPage/TA98%20Tree/Entity%20TA98%20EN/01.1.00.005%20Entity%20TA98%20EN.htm
p.getTAValue = function(frame)
	local ent = mw.wikibase.getEntityObject()
	local props = ent:formatPropertyValues('P1323')
	local out = {}
	local t = {}
	for k, v in pairs(props) do
		if k == 'value' then
			t = mw.text.split( v, ", ")
			for k2, v2 in pairs(t) do
				out[#out + 1] = "[http://www.unifr.ch/ifaa/Public/EntryPage/TA98%20Tree/Entity%20TA98%20EN/" .. string.sub(v2, 2) .. "%20Entity%20TA98%20EN.htm " .. v2 .. "]"
			end
		end
	end
	ret = table.concat(out, "<br> ")
	if #ret == 0 then
		ret = "Invalid TA"
	end
	return ret
end

return p