Module:snon-mut: Difference between revisions

From Linguifex
Jump to navigation Jump to search
No edit summary
No edit summary
 
(13 intermediate revisions by 2 users not shown)
Line 11: Line 11:


local export = {}
local export = {}
local function repl(forms, param)
if param ~= "normal" and forms[param] == forms["normal"] then
return "''not applicable''"
end
local ret = m_links.full_link({lang = lang, term = forms[param]})
return ret
end


function export.mutations(ret, args)
function export.mutations(ret, args)
Line 35: Line 25:
ret.lenition = ret.radical:gsub("^(.)", "%1h")
ret.lenition = ret.radical:gsub("^(.)", "%1h")
elseif match(first_letter, vowels) then -- h-prothesis
elseif match(first_letter, vowels) then -- h-prothesis
ret.lenition = "h'" .. ret.radical
ret.lenition = "h'" .. lower_radical
apostrophe = true
apostrophe = true
elseif match(lower_radical, "^ghi" .. vowels) then
elseif match(lower_radical, "^ghi" .. vowels) then
Line 53: Line 43:
ret.eclipsis = eclipsis_prefixes[first_letter] .. sub(lower_radical, 2, -1)
ret.eclipsis = eclipsis_prefixes[first_letter] .. sub(lower_radical, 2, -1)
elseif match(first_letter, vowels) then
elseif match(first_letter, vowels) then
ret.eclipsis = "n'" .. ret.eclipsis
ret.eclipsis = "n'" .. lower_radical
apostrophe = true
apostrophe = true
elseif match(lower_radical, "^ghi" .. vowels) then
elseif match(lower_radical, "^ghi" .. vowels) then
Line 63: Line 53:
if is_proper then
if is_proper then
if apostrophe then
if apostrophe then
ret.eclipsis = ret.eclipsis:gsub("^n'(%w)", upper):gsub("'","")
ret.eclipsis = "n" .. gsub(ret.eclipsis, "^n'(%w)", upper)
ret.lenition = ret.lenition:gsub("^h'(%w)", upper):gsub("'","")
ret.lenition = "h" .. gsub(ret.lenition, "^h'(%w)", upper)
else
else
ret.eclipsis = ret.eclipsis:gsub("^(%w)", upper)
ret.eclipsis = gsub(ret.eclipsis, "^(%w)", upper)
ret.lenition = ret.lenition:gsub("^(%w)", upper)
ret.lenition = gsub(ret.lenition, "^(%w)", upper)
end
end
end
end
return ret
return ret, apostrophe
end
end


