10,794
edits
TheNightAvl (talk | contribs) mNo edit summary |
TheNightAvl (talk | contribs) mNo edit summary |
||
Line 108: | Line 108: | ||
function append_IPA (working_IPA) | function append_IPA (working_IPA) | ||
local IPA_size = #IPA --This variable needs to be set before the function or it breaks. | local IPA_size = #IPA --This variable needs to be set before the function or it breaks. | ||
mw.log("————— REGISTERING PHONE —————") | -- generate_IPA: mw.log("————— REGISTERING PHONE —————") | ||
if IPA_size > 0 then | if IPA_size > 0 then | ||
for i=1, IPA_size do | for i=1, IPA_size do | ||
Line 115: | Line 115: | ||
end | end | ||
IPA[1] = working_IPA | IPA[1] = working_IPA | ||
mw.log("[" .. working_IPA .. "] registered.") | -- generate_IPA: mw.log("[" .. working_IPA .. "] registered.") | ||
mw.log("Current IPA: [" .. table.concat(IPA, "][") .. "]") | -- generate_IPA: mw.log("Current IPA: [" .. table.concat(IPA, "][") .. "]") | ||
end | end | ||
function generate_IPA(word) | function generate_IPA(word) | ||
Line 140: | Line 138: | ||
local i_iteration = -2 | local i_iteration = -2 | ||
mw.log("=========================\nCURRENT TEST STRING: <".. mw.ustring.upper(s) .. ">") | -- generate_IPA: mw.log("=========================\nCURRENT TEST STRING: <".. mw.ustring.upper(s) .. ">") | ||
if s_len < 3 then | if s_len < 3 then | ||
Line 147: | Line 145: | ||
for i = i_iteration, 0 do | for i = i_iteration, 0 do | ||
mw.log("————— <" .. split_s[s_len + i] .. "> selected. (i = " .. i .. ") —————") | -- generate_IPA: mw.log("————— <" .. split_s[s_len + i] .. "> selected. (i = " .. i .. ") —————") | ||
getData = data[split_s[s_len + i]] | getData = data[split_s[s_len + i]] | ||
local deadEnd = false | local deadEnd = false | ||
Line 158: | Line 156: | ||
if i == 0 then | if i == 0 then | ||
if getData[false] then | if getData[false] then | ||
mw.log("Singular index recognised.") | -- generate_IPA: mw.log("Singular index recognised.") | ||
getData = getData[false] | getData = getData[false] | ||
mw.log("Index acquired: " .. getData) | -- generate_IPA: mw.log("Index acquired: " .. getData) | ||
else | else | ||
error(split_s[s_len] .. " is an invalid character.") | error(split_s[s_len] .. " is an invalid character.") | ||
end | end | ||
else | else | ||
mw.log("Tabular index recognised.") | -- generate_IPA: mw.log("Tabular index recognised.") | ||
for j = 1, 0 - i do | for j = 1, 0 - i do | ||
-- DEBUG PRINT ONLY | -- DEBUG PRINT ONLY | ||
Line 175: | Line 173: | ||
end | end | ||
-- END OF DEBUG PRINT | -- END OF DEBUG PRINT | ||
mw.log("Testing " .. currentCombo) | -- generate_IPA: mw.log("Testing " .. currentCombo) | ||
if getData[split_s[s_len + i + j]] then | if getData[split_s[s_len + i + j]] then | ||
getData = getData[split_s[s_len + i + j]] | getData = getData[split_s[s_len + i + j]] | ||
mw.log("Combination recognised: " .. currentCombo .. " (j = " .. j .. ")") | -- generate_IPA: mw.log("Combination recognised: " .. currentCombo .. " (j = " .. j .. ")") | ||
if type(getData) == "string" then | if type(getData) == "string" then | ||
if j + i == 0 then | if j + i == 0 then | ||
mw.log("Index acquired: " .. getData) | -- generate_IPA: mw.log("Index acquired: " .. getData) | ||
multiMatch = true | multiMatch = true | ||
break | break | ||
else | else | ||
mw.log('Non-final index: dead end.') | -- generate_IPA: mw.log('Non-final index: dead end.') | ||
getData = {} | getData = {} | ||
deadEnd = true | deadEnd = true | ||
Line 194: | Line 192: | ||
elseif j + i == 0 and getData[false] then | elseif j + i == 0 and getData[false] then | ||
getData = getData[false] | getData = getData[false] | ||
mw.log("Index acquired: " .. getData) | -- generate_IPA: mw.log("Index acquired: " .. getData) | ||
multiMatch = true | multiMatch = true | ||
break | break | ||
Line 200: | Line 198: | ||
error("data[" .. table.concat(getData, "][") .. "][false] is missing." ) | error("data[" .. table.concat(getData, "][") .. "][false] is missing." ) | ||
else | else | ||
mw.log("Target still tabular: reiterating.") | -- generate_IPA: mw.log("Target still tabular: reiterating.") | ||
end | end | ||
else | else | ||
mw.log('Dead end.') | -- generate_IPA: mw.log('Dead end.') | ||
getData = {} | getData = {} | ||
deadEnd = true | deadEnd = true | ||
Line 213: | Line 211: | ||
end | end | ||
if type(getData) == "string" and (i == 0 or multiMatch == true) then | if type(getData) == "string" and (i == 0 or multiMatch == true) then | ||
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) | append_IPA(getData) | ||
s = mw.ustring.sub(s, 1, s_len + i - 1) | s = mw.ustring.sub(s, 1, s_len + i - 1) | ||
Line 219: | Line 217: | ||
break | break | ||
elseif deadEnd == false then | elseif deadEnd == false then | ||
mw.log('Non-final index: dead end.') | -- generate_IPA: mw.log('Non-final index: dead end.') | ||
end | end | ||
end | end | ||
end | end | ||
mw.log('————— STRING EXHAUSTED —————') | -- generate_IPA: mw.log('————— STRING EXHAUSTED —————') | ||
return | return IPA | ||
end | end | ||
function export.generate(frame) | function export.generate(frame) | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
local baseGen = generate_IPA(args[1]) | |||
local outputIPA = table.concat(baseGen,"][") | |||
return "[" .. outputIPA .. "]" | |||
end | end | ||
return export | return export |