Module:User:Oyunqi/ug-common2
- This module sandbox lacks a documentation subpage. You may create it.
- Useful links: root page • root page’s subpages • links • transclusions • testcases • user page • user talk page • userspace
This is a private module sandbox of Oyunqi, for their own experimentation. Items in this module may be added and removed at Oyunqi's discretion; do not rely on this module's stability.
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 cnt = 1
local base, v, c = match(str, "(.*[^" .. vowels .. "]+)([" .. vowels .. "]+)([^" .. vowels .. "]*)$")
if find(base,"[" .. vowels .. "]+") then cnt = 2 end
return base, v, c, cnt
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, "(.+)([" .. vowels .. "]+)[^" .. vowels .. "]*$")
if v then
if find(v, "[" .. vowelsBack .. "]$") then return "back" end
if find(v, "[" .. vowelsFront .. "]$") then return "front" end
return export.checkFrontBack(base)
else
return nil
end
end
function export.checkCentral(str)
--exceptions
--[[]
if match(str, "[تئ]ىز") or
match(str, "^[سك]ى[ر]$") or
match(str, "^[ت]ىل") or
match(str, "پىت$") or
match(str, "[چئ]ىش") then
return "back" end
if match(str, "^[ئب]-ىلىم$") or
match(str, "^[بس]ى[ز]$") then
return "front" end
--
if match(str, "^[^بس]ى[خز]$") then return "back" end
if match(str, "^[بس]ى[ز]$") then return "front" end
if match(str, "^[سك]ى[ر]$") then return "back" end
if match(str, "^[ئب]-ىلىم$") then return "front" end
if match(str, "^[چئ]ىش") then return "back" end
if match(str, "^[ت]ىل") then return "back" end
]]
for k, data in pairs(require('Module:ug-common/data').tongue) do
if match(str, k) then return data end
end
if match(str,"[" .. consonBack .. "]") then return "back" end
if match(str,"[" .. consonFront .. "]") then return "front" end
return nil
end
function checkChe(str)
local ff = match(str,"(.-)[" .. consonBack .. "]")
if ff then
return "back"
else
return "front"
end
end
return export