Used by {{R:ErtSz}}
.
local export = {}
local term_module, homonym_module = "Module:R:ErtSz/data", "Module:R:ErtSz/homonyms"
local base_path = "https://www.arcanum.com/hu/online-kiadvanyok/Lexikonok-a-"
.. "magyar-nyelv-ertelmezo-szotara-1BE8B/"
local function _sense_and_link(term, number, sense)
local code
if not number then
local single_match = require(term_module)(term)
if not single_match then
local homonyms = require(homonym_module)(term)
if not homonyms then
error("No data for " .. term .. " in [[" .. term_module
.. "]] or ]")
else
homonyms = require("Module:array")(homonyms)
local i = 0
error("Choose from one of the following homonyms and place its "
.. "number in the first parameter: "
.. homonyms
:map(function(homonym)
i = i + 1
return ""
end)
:concat(", "))
end
end
code = single_match
else
local homonyms = require(homonym_module)(term)
if not homonyms then
error("No data for " .. term .. " in [[".. homonym_module
.. "]]")
end
code = homonyms
if not code then
error("No homonym #" .. number .. " for " .. term
.. " in ]")
end
end
if code then
local link = ""
if sense then
return require("Module:qualifier").sense({sense}) .. " " .. link
else
return link
end
else
error("This should not happen")
end
end
function export.sense_and_link(frame)
local args = frame:getParent().args
local title = args.title and assert(mw.title.new(args.title)) or mw.title.getCurrentTitle()
-- Use args as number if it's composed of only ASCII digits.
local term, number
if args and args:find "^%d+$" then
number = tonumber(args)
else
term = args
if args then
number = tonumber(args)
if not number then
error("Parameter 2 should be a number if it is supplied")
end
end
end
local sense = args
if not term then
if title.nsText == "Template" then
return ""
else
term = title.text
end
end
return _sense_and_link(term, number, sense)
end
return export