বিষয়বস্তুতে চলুন

মডিউল:sl-common

উইকিঅভিধান, মুক্ত অভিধান থেকে

এই মডিউলের জন্য মডিউল:sl-common/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে

local export = {}

local u = mw.ustring.char
local GRAVE     = u(0x0300)
local ACUTE     = u(0x0301)
local MACRON    = u(0x0304)
local DGRAVE    = u(0x030F)
local INVBREVE  = u(0x0311)

function export.has_accents(word)
	if mw.ustring.find(mw.ustring.lower(word), "[áéíóŕúȃȇȋȏȓȗāēīōūȁȅȉȍȕèẹọ" .. GRAVE .. ACUTE .. MACRON .. DGRAVE .. INVBREVE .. "]") then
		return true
	else
		return false
	end
end

function export.remove_accents(text)
	return require("Module:languages").getByCode("sl"):makeEntryName(text)
end

function export.is_soft(stem)
	if mw.ustring.find(stem, "[cjčšž]$") then
		return true
	else
		return false
	end
end

function export.first_palat(stem)
	if stem:sub(-2) == "k" then return stem:sub(1, -2) .. "č"
	elseif stem:sub(-2) == "g" then return stem:sub(1, -2) .. "ž"
	elseif stem:sub(-3) == "sk" then return stem:sub(1, -3) .. "šč"
	else return stem
	end
end

function export.second_palat(stem)
	if stem:sub(-2) == "k" then return stem:sub(1, -2) .. "c"
	elseif stem:sub(-2) == "g" then return stem:sub(1, -2) .. "z"
	else return stem
	end
end

function export.iotation(stem)
	if stem:sub(-2) == "sk" then return stem:sub(1, -3) .. "šč"
	elseif stem:sub(-2) == "sl" then return stem:sub(1, -3) .. "šlj"
	elseif stem:sub(-1) == "t" or stem:sub(-1) == "k" or stem:sub(-1) == "c" then return stem:sub(1, -2) .. "č"
	elseif stem:sub(-1) == "g" or stem:sub(-1) == "z" then return stem:sub(1, -2) .. "ž"
	elseif stem:sub(-1) == "h" or stem:sub(-1) == "s" then return stem:sub(1, -2) .. "š"
	elseif stem:sub(-1) == "d" then return stem:sub(1, -2) .. "j"
	elseif stem:sub(-1) == "m" then return stem:sub(1, -2) .. "mlj"
	elseif stem:sub(-1) == "p" then return stem:sub(1, -2) .. "plj"
	elseif stem:sub(-1) == "b" then return stem:sub(1, -2) .. "blj"
	elseif stem:sub(-1) == "v" then return stem:sub(1, -2) .. "vlj"
	else return stem
	end
end

function export.t(stem)
	if mw.ustring.find(stem, "st$") then return stem
	elseif mw.ustring.find(stem, "[bp]$") then return stem .. "st"
	elseif mw.ustring.find(stem, "[dtz]$") then return (mw.ustring.gsub(stem, ".$", "st"))
	elseif mw.ustring.find(stem, "[čgkrž]$") then return (mw.ustring.gsub(stem, ".$", "č"))
	else return stem .. "t"
	end
end

return export