Module:rad-IPA: Difference between revisions

Jump to navigation Jump to search
m
Optimisation
(Added u resolution function.)
m (Optimisation)
Line 1: Line 1:
local export = {}
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local export = {}


local data = {
local data = {
Line 37: Line 37:
["e"] = {
["e"] = {
["a"] = "ia",
["a"] = "ia",
["j"] = "iːj",
[false] = "ie",
[false] = "ie",
},
},
Line 74: Line 75:
["o"] = {
["o"] = {
["a"] = "ua",
["a"] = "ua",
["j"] = "uːj",
[false] = "uo",
[false] = "uo",
},
},
Line 101: Line 103:
data["ò"] = data["o"]
data["ò"] = data["o"]
data["y"] = data["i"]
data["y"] = data["i"]
data["y"]["e"]["j"] = "yːj"
data["ý"] = data["í"]
data["ý"] = data["í"]
data["ỷ"] = data["ỉ"]
data["ỷ"] = data["ỉ"]
data[","] = data["."]
data[","] = data["."]
data["!"] = data["."]
data["!"] = data["."]
Line 116: Line 120:
["ʃ"] = true, ["t"] = true, ["u"] = true, ["uː"] = true, ["uːː"] = true, ["uːo"] = true, ["ua"] = true,
["ʃ"] = true, ["t"] = true, ["u"] = true, ["uː"] = true, ["uːː"] = true, ["uːo"] = true, ["ua"] = true,
["uo"] = true, ["v"] = true, ["w"] = true, ["y"] = true, ["z"] = true, ["ʒ"] = true, ["θ"] = true,
["uo"] = true, ["v"] = true, ["w"] = true, ["y"] = true, ["z"] = true, ["ʒ"] = true, ["θ"] = true,
-- Temporary phones --
["iːj"] = true, ["uːj"] = true, ["yːj"] = true,
}
}


Line 133: Line 141:
["ɔi"] = true, ["u"] = true, ["uː"] = true, ["uːː"] = true, ["uːo"] = true, ["ua"] = true,
["ɔi"] = true, ["u"] = true, ["uː"] = true, ["uːː"] = true, ["uːo"] = true, ["ua"] = true,
["uo"] = true,  
["uo"] = true,  
-- Temporary phones --
["iːj"] = true, ["uːj"] = true, ["yːj"] = true,
}
}


Line 145: Line 157:
local IPA = {}
local IPA = {}


function append_IPA(working_IPA)
-- PROCESS FUNCTIONS --
local IPA_size = #IPA --This variable needs to be set before the function or it breaks.
-- generate_IPA: mw.log("————— REGISTERING PHONE —————")
if IPA_size > 0 then
for i=1, IPA_size do
IPA[IPA_size - i + 2] = IPA[IPA_size - i + 1]
end
end
IPA[1] = working_IPA
-- generate_IPA: mw.log("[" .. working_IPA .. "] registered.")
-- generate_IPA: mw.log("Current IPA: [" .. table.concat(IPA, "][") .. "]")
end


function generate_IPA(word)
function generate_IPA(word)
Line 253: Line 254:
  if type(getData) == "string" and (i == 0 or multiMatch == true) then
  if type(getData) == "string" and (i == 0 or multiMatch == true) then
  -- generate_IPA: mw.log("Target acquired of length " .. 1 - i .. ", converting to [" .. getData .. "].")
  -- generate_IPA: mw.log("Target acquired of length " .. 1 - i .. ", converting to [" .. getData .. "].")
  append_IPA(getData)
  table.insert(IPA, 1, getData)
  s = mw.ustring.sub(s, 1, s_len + i - 1)
  s = mw.ustring.sub(s, 1, s_len + i - 1)
  s_len = mw.ustring.len(s)
  s_len = mw.ustring.len(s)
Line 315: Line 316:
function export.generate(frame)
function export.generate(frame)
local args = getArgs(frame)
local args = getArgs(frame)
local baseGen = generate_IPA(args[1])
local outputIPA = generate_IPA(args[1])
local outputIPA = resolve_u(baseGen)
outputIPA = resolve_u(outputIPA)
outputIPA = table.concat(outputIPA,"][")
outputIPA = table.concat(outputIPA,"][")

Navigation menu