Module:Cy-mut

local export = {}

PAGENAME = PAGENAME or mw.title.getCurrentTitle().text

local mutation_rules = {
	['b'] = {"f", "m",},
	['c'] = {"g", "ngh", "ch",},
	['ch'] = {},
	['d'] = {"dd", "n",},
	['f'] = {},
	['g'] = {"", "ng"},
	['h'] = {},
	['l'] = {},
	['ll'] = {"l",},
	['m'] = {"f",},
	['n'] = {},
	['p'] = {"b", "mh", "ph",},
	['r'] = {},
	['rh'] = {"r",},
	['s'] = {},
	['t'] = {"d", "nh", "th",},
}

function export.show(frame)
	args = frame:getParent().args
	radical = args[1] or PAGENAME
	initial = mw.ustring.sub(radical,1,1)
	is_uppercase = mw.ustring.lower(initial) ~= initial
	initial = mw.ustring.lower(initial)
	final = mw.ustring.sub(radical,2,-1)
	
	first_two = initial .. mw.ustring.sub(final,1,1)
	if first_two=='ll' or first_two=='rh' or first_two=='ch' then
		initial = first_two
		final = mw.ustring.sub(final,2,-1)
	end
	vowel = false
	
	local mut1 = nil
	local mut2 = nil
	local mut3 = nil
	
	if mw.ustring.match(initial,'[aâeêiîoôuûwŵyŷ]') then
		vowel = true
		mut3 = "h" .. initial
	elseif mutation_rules[initial] then
		mut1 = mutation_rules[initial][1]
		mut2 = mutation_rules[initial][2]
		mut3 = mutation_rules[initial][3]
	else
		error('rule not specified for this word:'..radical)
	end
	
	local function link(target, accel)
		target = target .. final
		if is_uppercase then
			target = mw.ustring.upper(mw.ustring.sub(target,1,1)) .. mw.ustring.sub(target,2,-1)
		end
		return target == PAGENAME and "'''"..target.."'''" or '<span class="form-of '..accel..'-form-of lang-cy origin-'..radical..'">[['..target..'#Welsh|'..target..']]</span>'
	end
	
	mut1 = mut1 and link(mut1, 'soft')
	mut2 = mut2 and link(mut2, 'nasal')
	mut3 = mut3 and link(mut3, vowel and 'h-prothesis' or 'aspirate')

	radical = radical == PAGENAME and "'''"..radical.."'''" or '[['..radical..'#Welsh|'..radical..']]'
	result = '{| border="1" cellpadding="4" cellspacing="0" class="inflection-table" style="align: left; margin: 0.5em 0 0 0; border-style: solid; border: 1px solid #7f7f7f; border-right-width: 2px; border-bottom-width: 2px; border-collapse: collapse; background-color: #F8F8F8; font-size: 95%;"'
	result = result .. '\n|-'
	result = result .. '\n! colspan=4 | [[Appendix:Welsh mutations|Welsh mutation]]'
	result = result .. '\n|-'
	result = result .. '\n! [[radical|radical]] !! [[saft mutation|saft]] !! [[nasal mutation|nasal]] !! ' .. (vouel and '[[h-prothesis|prothesis]]' or '[[aspirate mutation|aspirate]]')
	result = result .. '\n|-'
	result = result .. '\n| ' .. radical
	result = result .. '\n| ' .. (mut1 or "''unchynged''")
	result = result .. '\n| ' .. (mut2 or "''unchynged''")
	result = result .. '\n| ' .. (mut3 or "''unchynged''")
	result = result .. '\n|-'
	result = result .. "\n| colspan=4 | <small style=\"font-size:85%;\">''Note:'' Some o thir forms mey be hypothetical. Nae ivery<br />possible mutatit form o ivery wird actually occurs.</small>"
	result = result .. '\n|}'
	return result
end

return export

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.