Module:rad-stem/templates: Difference between revisions

From Laenkea
Jump to navigation Jump to search
mNo edit summary
Tags: Mobile edit Mobile web edit
mNo edit summary
Line 27: Line 27:
temp = mw.ustring.gsub(temp, "(úș)$", "uoș")
temp = mw.ustring.gsub(temp, "(úș)$", "uoș")
temp = mw.ustring.gsub(temp, "(ýș)$", "yeș")
temp = mw.ustring.gsub(temp, "(ýș)$", "yeș")
temp = mw.ustring.gsub(temp, "(oș)$", "uș")


return temp
return temp
Line 35: Line 36:
local stems = get_stems(args)
local stems = get_stems(args)
local adj = args['adj']
local adj = args['adj']
local adj_broken = break_adj(adj)
local adj_broken = ""
local adj_broken_e = ""
if adj then
adj_broken = break_adj(adj)  
adj_broken_e = mw.ustring.gsub(adj_broken, "(uș)$", "ûș")
end
return adj
return adj_broken
end
end



Revision as of 15:56, 28 November 2023

Underlies:


local export = {}
local getArgs = require('Module:Arguments').getArgs

local m_stem = require("Module:rad-stem")
local m_links = require("Module:links")
local m_parameters = require("Module:parameters")

function get_stems(args)
	local shifted = {"noun", "_"}
	
	local i = 1
	while args[i] do
		shifted[i+2] = args[i]
		i = i + 1
	end
	
	return m_stem.getNounStem(shifted)
end

function break_adj(adj)
	local C = "bcdðfghħjĵkķlmnņpqrsștvwxzþ°"
	local temp = adj

	temp = mw.ustring.gsub(temp, "([" .. C .. "])([" .. C .. "])íș$", "%1%2ieș")
	temp = mw.ustring.gsub(temp, "(°)", "")
	temp = mw.ustring.gsub(temp, "(íș)$", "jeș")
	temp = mw.ustring.gsub(temp, "(úș)$", "uoș")
	temp = mw.ustring.gsub(temp, "(ýș)$", "yeș")
	temp = mw.ustring.gsub(temp, "(oș)$", "uș")

	return temp
end

function export.sg_pl(frame)
	local args = getArgs(frame)
	local stems = get_stems(args)
	local adj = args['adj']
	local adj_broken = ""
	local adj_broken_e = ""
	if adj then
		adj_broken = break_adj(adj) 
		adj_broken_e = mw.ustring.gsub(adj_broken, "(uș)$", "ûș")
	end
	
	return adj_broken
end

return export

--[[
Debug console test string:
=p.sg_pl(mw.getCurrentFrame():newChild{title="whatever",args={"hv", "o~u^u", "þ"}})
]]--