Module:snon-mut: Difference between revisions

Melinoë (talk | contribs)
No edit summary
Melinoë (talk | contribs)
No edit summary
 
(20 intermediate revisions by the same user not shown)
Line 10: Line 10:


local GRAVE = "\204\128"
local GRAVE = "\204\128"
local ACUTE = "\204\129"
local CIRC = "\204\130"
local DIAER = "\204\136"


local lang = require("Module:languages").getByCode("cy")
local lang = require("Module:languages").getByCode("snon")
local PAGENAME = mw.loadData("Module:headword/data").pagename
local PAGENAME = mw.loadData("Module:headword/data").pagename
local MARKER = "<sup>△</sup>"
local MARKER = "<sup>△</sup>"


local mutation_rules = {
local mutation_rules = {
["b"] = {"f", "m"},
["b"] = {"bb", "m", "bh"},
["bh"] = {"b", "m", "gh"},
["c"] = {"g", "ngh", "ch"},
["c"] = {"g", "ngh", "ch"},
["ch"] = true,
["ch"] = {"gh", "ngh", "h"},
["d"] = {"dd", "n"},
["d"] = {"dd", "n", "dh"},
["dd"] = true,
["dh"] = {"d", "n", "gh"},
["f"] = true,
["g"] = {"gg", "ng", "gh"},
["g"] = {"", "ng"},
["h"] = {"gh", "nh", "ch"},
["h"] = true,
["l"] = {"ll", "l", "lh"},
["j"] = true,
["m"] = {"m", "mm", "mh"},
["k"] = true,
["n"] = {"n", "nn", "nh"},
["l"] = true,
["ll"] = {"l"},
["m"] = {"f"},
["mh"] = true,
["n"] = true,
["p"] = {"b", "mh", "ph"},
["p"] = {"b", "mh", "ph"},
["ph"] = true,
["ph"] = {"bh", "mh", "h"},
["q"] = true,
["r"] = {"rr", "r", "rh"},
["r"] = true,
["s"] = {"z", "s","sh"},
["rh"] = {"r"},
["s"] = true,
["t"] = {"d", "nh", "th"},
["t"] = {"d", "nh", "th"},
["th"] = true,
["th"] = {"dh", "nh", "ch"},
["ts"] = true,
["tsi"] = {"j", colloquial = true}, -- TODO: add colloquial marker.
["v"] = true,
["x"] = true,
["z"] = true
}
}


Line 55: Line 41:
data.is_uppercase = term_lower ~= term
data.is_uppercase = term_lower ~= term
local normalized = toNFD(term_lower)
local normalized = toNFD(term_lower)
data.vowel = normalized:match("^[aeiouwy]") and true or false
data.vowel = normalized:match("^[aeiouøy]") and true or false
if data.vowel then
if data.vowel then
data.final = term_lower
data.final = term_lower
-- H-prothesis, unless initial "w" is a semivowel (followed by a vowel other than "y", or "y" with a diacritic).
data.mut1 = "gh-"
if not (normalized:match("^w[aeiouw]") or umatch(normalized, "^wy[" .. GRAVE .. ACUTE .. CIRC .. DIAER .. "]")) then
data.mut2 = "n-"
data.mut3 = "h"
data.mut3 = "ch-"
end
return data
return data
end
end
Line 85: Line 70:
end
end
data.colloquial = mut.colloquial
data.colloquial = mut.colloquial
end
if initial == "tsi" then
-- "i" in "tsi" is retained if:
-- followed by a consonant (e.g. "tsips" → "jips")
-- followed by a semivowel (e.g. "tsiwawa" → "jiwawa", but "*tsiŵawa" → "*jŵawa"); "i" and "w" are semivowels if followed by any vowel, due to the preceding "i".
-- it has a diacritic (e.g. "tsïars" → "jïars")
if not (final:match("^[aeiouwy]") and not final:match("^[iw][aeiouwy]")) then
final = "i" .. final
-- If "i" in "tsi" is not retained, the following vowel cannot have a diaeresis unless it's followed by a vowel.
elseif not umatch(final, "^[aeiouwy]" .. DIAER .. "[" .. GRAVE .. ACUTE .. CIRC .. "]?[aeiouwy]") then
final = final:gsub("^([aeiouwy])" .. DIAER, "%1") -- If there's no diaeresis, this does nothing.
end
end
end
Line 156: Line 128:
args = { title = '[[Appendix:Scots Norse mutations|Mutated forms]] of ' .. require("Module:links").full_link({lang = lang, alt = title}, 'term'), palette = 'green' } }
args = { title = '[[Appendix:Scots Norse mutations|Mutated forms]] of ' .. require("Module:links").full_link({lang = lang, alt = title}, 'term'), palette = 'green' } }
result = result .. '\n! [[radical]]'
result = result .. '\n! [[radical]]'
result = result .. '\n! [[soft mutation|soft]]'
result = result .. '\n! ' .. (data.vowel and 'gh-prothesis' or '[[soft mutation|voiced]]')
result = result .. '\n! [[nasal mutation|nasal]]'
result = result .. '\n! ' .. (data.vowel and 'n-prothesis' or '[[nasal mutation|nasal]]')
result = result .. '\n! ' .. (data.vowel and '[[h-prothesis]]' or '[[aspirate mutation|aspirate]]')
result = result .. '\n! ' .. (data.vowel and 'ch-prothesis' or '[[aspirate mutation|aspirate]]')
result = result .. '\n|-'
result = result .. '\n|-'
result = result .. '\n| ' .. require("Module:links").full_link({lang = lang, term = data.radical})
result = result .. '\n| ' .. require("Module:links").full_link({lang = lang, term = data.radical})