Module:mg-spel: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(27 intermediate revisions by the same user not shown)
Line 1: Line 1:
local PAGENAME = mw.title.getCurrentTitle().text
local gsub = mw.ustring.gsub
local gsub = mw.ustring.gsub
local PAGENAME = gsub(mw.title.getCurrentTitle().text, "%s", " ")
local match = mw.ustring.match
local match = mw.ustring.match
local gmatch = mw.ustring.gmatch
local gmatch = mw.ustring.gmatch
Line 9: Line 9:


local export = {}
local export = {}
local function link(term)
return "[[Contionary:" .. term .. "|" .. term .. "]]"
end


function export.alter(frame)
function export.alter(frame)
local ret = {}; local qs = {}
local ret = {}; local qs = {}
local term = frame:getParent().args[1] or PAGENAME
local term = mw.title.getCurrentTitle().nsText == "Template" and "cosmaile" or frame:getParent().args[1] or PAGENAME
local e = term; local a = term; local c = term; local s = term
local e = term; local a = term; local c = term; local s = term
Line 18: Line 22:
-- Spanish
-- Spanish
e = e:gsub("il", "ll")
e = e:gsub("il(.)", "ll%1")
e = e:gsub("v", "b")
e = e:gsub("v", "b")
e = e:gsub("[gh]", "j")
e = e:gsub("([^c])[gh]", "%1j")
-- Asturian    
-- Asturian    
a = a:gsub("il", "ll")
a = a:gsub("il(.)", "ll%1")
a = a:gsub("v", "b")
a = a:gsub("v", "b")
-- Southern
-- Southern
s = s:gsub("ñ", "nh")
s = s:gsub("ñ", "nh")
s = s:gsub("il", "lh")
s = s:gsub("il(.)", "lh%1")
s = s:gsub("v", "b")
s = s:gsub("v", "b")
local lh = match(s, "lh")
local lh = match(s, "lh")
Line 35: Line 39:
c = c:gsub("c([aou])", "k%1")
c = c:gsub("c([aou])", "k%1")
c = c:gsub("qu([ei])", "k%1")
c = c:gsub("qu([ei])", "k%1")
c = c:gsub("ñ", "in")
c = c:gsub("([^i])ñ", "%1in")
c = c:gsub("x", "is")
c = c:gsub("([^i])x", "%1is")
-- disclaimer: awful approach below, your physical and mental integrity may be at risk
-- disclaimer: awful approach below, your physical and mental integrity may be at risk
Line 42: Line 46:
if e == a and a == s then
if e == a and a == s then
qs = {"Spanish", "Asturian", "Southern"}
qs = {"Spanish", "Asturian", "Southern"}
table.insert(ret, "* " .. m_l.full_link({term = e, lang = lang}) .. " " .. m_q.format_qualifier(qs) .. "\n")
if e ~= term then table.insert(ret, "* " .. link(e) .. " " .. m_q.format_qualifier(qs) .. "\n") end
elseif e == a then
elseif e == a then
table.insert(qs, "Spanish")
table.insert(qs, "Spanish")
table.insert(qs, "Asturian")
table.insert(qs, "Asturian")
table.insert(ret, "* " .. m_l.full_link({term = e, lang = lang}) .. " " .. m_q.format_qualifier(qs) .. "\n")
if e ~= term then table.insert(ret, "* " .. link(e) .. " " .. m_q.format_qualifier(qs) .. "\n") end
table.insert(ret, "* " .. m_l.full_link({term = s, lang = lang})
if s ~= term then table.insert(ret, "* " .. link(s) .. (lh and ", " .. link(s:gsub("lh", "j")) or "")
  .. (lh and ", " .. m_l.full_link({term = s:gsub("lh", "j"), lang = lang}) or "")
.. " " .. m_q.format_qualifier({"Southern"}) .. "\n") end
  .. " " .. m_q.format_qualifier({"Southern"}) .. "\n")
elseif e == s then
elseif e == s then
table.insert(qs, "Spanish")
table.insert(qs, "Spanish")
table.insert(qs, "Southern")
table.insert(qs, "Southern")
table.insert(ret, "* " .. m_l.full_link({term = e, lang = lang}) .. " " .. m_q.format_qualifier(qs) .. "\n")
if e ~= term then table.insert(ret, "* " .. link(e) .. " " .. m_q.format_qualifier(qs) .. "\n") end
table.insert(ret, "* " .. m_l.full_link({term = a, lang = lang}) .. " " .. m_q.format_qualifier({"Asturian"}) .. "\n")
if a ~= term then table.insert(ret, "* " .. link(a) .. " " .. m_q.format_qualifier({"Asturian"}) .. "\n") end
elseif a == s then
elseif a == s then
table.insert(qs, "Asturian")
table.insert(qs, "Asturian")
table.insert(qs, "Southern")
table.insert(qs, "Southern")
table.insert(ret, "* " .. m_l.full_link({term = a, lang = lang}) .. " " .. m_q.format_qualifier(qs) .. "\n")
if a ~= term then table.insert(ret, "* " .. link(a) .. " " .. m_q.format_qualifier(qs) .. "\n") end
table.insert(ret, "* " .. m_l.full_link({term = e, lang = lang}) .. " " .. m_q.format_qualifier({"Spanish"}) .. "\n")
if e ~= term then table.insert(ret, "* " .. link(e) .. " " .. m_q.format_qualifier({"Spanish"}) .. "\n") end
else
else
table.insert(ret, "* " .. m_l.full_link({term = e, lang = lang}) .. " " .. m_q.format_qualifier({"Spanish"}) .. "\n")
if e ~= term then table.insert(ret, "* " .. link(e) .. " " .. m_q.format_qualifier({"Spanish"}) .. "\n") end
table.insert(ret, "* " .. m_l.full_link({term = a, lang = lang}) .. " " .. m_q.format_qualifier({"Asturian"}) .. "\n")
if a ~= term then table.insert(ret, "* " .. link(a) .. " " .. m_q.format_qualifier({"Asturian"}) .. "\n") end
table.insert(ret, "* " .. m_l.full_link({term = s, lang = lang})
if s ~= term then table.insert(ret, "* " .. link(s) .. (lh and ", " .. link(s:gsub("lh", "j")) or "")
  .. (lh and ", " .. m_l.full_link({term = s:gsub("lh", "j"), lang = lang}) or "")
.. " " .. m_q.format_qualifier({"Southern"}) .. "\n") end
  .. " " .. m_q.format_qualifier({"Southern"}) .. "\n")
