Module:rad-syllables: Difference between revisions

Jump to navigation Jump to search
m
ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
mNo edit summary
mNo edit summary
Line 90: Line 90:


function graphemise(word)
function graphemise(word)
mw.log("————— GRAPHEMISING —————")
--mw.log("————— GRAPHEMISING —————")


local graphemes = {}
local graphemes = {}
Line 103: Line 103:
if irregular[check_string] then
if irregular[check_string] then
mw.log("Irregular spelling recognised: " .. orig_string)
--mw.log("Irregular spelling recognised: " .. orig_string)
local capitals = {}
local capitals = {}
Line 135: Line 135:
for j = 0, #irregular[check_string] - 1 do
for j = 0, #irregular[check_string] - 1 do
table.insert(graphemes, 1, irregular[check_string][#irregular[check_string] - j])
table.insert(graphemes, 1, irregular[check_string][#irregular[check_string] - j])
mw.log("<" .. irregular[check_string][#irregular[check_string] - j] .. "> logged.")
--mw.log("<" .. irregular[check_string][#irregular[check_string] - j] .. "> logged.")
end
end
word = mw.ustring.sub(word, 1, i - 1)
word = mw.ustring.sub(word, 1, i - 1)
Line 141: Line 141:
elseif grapheme[check_string] then
elseif grapheme[check_string] then
table.insert(graphemes, 1, orig_string)
table.insert(graphemes, 1, orig_string)
mw.log("<" .. orig_string .. "> logged.")
--mw.log("<" .. orig_string .. "> logged.")
word = mw.ustring.sub(word, 1, i - 1)
word = mw.ustring.sub(word, 1, i - 1)
break
break
elseif mw.ustring.len(check_string) == 1 then
elseif mw.ustring.len(check_string) == 1 then
table.insert(graphemes, 1, orig_string)
table.insert(graphemes, 1, orig_string)
mw.log("<" .. orig_string .. "> logged.")
--mw.log("<" .. orig_string .. "> logged.")
word = mw.ustring.sub(word, 1, i - 1)
word = mw.ustring.sub(word, 1, i - 1)
break
break
Line 155: Line 155:
end
end
mw.log("String exhausted.")
--mw.log("String exhausted.")


mw.log("<" .. table.concat(graphemes, "><") .. ">")
--mw.log("<" .. table.concat(graphemes, "><") .. ">")
return graphemes
return graphemes
end
end


function syllabify(graphemes)
function syllabify(graphemes)
mw.log("————— SYLLABIFYING —————")
--mw.log("————— SYLLABIFYING —————")
for _, g in ipairs(irregular_grapheme) do
for _, g in ipairs(irregular_grapheme) do
Line 172: Line 172:
local function swap(Pos1, Pos2)
local function swap(Pos1, Pos2)
mw.log(graphemes[Pos1] .. " ↔ " .. graphemes[Pos2] .. " at position " .. Pos1)
--mw.log(graphemes[Pos1] .. " ↔ " .. graphemes[Pos2] .. " at position " .. Pos1)
local temp = graphemes[Pos1]
local temp = graphemes[Pos1]
graphemes[Pos1] = graphemes[Pos2]
graphemes[Pos1] = graphemes[Pos2]
Line 186: Line 186:
if vowel[mw.ustring.lower(graphemes[i])] then
if vowel[mw.ustring.lower(graphemes[i])] then
table.insert(graphemes, i, "σ")
table.insert(graphemes, i, "σ")
mw.log("σ inserted in position " .. i)
--mw.log("σ inserted in position " .. i)
i = i + 2
i = i + 2
else
else

Navigation menu