Module:fi-dialects/helper
Jump to navigation
Jump to search
- The following documentation is located at Module:fi-dialects/helper/documentation. [edit]
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox
Implements utility functions for Finnish dialectal data modules.
add_word_for
[edit]add_word_for(syns, word, parishes)
- Adds the given
word
tosyns
, as returned by dialectal data modules, for all of the given parishes.parishes
may be a table or a comma-separated list of parishes as a string.
local export = {}
local function add_word(syns, parish, word)
if not syns[parish] then
syns[parish] = word
elseif type(syns[parish]) == "string" then
syns[parish] = { syns[parish], word }
else
table.insert(syns[parish], word)
end
end
function export.add_word_for(syns, word, parishes)
if type(parishes) == "string" then
for parish in mw.text.gsplit(parishes, ",") do
add_word(syns, mw.ustring.gsub(mw.text.trim(parish), "[ .]", ""), word)
end
else
for _, parish in ipairs(parishes) do
add_word(syns, parish, word)
end
end
end
return export