This module holds some common used functions for Uyghur, that are needed by other modules.
local export = {}
local find = mw.ustring.find
local sub = mw.ustring.sub
local gsub = mw.ustring.gsub
local match = mw.ustring.match
local length = mw.ustring.len
local vowels = "اەېىوۇۆۈ"
local vowelsBack = "اوۇ"
local vowelsFront = "ەۆۈ"
-- local vowelsCentral = "ېى"
local consonBack = "خغق"
local consonFront = "كگ"
local consonJsiz = "پتچخسشفقكھغگبد"
function export.getLast(str)
local base, v, c = match(str, "(.*+)(+)(*)$")
return base, v, c
end
function export.checkTongue(str)
local isChe = find(str, "چە$")
if isChe then str = gsub(str, "چە$", "") end
local tongue = export.checkFrontBack(str)
if tongue then return tongue end
if isChe then return checkChe(str) end
return export.checkCentral(str)
end
function export.checkFrontBack(str)
local base, v = match(str, "(.+)(+)*$")
if v then
if find(v, "$") then return "back" end
if find(v, "$") then return "front" end
return export.checkFrontBack(base)
else
return nil
end
end
function export.checkCentral(str)
--exceptions
for k, data in pairs(require('Module:ug-common/data').tongue) do
if match(str, k) then return data end
end
if match(str,"") then return "back" end
if match(str,"") then return "front" end
return nil
end
function checkChe(str)
local ff = match(str,"(.-)")
if ff then return "back" else return "front" end
end
return export