Module:rad-syllables: Difference between revisions

m
Added divider option
(Created page with "local export = {} local getArgs = require('Module:Arguments').getArgs -- DATA -- local grapheme = { ["a"] = true, ["á"] = true, ["à"] = true, ["â"] = true, ["ả"] = true, ["ai"] = true, ["âi"] = true, ["ao"] = true, ["ào"] = true, ["aoi"] = true, ["au"] = true, ["b"] = true, ["c"] = true, ["d"] = true, ["ð"] = true, ["dx"] = true, ["dz"] = true, ["e"] = true, ["é"] = true, ["è"] = true, ["ea"] = true, ["ei"] = true, ["f"] = true, ["g"] = true, ["h"] = true, [...")
 
m (Added divider option)
Line 123: Line 123:
end
end


function syllabify(graphemes)
function syllabify(graphemes, divider)
mw.log("————— SYLLABIFYING —————")
mw.log("————— SYLLABIFYING —————")
Line 239: Line 239:
else break
else break
end
end
end
if divider == nil then
divider = "|"
end
end


graphemes = table.concat(graphemes)
graphemes = table.concat(graphemes)
graphemes = mw.ustring.gsub(graphemes, "(σ)", "|")
graphemes = mw.ustring.gsub(graphemes, "(σ)", divider)
return graphemes
return graphemes
Line 257: Line 261:
local outputSyllables = args[1]
local outputSyllables = args[1]
local parameters = {}
local p = 2
mw.log("——— Parameters ———")
while args[p] do
parameters[args[p]] = true
mw.log(args[p] .. " = true")
p = p + 1
end
outputSyllables = graphemise(outputSyllables)
outputSyllables = graphemise(outputSyllables)
outputSyllables = syllabify(outputSyllables)
outputSyllables = syllabify(outputSyllables, args[2])


return outputSyllables
return outputSyllables