Line 77: Line 67:
local params = {
local params = {
[1] = {alias_of = "word"},
[1] = {default = PAGENAME, template_default = "bèdh"},
["ecl"] = {},
["ecl"] = {},
["len"] = {},
["len"] = {},
["word"] = {default = PAGENAME, template_default = "bèdh"}
}
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local args = require("Module:parameters").process(frame:getParent().args, params)
local is_vowel
local ret = {radical = args[1]}
local ret = {radical = args[1]}
ret = export.mutations(ret, args)
ret, is_vowel = export.mutations(ret, args)
local links = {}
local links = {}
for k, v in pairs(ret) do
for k, v in pairs(ret) do
links[k] = m_l.full_link{lang = lang, term = v}
if v == "-" then
links[k] = "''not applicable''"
else
links[k] = m_l.full_link{lang = lang, term = v}
end
end
end
local table_args = {
local table_args = {
palette = "blue",
palette = "blue",
notes = "Certain mutated forms of some words can never occur in standard Modern Scots Norse.<br>All possible mutated forms are displayed for convenience.",
notes = "<p style=font-size:85%;>''Note:'' Certain mutated forms of some words can never occur in standard Scots Norse.<br>All possible mutated forms are displayed for convenience.</p>",
title = "[[Scots Norse#Mutation|Mutated forms]] of " .. ret.radical
title = "[[Scots Norse#Mutation|Mutated forms]] of " .. ret.radical,
-- class = "wide",
}
}
local contents = [=[
local contents = [[
! radical !! lenition !! eclipsis
|-
! radical !! ]] .. (is_vowel and "h-prothesis" or "lenition") .. [[ !! eclipsis
|-
| {radical} || {lenition} || {eclipsis}
| {radical} || {lenition} || {eclipsis}
]=]
]]
contents = require('Module:string utilities').format(contents, links)
contents = require('Module:string utilities').format(contents, links)

Latest revision as of 19:24, 4 May 2026



local gsub = mw.ustring.gsub
local match = mw.ustring.match
local gmatch = mw.ustring.gmatch
local sub = mw.ustring.sub
local upper = mw.ustring.upper

local m_l = require("Module:links")

local lang = require("Module:languages").getByCode("snon")
local PAGENAME = mw.loadData("Module:headword/data").pagename

local export = {}

function export.mutations(ret, args)
	local lower_radical = mw.ustring.lower(ret.radical or args.word)
	local first_letter = match(lower_radical, "^%W*(%w)")
	local is_proper = ret.radical ~= lower_radical
	
	local vowels = "([aeiouàèìòù])"
	local apostrophe
	
	if args.len then
		ret.lenition = args.len
	elseif match(first_letter, "[bcdfgmptsnlrv]") then
		ret.lenition = ret.radical:gsub("^(.)", "%1h")
	elseif match(first_letter, vowels) then -- h-prothesis
		ret.lenition = "h'" .. lower_radical
		apostrophe = true
	elseif match(lower_radical, "^ghi" .. vowels) then
		ret.lenition = gsub(lower_radical, "^ghi" .. vowels, "chi%1")
	else
		ret.lenition = "-"
	end
	
	local eclipsis_prefixes = {
		["b"] = "m", ["c"] = "g", ["d"] = "n", ["f"] = "v", ["g"] = "n",
		["p"] = "b", ["t"] = "d", ["h"] = "g", ["s"] = "z", ["v"] = "b",
	}
	
	if args.ecl then
		ret.eclipsis = args.ecl
	elseif eclipsis_prefixes[first_letter] then
		ret.eclipsis = eclipsis_prefixes[first_letter] .. sub(lower_radical, 2, -1)
	elseif match(first_letter, vowels) then
		ret.eclipsis = "n'" .. lower_radical
		apostrophe = true
	elseif match(lower_radical, "^ghi" .. vowels) then
		ret.eclipsis = gsub(lower_radical, "^ghi" .. vowels, "ni%1")
	else
		ret.eclipsis = "-"
	end
	
	if is_proper then
		if apostrophe then
			ret.eclipsis = "n" .. gsub(ret.eclipsis, "^n'(%w)", upper)
			ret.lenition = "h" .. gsub(ret.lenition, "^h'(%w)", upper)
		else
			ret.eclipsis = gsub(ret.eclipsis, "^(%w)", upper)
			ret.lenition = gsub(ret.lenition, "^(%w)", upper)
		end
	end
	
	return ret, apostrophe
end

function export.mutation_table(frame)
	
	local params = {
		[1] = {default = PAGENAME, template_default = "bèdh"},
		["ecl"] = {},
		["len"] = {},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local is_vowel
	local ret = {radical = args[1]}
	ret, is_vowel = export.mutations(ret, args)
	
	local links = {}
	for k, v in pairs(ret) do
		if v == "-" then
			links[k] = "''not applicable''"
		else
			links[k] = m_l.full_link{lang = lang, term = v}
		end
	end
	
	local table_args = {
		palette = "blue",
		notes = "<p style=font-size:85%;>''Note:'' Certain mutated forms of some words can never occur in standard Scots Norse.<br>All possible mutated forms are displayed for convenience.</p>",
		title = "[[Scots Norse#Mutation|Mutated forms]] of " .. ret.radical,
	--	class = "wide",
	}
	
	local contents = [[
	|-
	! radical !! ]] .. (is_vowel and "h-prothesis" or "lenition") .. [[ !! eclipsis
	|-
	| {radical} || {lenition} || {eclipsis}
	]]
	contents = require('Module:string utilities').format(contents, links)
	
	return require("Module:inflection table").inflection_table(frame, table_args, contents)
end

return export