Module:ryu-conj

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


-- WORK IN PROGRESS --

local export = {}
local m_ryu = require("Module:ryu")
local m_links = require("Module:links")
local m_str_utils = require("Module:string utilities")
local lang = require("Module:languages").getByCode("ryu")

local ryu_cni = require("Module:ryu-shift").continuative_stem
local ryu_fun = require("Module:ryu-shift").fundamental_stem
local ryu_onb = require("Module:ryu-shift").onbin_stem

local format_ryu = require("Module:ryu-shift").format_ryu
local format_ryu_kata = require("Module:ryu-shift").format_ryu_kata
local format_ryu_extras = require("Module:ryu-shift").format_ryu_extras
local format_ryu_no_glottal = require("Module:ryu-shift").format_ryu_no_glottal
local format_ryu_split_vowel = require("Module:ryu-shift").format_ryu_split_vowel
local format_ryu_broken_vowel = require("Module:ryu-shift").format_ryu_broken_vowel

local conjIrregulars = require("Module:ryu-shift").conj_irregulars

local romaji = m_ryu.kana_to_romaji
local hiragana = m_ryu.kata_to_hira
local katakana = m_ryu.romaji_to_kata

function export.ryuconj(frame)
	
	local params = {
		 = {}, -- Stem
		 = {}, -- Column (a single letter)
		 = {},
		 = { type = "boolean", default = nil }, -- Intransitivity
	};

	local args = require("Module:parameters").process(frame:getParent().args, params)
	local head = args or mw.title.getCurrentTitle().text
	
	if args == nil and args == nil then args = "" elseif args == nil then error("Parameter 2= is unset.") end
	if args == nil then args = head end
	
	local stem = args
	local col = args
	
	checkStemValidity(stem, col)

	local headstem = removeEnding(head, col)
	
	if headstem == nil then error("Invalid conjugation paradigm given in parameter 2=.") end
	
	local data = {forms = {}, cascade = {}, entry = {}, head = head, headstem = headstem, rows = {"ind", "pro", "cau", "pas", "cps", "irs", "pre", "stm", "cnj", "des", "apo", "pol", "plq" }}
	
	for key, row in pairs(data.rows) do
		
		data.forms = conjugate(row, stem, col)
		for ckey, crow in pairs(data.forms) do data.cascade = crow end
	
	end
	
	return export.make_table(data, args)
	
end