end
end
if c ~= term then
if c ~= term then
table.insert(ret, "* " .. m_l.full_link({term = c, lang = lang}) .. " " .. m_q.format_qualifier({"Celtic"}) .. "\n")
table.insert(ret, "* " .. link(c) .. " " .. m_q.format_qualifier({"Celtic"}) .. "\n")
end
end
table.insert(ret, 1, "===Alternative forms===")
table.insert(ret, 2, "\n")
if e == term and a == term and c == term and s == term then
if e == term and a == term and c == term and s == term then
error('Delete me')
ret = {"aa", "aa"}
end
end
Line 81: Line 86:
function export.mutate(frame)
function export.mutate(frame)
local term = frame:getParent().args[1] or PAGENAME
local term = mw.title.getCurrentTitle().nsText == "Template" and "bea" or frame:getParent().args[1] or PAGENAME
local unchanged = "''unchanged''"
local unchanged = "''unchanged''"
local uc = match(term, "[A-Z]")
term = mw.ustring.lower(term)
local spat = {["p"] = "b", ["b"] = "v", ["t"] = "d", ["d"] = "z", ["c"] = "g", ["q"] = "g", ["g"] = "h"}
local soft = {
local npat = {["m"] = "v", ["b"] = "m", ["d"] = "n", ["g"] = "k"}
["p"] = "b", ["b"] = "v", ["d"] = "z", ["t"] = "d", ["g"] = "h", ["c"] = "g", ["q"] = "g",  
["P"] = "B", ["B"] = "V", ["D"] = "Z", ["T"] = "D", ["G"] = "H", ["C"] = "G", ["Q"] = "G",
}
local nasal = {
["m"] = "v", ["b"] = "m", ["d"] = "n", ["g"] = "k",
["M"] = "V", ["B"] = "M", ["D"] = "N", ["G"] = "K"
}
local function aw(term, mutation)
local function aw(term, mutation)
local mutated = nil
local mutated = ""
for regex, repl in pairs(mutation == "nasal" and npat or spat) do
for regex, repl in pairs(mutation) do
mutated = gsub(term, "^" .. regex, repl, 1)
mutated = gsub(term, "^" .. regex, repl, 1)
mutated = gsub(mutated, "^k(.)", function(foo) return match(foo, "[aou]") and "c" or "qu" end)
mutated = gsub(mutated, "^k(.)", function(foo) return (match(foo, "[aou]") and "c" or "qu") .. foo end)
if mutated ~= word then return mutated end
if mutated ~= term then return mutated end
end
end
mutated = gsub(mutated, "^k(.)", function(foo) return match(foo, "[aou]") and "c" or "qu" end)
return not mutated and unchanged
return unchanged
end
end
local function link(term, uc)
local function link(term)
local links = {}
local links = {}
for alt in gmatch(term, "([^%s,]+)") do
for alt in gmatch(term, "([^%s,]+)") do
if uc then alt = gsub(alt, "^(.)", mw.ustring.upper("%1")) end
if alt == unchanged then return unchanged end
alt = "[[Contionary:" .. alt .. "|" .. alt .. "]]"
alt = "[[Contionary:" .. alt .. "|" .. alt .. "]]"
table.insert(links, alt)
table.insert(links, alt)
Line 120: Line 128:
! Radical
! Radical
! Soft
! Soft
! Hard
! Nasal
|-
|-
| ]=] .. link(term, uc) .. [=[​
| ]=] .. link(term, uc) .. [=[​
| ]=] .. link(aw(term, "soft"), uc) .. [=[​
| ]=] .. link(aw(term, soft)) .. [=[​
| ]=] .. link(aw(term, "nasal"), uc) .. [=[​
| ]=] .. link(aw(term, nasal)) .. [=[​
|-
|-
| colspan=3 style="font-size: 89%; text-align: left;" | <div class="dummy-footnote" style="font-size: 90%; margin-bottom: 0.5em; margin-left: 2em;">1.&#32;<span style="color: #002bb8;">^</span>&#32;<span class="citation">Christian Evans, (2021). <span class="plainlinks">[https://drive.google.com/file/d/1AIZ_FwLek3nKrYsbE9sZxTZmi_pwf7DR “Mutation in Modern Gallaecian”]</span>, ''Segments'' (01-07), April 2021.</span></div>
| colspan=3 style="font-size: 89%; text-align: left;" | <div class="dummy-footnote" style="font-size: 90%; margin-bottom: 0.5em; margin-left: 2em;">1.&#32;<span style="color: #002bb8;">^</span>&#32;<span class="citation">Christian Evans, (2021). <span title="See link">[[Template:mg-mut/doc#References|“Mutation in Modern Gallaecian”]]</span>, ''Segments'' (01-07), April 2021.</span></div>
|}
|}]=]
]=]
return wikicode
return wikicode