Module:User:Dine2016/ja-ojad

Hello, you have come here looking for the meaning of the word Module:User:Dine2016/ja-ojad. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:User:Dine2016/ja-ojad, but we will also tell you about its etymology, its characteristics and you will know how to say Module:User:Dine2016/ja-ojad in singular and plural. Everything you need to know about the word Module:User:Dine2016/ja-ojad you have here. The definition of the word Module:User:Dine2016/ja-ojad will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:User:Dine2016/ja-ojad, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


local export = {}

local find = mw.ustring.find
local sub = mw.ustring.sub
local gsub = mw.ustring.gsub
local match = mw.ustring.match

local m_ja = require("Module:ja")
local data = mw.loadData("Module:ja/data/ojad/る")

local function contains(list, item)
	for i = 1, #list do
		if list == item then return true end
	end
	return false
end

local function ja(text)
	return '<span lang="ja" class="Jpan">' .. text .. '</span>'
end

-- interpolate_kanji('開く', 'あく', 'あきます') returns '開きます'
local function interpolate_kanji(kanji, kana1, kana2)
	local kanji_stem, okurigana = match(kanji, '^(.-)(*)$')
	if not find(kana1, okurigana .. '$') then error(kana1 .. ' does not end with ' .. okurigana) end
	local kana_stem = gsub(kana1, okurigana .. '$', '')
	if find(kanji_stem, '来$') and find(kana_stem, 'く$') then kana_stem = gsub(kana_stem, 'く$', '') end
	if not find(kana2, '^' .. kana_stem) then error(kana2 .. ' does not begin with ' .. kana_stem) end
	local kanji2 = gsub(kana2, '^' .. kana_stem, kanji_stem)
	return kanji2
end

-- a tick in pron denotes a fall in pitch, no tick means heibangata
-- format_accent(frame, "かえりま'す") returns overlined かえります and 
local function format_accent(frame, pron)
	-- count morae
	local acc = gsub(pron, "", '')
	acc = m_ja.count_morae(match(acc, "^(.-)'") or '')
	
	-- call ja_pron to format the accent
	pron = gsub(pron, "'", '')
	local ja_pron = frame:expandTemplate{ title = 'ja-pron', args = {  = pron, acc = acc } }
	local kana, romaji = match(ja_pron, '(<span lang="ja" class="Jpan">.-) (<span class="Latn"><samp>.-</samp></span>)')
	return kana, romaji
end

local function format_row(frame, label, lemma_kanji, lemma_kana, prons) -- prons is '-' (no accent provided) or one or more pron separated by '/'
	local kanji, kana, romaji
	if prons == '' then
		kanji = '-'
		kana = '-'
		romaji = '-'
	else
		kanji = {}
		kana = {}
		romaji = {}
		for pron in mw.text.gsplit(prons, '/') do
			local new_kanji = interpolate_kanji(lemma_kanji, lemma_kana, gsub(pron, "", ''))
			if not contains(kanji, new_kanji) then table.insert(kanji, new_kanji) end
			local new_kana, new_romaji = format_accent(frame, pron)
			table.insert(kana, new_kana)
			table.insert(romaji, new_romaji)
		end
		kanji = table.concat(kanji, '<br>')
		kana = table.concat(kana, '<br>')
		romaji = table.concat(romaji, '<br>')
		kanji = ja(kanji)
	end
	return kana
end

local function format_word(frame, key)
	local result = {}
	if data then
		local entry = data
		local lemma_kanji = gsub(key, ':.*', '')
		local lemma_kana = gsub(gsub(entry, '/.*', ''), '', '')
		for i = 1, 12 do
			table.insert(result, '| ' .. format_row(frame, 'aaa', lemma_kanji, lemma_kana, entry))
		end
	else
		error('no entry for ' .. key)
	end
	return table.concat(result, '\n')
end

function export.test(frame)
	local keys = {
'生える','腫れる','触れる','混ぜる','向ける','もてる','揺れる','避ける','寄せる','与える','暴れる','溢れる','甘える','慌てる','いじめる','浮かべる','薄める','埋める:うずめる','抑える','収める','恐れる','抱える','掲げる','重ねる','固める','鍛える','崩れる','加える','応える','こぼれる','支える','仕入れる','沈める','優れる','育てる','務める','努める','潰れる','強める','眺める','名付ける','怠ける','寝かせる','離れる','広げる','広める','深める','含める','ふざける','震える','ぶつける','解ける:ほどける','任せる','見上げる','見詰める','認める',
'目覚める','用いる','求める','休める','破れる','夢見る','弱める','憧れる','改める','受け入れる','受け付ける','受け止める','打ち明ける','打ち上げる','訴える','埋め立てる','追い掛ける','押し寄せる','訪れる','衰える','傾ける','苦しめる','試みる','妨げる','確かめる','抱き上げる','捕まえる','積み上げる','出迎える','整える','取り上げる','取り入れる','取り替える','慰める','引き上げる','引き受ける','恵まれる','持ち上げる','役立てる','呼び掛ける','呼び止める','言い聞かせる','組み合わせる','作り上げる'
	}
	local result = {'{|\n'}
	for _, key in ipairs(keys) do
		--table.insert(result, '|-\n' .. format_word(frame, key))
	end
	table.insert(result, '\n|}')
	return ']<br>]'
	--return table.concat(result, '\n')
end

return export