function export.make_table(data, args)
	
	local content = [=[
{| class="inflection-table vsSwitcher wikitable" style="margin: 0; margin-top: 2px; text-align: center; width: 100%; border-top: 0" rules="all"
! class="vsToggleElement" colspan="3" style="font-size:97.5%; background-color: var(--wikt-palette-magenta-3, #eaecf0); text-align:left; padding: 2px 2px 2px 10px" | Conjugation of@ROMA "<span class="Jpan" lang="ja-Jpan">@HEADWORD</span>"@ANNOTATION
|- class="vsHide"
! colspan="3" style="@HEADERPADDING; @FONTSIZE" | Key conjugational stems
|- class="vsHide"
! style="@PADDING; width: 30%; @FONTSIZE" | Irrealis (<span class="Jpan" lang="ryu" style="font-size: 97.5%; word-break: keep-all">未然形</span>)
| style="@PADDING; width: 35%" | {stm.irr}
| style="@PADDING; width: 35%" | {k.stm.irr}
|- class="vsHide"
! style="@PADDING; @FONTSIZE" | Continuative (<span class="Jpan" lang="ryu" style="font-size: 97.5%; word-break: keep-all">連用形</span>)
| style="@PADDING" | {stm.cni}
| style="@PADDING" | {k.stm.cni}
|- class="vsHide"
! colspan="3" style="@HEADERPADDING; @FONTSIZE" | Key constructions
|- class="vsHide"
! style="@PADDING; @FONTSIZE" | Terminal
| style="@PADDING" | {ind.p_im}
| style="@PADDING" | {k.ind.p_im}
|- class="vsHide"
! style="@PADDING; @FONTSIZE" | Negative
| style="@PADDING" | {ind.ineg}
| style="@PADDING" | {k.ind.ineg}
|- class="vsHide"
! style="@PADDING; @FONTSIZE" | Adnominal
| style="@PADDING" | {ind.a_im}
| style="@PADDING" | {k.ind.a_im}
|- class="vsHide"
! style="@PADDING; @FONTSIZE" | Conditional
| style="@PADDING" | {stm.con}
| style="@PADDING" | {k.stm.con}
|- class="vsHide"
! style="@PADDING; @FONTSIZE" | Imperative
| style="@PADDING" | {stm.imp}
| style="@PADDING" | {k.stm.imp}
|- class="vsHide"
| colspan="3" style="padding: 0" |
{|class="inflection-table wikitable" style="margin: 0; text-align: center; min-width: 100%; border-top: 0; border-style: hidden" rules="all"
|-
! colspan="4" style="@HEADERPADDING; @FONTSIZE" | Aspectual forms
|-
! style="@HEADERPADDING; @FONTSIZE" | Aspect
! style="@HEADERPADDING; @FONTSIZE" | Stem
! colspan="2" style="@HEADERPADDING; @FONTSIZE" | Terminal form
|-
! style="@PADDING; width: 30%; @FONTSIZE" | Perfective
| style="@PADDING; width: 23.33%" | {stm.per}
| style="@PADDING; width: 23.33%" | {ind.p_pf}
| style="@PADDING; width: 23.33%" | {k.stm.per}
@RESULTATIVE1
! style="@PADDING; @FONTSIZE" | Progressive
| style="@PADDING" | {stm.pro}
| style="@PADDING" | {pro.p_im}
| style="@PADDING" | {k.stm.pro}
|}
|- class="vsHide"
| colspan="3" style="padding: 0" |
{|class="inflection-table vsSwitcher wikitable" style="margin: 0; text-align: center; min-width: 100%; border-top: 0; border-style: hidden" rules="all"
! class="vsToggleElement" colspan="3" style="@HEADERPADDING; @FONTSIZE; width: 10%" | Conjunctive constructions
|- class="vsHide"
! style="@PADDING; @FONTSIZE; width: 30%" | Conjunctive
| style="@PADDING; width: 35%" | {stm.cnj}
| style="@PADDING; width: 35%" | {k.stm.cnj}
|- class="vsHide"
! style="@PADDING; @FONTSIZE" | Request
| style="@PADDING" | {cnj.req}
| style="@PADDING" | {k.cnj.req}
|- class="vsHide"
! style="@PADDING; @FONTSIZE" | Benefactive
| style="@PADDING" | {cnj.ben}
| style="@PADDING" | {k.cnj.ben}
|- class="vsHide"
! style="@PADDING; @FONTSIZE" | Completive
| style="@PADDING" | {cnj.cmp}
| style="@PADDING" | {k.cnj.cmp}
|}
|- class="vsHide"
| colspan="3" style="padding: 0" |
{|class="inflection-table vsSwitcher wikitable" style="margin: 0; text-align: center; min-width: 100%; border-top: 0; border-style: hidden" rules="all"
! class="vsToggleElement" colspan="3" style="@HEADERPADDING; @FONTSIZE; width: 10%" | Constructions with the apocopated form
|- class="vsHide"
! style="@PADDING; @FONTSIZE; width: 30%" | Apocopated form
| style="@PADDING; width: 35%" | {apo.apo}
| style="@PADDING; width: 35%" | {k.apo.apo}
|- class="vsHide"
! style="@PADDING; @FONTSIZE" | Prohibitive
| style="@PADDING" | {apo.prb}
| style="@PADDING" | {k.apo.prb}
|- class="vsHide"
! style="@PADDING; @FONTSIZE" | Reported past
| style="@PADDING" | {apo.rpp}
| style="@PADDING" | {k.apo.rpp}
|- class="vsHide"
! style="@PADDING; @FONTSIZE" | Nominalized
| style="@PADDING" | {apo.nom}
| style="@PADDING" | {k.apo.nom}
|- class="vsHide"
! style="@PADDING; @FONTSIZE" | Hypothetical <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Provisional
| style="@PADDING" | {apo.pvc}
| style="@PADDING" | {k.apo.pvc}
|- class="vsHide"
! style="@PADDING; @FONTSIZE" | Cause and effect
| style="@PADDING" | {apo.cae}
| style="@PADDING" | {k.apo.cae}
|}
|- class="vsHide"
! colspan="3" style="@HEADERPADDING; @FONTSIZE" | Other forms
|- class="vsHide"
! style="@PADDING; @FONTSIZE" | Volitional
| style="@PADDING" | {stm.irr}
| style="@PADDING" | {k.stm.irr}
|- class="vsHide"
! style="@PADDING; @FONTSIZE" | Polite
| style="@PADDING" | {pol.p_im}
| style="@PADDING" | {k.pol.p_im}
|- class="vsHide"
! style="@PADDING; @FONTSIZE" | Polar questions
| style="@PADDING" | {plq.p_im}
| style="@PADDING" | {k.plq.p_im}
|}
{| class="inflection-table vsSwitcher wikitable" style="margin: 0; margin-top: 2px; text-align: center; width: 100%; border-top: 0" rules="all"
! class="vsToggleElement" colspan="3" style="font-size:97.5%; background-color: var(--wikt-palette-magenta-3, #eaecf0); text-align:left; padding: 2px 2px 2px 10px" | Extended conjugation of@ROMA "<span class="Jpan" lang="ja-Jpan">@HEADWORD</span>"@ANNOTATION
|- class="vsHide"
! colspan="3" style="@HEADERPADDING; @FONTSIZE" | Indicative
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; width: 30%" |
! style="@HEADERPADDING; @FONTSIZE; width: 35%" | Terminal
! style="@HEADERPADDING; @FONTSIZE; width: 35%" | Adnominal
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Non-past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Imperfective
| style="@PADDING" | {ind.p_im}
| style="@PADDING" | {ind.a_im}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Negative
| colspan="2" style="@PADDING" | {ind.ineg}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Perfective
| style="@PADDING" | {ind.p_pf}
| style="@PADDING" | {ind.a_pf}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Negative past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> perfective
| colspan="2" style="@PADDING" | {ind.pneg}
|- class="vsHide"
! colspan="3" style="@HEADERPADDING; @FONTSIZE" | Progressive
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; width: 30%" |
! style="@HEADERPADDING; @FONTSIZE; width: 35%" | Terminal
! style="@HEADERPADDING; @FONTSIZE; width: 35%" | Adnominal
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Non-past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Imperfective
| style="@PADDING" | {pro.p_im}
| style="@PADDING" | {pro.a_im}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Negative
| colspan="2" style="@PADDING" | {pro.ineg}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Perfective
| style="@PADDING" | {pro.p_pf}
| style="@PADDING" | {pro.a_pf}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Negative past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> perfective
| colspan="2" style="@PADDING" | {pro.pneg}
|- class="vsHide"
! colspan="3" style="@HEADERPADDING; @FONTSIZE" | Causative
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; width: 30%" |
! style="@HEADERPADDING; @FONTSIZE; width: 35%" | Terminal
! style="@HEADERPADDING; @FONTSIZE; width: 35%" | Adnominal
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Non-past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Imperfective
| style="@PADDING" | {cau.p_im}
| style="@PADDING" | {cau.a_im}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Negative
| colspan="2" style="@PADDING" | {cau.ineg}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Perfective
| style="@PADDING" | {cau.p_pf}
| style="@PADDING" | {cau.a_pf}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Negative past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> perfective
| colspan="2" style="@PADDING" | {cau.pneg}
|- class="vsHide"
! colspan="3" style="@HEADERPADDING; @FONTSIZE" | Passive <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Potential
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; width: 30%" |
! style="@HEADERPADDING; @FONTSIZE; width: 35%" | Terminal
! style="@HEADERPADDING; @FONTSIZE; width: 35%" | Adnominal
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Non-past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Imperfective
| style="@PADDING" | {pas.p_im}
| style="@PADDING" | {pas.a_im}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Negative
| colspan="2" style="@PADDING" | {pas.ineg}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Perfective
| style="@PADDING" | {pas.p_pf}
| style="@PADDING" | {pas.a_pf}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Negative past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> perfective
| colspan="2" style="@PADDING" | {pas.pneg}
|- class="vsHide"
! colspan="3" style="@HEADERPADDING; @FONTSIZE" | Causative passive
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; width: 30%" |
! style="@HEADERPADDING; @FONTSIZE; width: 35%" | Terminal
! style="@HEADERPADDING; @FONTSIZE; width: 35%" | Adnominal
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Non-past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Imperfective
| style="@PADDING" | {cps.p_im}
| style="@PADDING" | {cps.a_im}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Negative
| colspan="2" style="@PADDING" | {cps.ineg}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Perfective
| style="@PADDING" | {cps.p_pf}
| style="@PADDING" | {cps.a_pf}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Negative past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> perfective
| colspan="2" style="@PADDING" | {cps.pneg}
@RESULTATIVE2
! colspan="3" style="@HEADERPADDING; @FONTSIZE" | Preparatory
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; width: 30%" |
! style="@HEADERPADDING; @FONTSIZE; width: 35%" | Terminal
! style="@HEADERPADDING; @FONTSIZE; width: 35%" | Adnominal
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Non-past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Imperfective
| style="@PADDING" | {pre.p_im}
| style="@PADDING" | {pre.a_im}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Negative
| colspan="2" style="@PADDING" | {pre.ineg}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Perfective
| style="@PADDING" | {pre.p_pf}
| style="@PADDING" | {pre.a_pf}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Negative past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> perfective
| colspan="2" style="@PADDING" | {pre.pneg}
|- class="vsHide"
! colspan="3" style="@HEADERPADDING; @FONTSIZE" | Desiderative
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; width: 30%" |
! style="@HEADERPADDING; @FONTSIZE; width: 35%" | Terminal
! style="@HEADERPADDING; @FONTSIZE; width: 35%" | Adnominal
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Non-past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Imperfective
| style="@PADDING" | {des.p_im}
| style="@PADDING" | {des.a_im}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Negative
| colspan="2" style="@PADDING" | {des.ineg}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Perfective
| style="@PADDING" | {des.p_pf}
| style="@PADDING" | {des.a_pf}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Negative past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> perfective
| colspan="2" style="@PADDING" | {des.pneg}
|- class="vsHide"
! colspan="3" style="@HEADERPADDING; @FONTSIZE" | Polite
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; width: 30%" |
! style="@HEADERPADDING; @FONTSIZE; width: 35%" | Terminal
! style="@HEADERPADDING; @FONTSIZE; width: 35%" | Adnominal
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Non-past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Imperfective
| style="@PADDING" | {pol.p_im}
| style="@PADDING" | {pol.a_im}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Negative
| colspan="2" style="@PADDING" | {pol.ineg}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Perfective
| style="@PADDING" | {pol.p_pf}
| style="@PADDING" | {pol.a_pf}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Negative past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> perfective
| colspan="2" style="@PADDING" | {pol.pneg}
|- class="vsHide"
! colspan="3" style="@HEADERPADDING; @FONTSIZE" | Polar questions
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; width: 30%" |
! colspan="2" style="@HEADERPADDING; @FONTSIZE; width: 70%" | Terminal
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Non-past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Imperfective
| colspan="2" style="@PADDING" | {plq.p_im}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Negative
| colspan="2" style="@PADDING" | {plq.ineg}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Perfective
| colspan="2" style="@PADDING" | {plq.p_pf}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px; padding-right: 20px" | Negative past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> perfective
| colspan="2" style="@PADDING" | {plq.pneg}
|}
]=]
	
	if args == true then
		content = content:gsub("@RESULTATIVE1", "|-")
		content = content:gsub("@RESULTATIVE2", '|- class="vsHide"')
	else
		content = content:gsub("@RESULTATIVE1", [=[
|-
! style="@PADDING; @FONTSIZE" | Resultative
| style="@PADDING" | {stm.res}
| style="@PADDING" | {irs.p_im}
| style="@PADDING" | {k.stm.res}
|-
]=])
		content = content:gsub("@RESULTATIVE2", [=[
|- class="vsHide"
! colspan="3" style="@HEADERPADDING; @FONTSIZE" | Resultative
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; width: 30%" |
! style="@HEADERPADDING; @FONTSIZE; width: 35%" | Terminal
! style="@HEADERPADDING; @FONTSIZE; width: 35%" | Adnominal
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px" | Non-past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Imperfective
| style="@PADDING" | {irs.p_im}
| style="@PADDING" | {irs.a_im}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px" | Negative
| colspan="2" style="@PADDING" | {irs.ineg}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px" | Past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> Perfective
| style="@PADDING" | {irs.p_pf}
| style="@PADDING" | {irs.a_pf}
|- class="vsHide"
! style="@HEADERPADDING; @FONTSIZE; text-align: left; padding-left: 20px" | Negative past <span class="Jpan" lang="ja-Jpan" style="font-size: 95%">/</span> perfective
| colspan="2" style="@PADDING" | {irs.pneg}
|- class="vsHide"
]=])
	end
	
	content = content:gsub("@HEADERPADDING", 'padding: 9px 10px 9px 10px')
	content = content:gsub("@PADDING", 'padding: 12px 10px 12px 10px')
	content = content:gsub("@FONTSIZE", 'font-size: 96%%')
	
	if check_r_types(args) and args ~= "rn" then content = content:gsub("@ROMA", " ''" .. format_ryu_extras(data.cascade) .. "''") else content = content:gsub("@ROMA", " ''" .. format_ryu_extras(data.cascade) .. "''") end
	content = content:gsub("@HEADWORD", args)
	content = content:gsub("@ANNOTATION", ", ''" .. args .. "''-column verb")
	
	local history = {}
	
	return (string.gsub(content, "{(+)}",
			function(code)
				if history == nil then history = {} end
				if code:sub(1, 2) == "k." then
					local count = 0
					data.entry = map(data.cascade, function(i)
						count = count + 1
						i = format_ryu_extras(i)
						local format_ryu = format_ryu(i)
						local forms = {}
						if format_ryu ~= history then
							table.insert(forms, format_ryu)
						end
						if format_ryu:find("ゐ") ~= nil or format_ryu:find("ゑ") ~= nil or format_ryu:find("をぅ") ~= nil or format_ryu:find("っや") ~= nil then
							table.insert(forms, format_ryu_no_glottal(format_ryu))
							if format_ryu:find("をぅ") ~= nil then
								table.insert(forms, format_ryu_kata(i):gsub("ウゥ", "ヲゥ") .. '')
							end
							table.insert(forms, format_ryu_kata(i))
						elseif format_ryu:find("いぃ") ~= nil then
							table.insert(forms, format_ryu:gsub("いぃ", "ゐ"))
							table.insert(forms, format_ryu_kata(i))
							table.insert(forms, format_ryu_kata(i):gsub("イィ", "ヰ") .. '')
						else
							table.insert(forms, format_ryu_kata(i))
						end
						if format_ryu:find("じ") ~= nil then
							table.insert(forms, format_ryu_kata(i):gsub("ジ", "ヂ") .. '')
						end
						return '<span class="Jpan" lang="ryu">' .. table.concat(forms, " / ") .. '</span>'
					end)
					return table.concat(data.entry, "<br>")
				end
				if data.cascade == nil then error("Form code {" .. code .. "} not defined.") end
				data.entry = map(data.cascade, function(i)
					local i_broken = format_ryu_extras(format_ryu_broken_vowel(i, args))
					i = format_ryu_extras(i)
					local form_shown = format_ryu(i_broken):gsub("^" .. format_ryu(args), data.headstem)
					if args == "r2" and format_ryu(i_broken):find("^" .. format_ryu(args:sub(1, -2) .. "ē")) ~= nil then
						form_shown = form_shown:gsub("^" .. format_ryu(args:sub(1, -2) .. "ē"), data.headstem .. "え")
					end
					local lemma = data.cascade -- Table
					if data.headstem:sub(-3, -1) == "ー" and args:sub(-1, -1) == lemma:sub(#args + 1, #args + 1) then
						if args:sub(-1, -1) == format_ryu_split_vowel(i):sub(#args + 1, #args + 1) then
							form_shown = form_shown:gsub("^" .. data.headstem .. "い", data.headstem)
						else
							form_shown = form_shown:gsub("^" .. data.headstem, data.headstem:sub(1, -4))
						end
					end
					if check_r_types(args) and args:sub(-1, -1) == "i" and data.headstem:sub(-3, -1) ~= "ー" then
						form_shown = form_shown:gsub("^" .. data.headstem .. "い", data.headstem)
					end
					if ((args == "r5" or args == "r6") and form_shown:find("^" .. format_ryu(args):sub(1, -4) .. "っ") ~= nil) or (args == "r5" and form_shown:find("^" .. format_ryu(args):sub(1, -4) .. "ら") ~= nil) then
						form_shown = form_shown:gsub("^" .. format_ryu(args):sub(1, -4), data.headstem:sub(1, #format_ryu(args):sub(1, -4)))
					end
					table.insert(history, form_shown)
					if form_shown == data.head then
						return =] .. form_shown .. =] .. i .. ']</span>'
					end
					return '<span class="Jpan" lang="ryu">' .. form_shown .. '</span> <span style="font-size:95%"></span>'
				end)
				return table.concat(data.entry, "<br>")
			end))
	
end

function returnForms(p)
	
	p.infix = p.infix == nil and "" or p.infix
	
	p.i_infix = p.i_infix == nil and p.infix or p.i_infix
	p.p_infix = p.p_infix == nil and p.infix or p.p_infix
	p.n_infix = p.n_infix == nil and p.infix or p.n_infix
	p.p_stem = p.p_stem == nil and p.stem or p.p_stem
	p.n_stem = p.n_stem == nil and p.stem or p.n_stem
	
	local conj = {
		p_im = { p.stem .. p.i_infix .. "n" },
		a_im = { p.stem .. p.i_infix .. "ru" },
		p_pf = { p.p_stem .. p.p_infix .. "an" },
		a_pf = { p.p_stem .. p.p_infix .. "aru" },
		ineg = { p.n_stem .. p.n_infix .. "an" },
		pneg = { p.n_stem .. p.n_infix .. "antan" },		
	};

	if p.grade == "" then return conjIrregulars(p) end

	if p.grade == "r2" and p.base ~= nil then
		
		conj = { p.base .. "ran", p.base .. "an" }
		conj = { p.base .. "rantan", p.base .. "antan" }
		
	elseif p.grade == "r5" and p.base ~= nil and p.base:sub(-2, -1) == "ri" then
		
		conj = { p.base:sub(1, -3) .. "ran" }
		conj = { p.base:sub(1, -3) .. "rantan" }
		
	elseif p.grade == "rn" and p.base ~= nil then
		
		conj = { p.base .. "n" }
		conj = { p.base .. "ru" }		

	end
	
	if p.r_type == true and p.base ~= nil and p.grade ~= "rn" then
		
		conj = { p.base .. "yun", p.base .. "in" }
		conj = { p.base .. "yuru", p.base .. "iru" }
		
	elseif p.pas == true then
		
		conj = { p.stem .. "ariyun", p.stem .. "ariin" }
		conj = { p.stem .. "ariyuru", p.stem .. "ariiru" }
		conj = { p.p_stem .. "aritan", p.p_stem .. "attan" }
		conj = { p.p_stem .. "aritaru", p.p_stem .. "attaru" }
		conj = { p.n_stem .. "ariran", p.n_stem .. "aran" }
		conj = { p.n_stem .. "arirantan", p.n_stem .. "aratan" }
		
	elseif p.cps == true then
		
		conj = { p.stem .. "asariyun", p.stem .. "asariin" }
		conj = { p.stem .. "asariyuru", p.stem .. "asariiru" }
		conj = { p.p_stem .. "asaritan" }
		conj = { p.p_stem .. "asariraru" }
		conj = { p.n_stem .. "asariran" }
		conj = { p.n_stem .. "asarirantan" }
	
	elseif p.irs == true then
		
		conj = { p.n_stem .. p.n_infix .. "nēn" }
		conj = { p.n_stem .. p.n_infix .. "nēntan" }
		
	elseif p.pre == true then
		
		conj = { p.p_stem .. "ōchan" }
		conj = { p.p_stem .. "ōcharu" }
		
	elseif p.des == true then
		
		conj = { p.n_stem .. "ikō nēn", p.n_stem .. "ikō nēran" }
		conj = { p.n_stem .. "ikō nēntan", p.n_stem .. "ikō nērantan" }

	end
	
	return conj
	
end

function conjugate(row, stem, col)
	
	local conj = "—"
	
	if row == "ind" and check_r_types(col) then
		
		conj = returnForms({ stem = ryu_cni(stem, col), p_stem = ryu_onb(stem, col), n_stem = ryu_fun(stem, col), i_infix = "u", r_type = true, base = stem, grade = col, row = row })
		return conj
	
	elseif row == "ind" then
		
		conj = returnForms({ stem = ryu_cni(stem, col), p_stem = ryu_onb(stem, col), n_stem = ryu_fun(stem, col), i_infix = "u", grade = col, row = row })
		return conj
		
	elseif row == "pro" then
		
		conj = returnForms({ stem = ryu_onb(stem, col), infix = "ō", p_infix = "ōt", n_infix = "ēwur", grade = col, row = row })
		return conj
		
	elseif row == "cau" then
		
		if col == "r2" then
			conj = returnForms({ stem = stem, infix = "asu", p_infix = "ach", n_infix = "as", grade = col, row = row })
			return conj
		elseif col == "r5" then
			conj = returnForms({ stem = stem:sub(1, -2), infix = "asu", p_infix = "ach", n_infix = "as", grade = col, row = row })
			return conj
		end
		
		conj = returnForms({ stem = ryu_fun(stem, col), infix = "asu", p_infix = "ach", n_infix = "as", grade = col, row = row })
		return conj
		
	elseif row == "pas" then
		
		if col == "r2" then
			conj = returnForms({ stem = stem, pas = true })
			return conj
		elseif col == "r5" then
			conj = returnForms({ stem = stem:sub(1, -2), pas = true })
			return conj
		end
		
		conj = returnForms({ stem = ryu_fun(stem, col), pas = true, grade = col, row = row })
		return conj
		
	elseif row == "cps" then
		
		if col == "r2" then
			conj = returnForms({ stem = stem, cps = true })
			return conj
		elseif col == "r5" then
			conj = returnForms({ stem = stem:sub(1, -2), cps = true })
			return conj
		end
		
		conj = returnForms({ stem = ryu_fun(stem, col), cps = true, grade = col, row = row })
		return conj
		
	elseif row == "irs" then
		
		conj = returnForms({ stem = ryu_onb(stem, col), infix = "ē", p_infix = "ēt", irs = true, grade = col, row = row })
		return conj
		
	elseif row == "pre" then
		
		conj = returnForms({ stem = ryu_onb(stem, col), infix = "ōchu", p_infix = "ōch", n_infix = "ēuk", pre = true, grade = col, row = row })
		return conj
		
	elseif row == "des" then
	
		if col == "r2" then
			conj1 = returnForms({ stem = ryu_cni(stem, col) .. " bus", i_infix = "a", p_infix = "at", des = true })
			conj2 = returnForms({ stem = stem:sub(1, -2) .. "ē bus", i_infix = "a", p_infix = "at", des = true })
			return join(conj1, conj2)	
		elseif check_r_types(col) then
			conj = returnForms({ stem = ryu_cni(stem, col) .. " bus", i_infix = "a", p_infix = "at", des = true, grade = col, row = row })
			return conj
		end
		
		conj = returnForms({ stem = ryu_cni(stem, col) .. "i bus", i_infix = "a", p_infix = "at", des = true, grade = col, row = row })
		
		return conj
		
	elseif row == "pol" then
		
		if check_r_types(col) then
			
			conj1 = returnForms({ stem = ryu_cni(stem, col):sub(1, -2), i_infix = "yabiyu", p_infix = "yabit", n_infix = "yabir" })
			conj2 = returnForms({ stem = ryu_cni(stem, col):sub(1, -2), i_infix = "yabī", p_infix = "yabit", n_infix = "yabir" })
			conj3 = returnForms({ stem = ryu_cni(stem, col), i_infix = "biyu", p_infix = "bit", n_infix = "bir" })
			conj4 = returnForms({ stem = ryu_cni(stem, col), i_infix = "bī", p_infix = "bit", n_infix = "bir" })
	
			return join(join(conj1, conj2), join(conj3, conj4))
			
		end
		
		conj1 = returnForms({ stem = ryu_cni(stem, col), i_infix = "abiyu", p_infix = "abit", n_infix = "abir", grade = col, row = row })
		conj2 = returnForms({ stem = ryu_cni(stem, col), i_infix = "abī", p_infix = "abit", n_infix = "abir", grade = col, row = row })

		return join(conj1, conj2)
		
	elseif row == "plq" then
		
		conj = {
			p_im = { ryu_cni(stem, col) .. "umi" },
			p_pf = { ryu_onb(stem, col) .. "ī" },
			ineg = { ryu_fun(stem, col) .. "ani" },
			pneg = { ryu_fun(stem, col) .. "antī" },
		}
		
		if check_r_types(col) then conj = { stem .. "yumi", stem .. "imi" } end
		if col == "r2" then conj = { stem .. "ani" }; conj = { stem .. "antī" } end
		if col == "r5" then conj = { stem:sub(1, -2) .. "ani" }; conj = { stem:sub(1, -2) .. "antī" } end
		
		return conj
		
	elseif row == "cnj" then
		
		conj = {
			req = { ryu_onb(stem, col) .. "i kwimisōrē", ryu_onb(stem, col) .. "i kwimisōri" },
			ben = { ryu_onb(stem, col) .. "i kwīn" },
			cmp = { ryu_onb(stem, col) .. "i nēn" }
		};
		
		return conj
		
	elseif row == "apo" then
		
		if check_r_types(col) then
			
			conj = {
				apo = { stem .. "yu", ryu_cni(stem, col) },
				rpp = { stem .. "yutan", ryu_cni(stem, col) .. "tan" },
				nom = { stem .. "yushi", ryu_cni(stem, col) .. "shi" },
				prb = { stem .. "yuna", ryu_cni(stem, col) .. "na" },
				pvc = { stem .. "yurā", ryu_cni(stem, col) .. "rā" },
				cae = { stem .. "yukutu", ryu_cni(stem, col) .. "kutu" },
			};
	
			return conj
			
		end
		
		conj = {
			apo = { ryu_cni(stem, col) .. "u" },
			rpp = { ryu_cni(stem, col) .. "utan" },
			nom = { ryu_cni(stem, col) .. "ushi" },
			prb = { ryu_cni(stem, col) .. "una" },
			pvc = { ryu_cni(stem, col) .. "urā" },
			cae = { ryu_cni(stem, col) .. "ukutu" },
		};
		
		return conj
		
	elseif row == "stm" then
		
		conj = {
			irr = { ryu_fun(stem, col) .. "a" },
			cni = { ryu_cni(stem, col) .. "i" },
			per = { ryu_onb(stem, col) .. "a" },
			pro = { ryu_onb(stem, col) .. "ō" },
			res = { ryu_onb(stem, col) .. "ē" },
			cnj = { ryu_onb(stem, col) .. "i" },
			con = { ryu_fun(stem, col) .. "ē" },
			imp = { ryu_fun(stem, col) .. "i", ryu_fun(stem, col) .. "ē" },
		};
	
		if check_r_types(col) then conj = { ryu_cni(stem, col) } end
	
		if col == "r2" then 
			conj = { ryu_fun(stem, col) .. "a", stem .. "a" } 
			conj = { ryu_cni(stem, col), stem:sub(1, -2) .. "ē"}
		elseif col == "r5" then
			conj = { stem:sub(1, -2) .. "a" } 
		end
		
		return conj
		
	end
	
	return conj
	
end

function removeEnding(head, col)
	if col == "k" or col == "t" then
		if head:sub(-9, -1) == "ちゅん" then
			return head:sub(1, -10)
		else
			error("col=" .. col ..  " and dictionary form ending mismatch.")
		end
	elseif col == "g" or col == "d" or col == "d2" then
		if head:sub(-9, -1) == "じゅん" then
			return head:sub(1, -10)
		else
			error("col=" .. col ..  " and dictionary form ending mismatch.")
		end
	elseif col == "s" then
		if head:sub(-6, -1) == "すん" then
			return head:sub(1, -7)
		else
			error("col=" .. col ..  " and dictionary form ending mismatch.")
		end
	elseif col == "b" then
		if head:sub(-6, -1) == "ぶん" then
			return head:sub(1, -7)
		else
			error("col=" .. col ..  " and dictionary form ending mismatch.")
		end
	elseif col == "n" then
		if head:sub(-6, -1) == "ぬん" then
			return head:sub(1, -7)
		else
			error("col=" .. col ..  " and dictionary form ending mismatch.")
		end
	elseif col == "m" then
		if head:sub(-6, -1) == "むん" then
			return head:sub(1, -7)
		else
			error("col=" .. col ..  " and dictionary form ending mismatch.")
		end
	elseif check_r_types(col) then
		if head:sub(-6, -1) == "いん" then
			return head:sub(1, -7)
		elseif head:sub(-6, -1) == "ゆん" then
			return head:sub(1, -7)
		elseif head:sub(-3, -1) == "ん" then
			return head:sub(1, -4)
		else
			error("col=" .. col ..  " and dictionary form ending mismatch.")
		end
	elseif col == "" then
		return ""
	else
		error("Conjugation type given in parameter 2= is not defined in removeEnding().")
	end
end

function check_r_types(s)
	if s == "" then return false end
	if s ~= "r" and s ~= "rn" and tonumber(s:sub(-1, -1)) == nil then
		return false
	elseif s == "r" or s == "rn" then
		return true
	elseif (s:sub(1, 1) == "r" and tonumber(s:sub(-1, -1)) <= 6 and tonumber(s:sub(-1, -1)) >= 2) then
		return true
	end
	return false
end

function map(tbl, f)
    local t = {}
    for k,v in pairs(tbl) do
        t = f(v)
    end
    return t
end

function checkStemValidity(stem, col)
	if (col == "r5" or col == "r6") and stem:sub(-2, -1) ~= "ri" then
		error("Stem ending 1= and conjugation type 2= mismatch. Conjugation types r5 and r6 requires that the stem ends in -ri")
	end
end

function join(t1, t2)
	local out = {}
	for k, v in pairs(t1) do
		if table.concat(v)== table.concat(t2) then
			out = v
		else
			local i = {}
			for ki, vi in pairs(v) do table.insert(i, vi) end
			for ki, vi in pairs(t2) do table.insert(i, vi) end
			out = i
		end
	end
	return out
end

return export