Documentation for this module may be created at မဝ်ဂျူ:ko-conj/doc

local export = {}
local m_translit = require('Module:ko-translit').tr_revised

local gsub = mw.ustring.gsub
local sub = mw.ustring.sub
local match = mw.ustring.match
local len = mw.ustring.len
local codepoint = mw.ustring.codepoint
local char = mw.ustring.char

local grey_bg = ' style="background:#E0E0E0" '
local rom_format = '<span style="font-size:90%; color:#888" class="tr">'

function format_Korean(text, rom, horizontal, no_space)
	return '<span class="Kore" lang="ko"">' .. text .. "</span>" .. (rom
		and (horizontal and (no_space and '' or ' ') .. '(' .. rom_format or '<br>' .. rom_format) ..
			m_translit(tostring(rom) ~= "true" and rom or text) .. 
			 '</span>' .. (horizontal and ')' or '')
		or '')
end

function replace(text1, text2, text3)
	if match(text1, text2) and len(text1) == len(text2) then
		return gsub(text1, text2, text3)
	else
		return gsub(text1, sub(text2, 1, -2), sub(text3, 1, -2))
	end
end

local conj_type = {
	["adjectives"] = {
		["ha"] = { name = "ha-irregular", Korean = "하" },
		["reu"] = { name = "reu-irregular", Korean = "르" },
		["reo"] = { name = "reo-irregular", Korean = "러" },
		["s"] = { name = "s-irregular", Korean = "ㅅ" },
		["p"] = { name = "p-irregular", Korean = "ㅂ" },
		["h"] = { name = "h-irregular", Korean = "ㅎ" },
		["det_h"] = { name = "determiner-h-irregular", Korean = "ㅎ", extra = "-determiner" },
		["l"] = { name = "l-irregular", Korean = "ㄹ" },
		["si"] = { name = "si-irregular", Korean = "시" },
		["i"] = { name = "i-irregular", Korean = "이" },
		["ex"] = { name = "existential-irregular", Korean = "있/없", rom = "iss/eops" },
	},
	["verbs"] = {
		["ha"] = { name = "ha-irregular", Korean = "하" },
		["ga"] = { name = "ga-irregular", Korean = "가" },
		["si"] = { name = "si-irregular", Korean = "시" },
		["o"] = { name = "o-irregular", Korean = "오" },
		["reu"] = { name = "reu-irregular", Korean = "르" },
		["reo"] = { name = "reo-irregular", Korean = "러" },
		["s"] = { name = "s-irregular", Korean = "ㅅ" },
		["p"] = { name = "p-irregular", Korean = "ㅂ" },
		["noh"] = { name = "noh-irregular", Korean = "놓", rom = "noh" },
		["l"] = { name = "l-irregular", Korean = "ㄹ" },
		["d"] = { name = "d-irregular", Korean = "ㄷ" },
		["eo"] = { name = "eo-irregular", Korean = "어" },
		["u"] = { name = "u-irregular", Korean = "우" },
	}
}

function conj_text(irregtype, pos)
	if irregtype == '' then return 'regular' end
	local conj_data = conj_type[pos][irregtype]
	return '[[:Category:Korean ' .. 
		conj_data.name .. 
		' ' .. pos .. '|' .. 
		format_Korean(conj_data.Korean, rom or true, true, true) .. 
		(conj_data.extra or "") .. 
		"-irregular]]"
end
	
function conj_category(irregtype, pos)
	if irregtype == '' then return '' end
	return '[[Category:Korean ' .. conj_type[pos][irregtype].name .. ' ' .. pos .. ']]'
end
	
function export.adjective(frame, args)
	local args = args or frame:getParent().args
	local word = args[1] or mw.title.getCurrentTitle().text
	local irreg = args["irreg"] or false
	local honorific = args["honorific"] or 'yes'
	local phonetic = args["phon"] and sub(args["phon"], 1, -2) or false
	local honorific_note = args["honorific_note"] or nil
	local form = args["form"] or false
	local forms = {}
	local honforms = {}
	local consonant_stem = true
	
	stem1 = sub(word,1,-2)
	prestem1 = sub(stem1,1,-2)
	stem1last_basic = codepoint(sub(stem1,-1,-1))
	stem1last = stem1last_basic - 0xAC00
	stem1_jongseong = stem1last % 28
	
	if stem1_jongseong == 0 then
		stem1_jongseong = false
	else
		stem1_jongseong = char(0x11A7 + stem1_jongseong)
	end
	
	stem1_jungseong = math.floor((stem1last % 588) / 28)
	stem1_jungseong = char(0x1161 + stem1_jungseong)
	
	if not stem1_jongseong then
		consonant_stem = false
		hal = prestem1 .. char(stem1last_basic + 8)
		ham = prestem1 .. char(stem1last_basic + 16)
		han = prestem1 .. char(stem1last_basic + 4)
		hap = prestem1 .. char(stem1last_basic + 17)
		
		if stem1_jungseong == 'ᅡ' then
			if codepoint(sub(stem1,-1,-1)) == 54616 then
				irregtype = 'ha'
				stem2 = prestem1 .. char(stem1last_basic + 28)
				haet = prestem1 .. '했'
				stem2a = stem1 .. '여'
				hayeot = stem1 .. '였'
			else
				haet = prestem1 .. char(stem1last_basic + 20)
			end
			
		elseif stem1_jungseong == 'ᅵ' then
			stem2 = prestem1 .. char(stem1last_basic - 392)
			haet = prestem1 .. char(stem1last_basic - 372)
			if codepoint(sub(stem1,-1,-1)) == 49884 and irreg == 'y' then
				irregtype = 'si'
				honorific = 'no'
				stem2a = prestem1 .. '세'
				honorific_note = "''This adjective is in honorific form.''"
			elseif match(sub(stem1,-1,-1),'[이니]') and irreg == 'y' then
				irregtype = 'i'
				stem2, stem2a, haet = stem1 .. "에", stem1 .. "어", stem1 .. '었'
			else
				stem2a, hayeot = stem1 .. '어', stem1 .. '었'
			end
			
		elseif match(stem1_jungseong,'[ᅢᅦᅰ]') then
			haet = prestem1 .. char(stem1last_basic + 20)
			stem2a, hayeot = stem1 .. '어', stem1 .. '었'
			
		elseif stem1_jungseong == 'ᅩ' then
			stem2, stem2a = prestem1 .. char(stem1last_basic + 28), stem1 .. '아'
			haet, hayeot = prestem1 .. char(stem1last_basic + 48), stem1 .. '았'
			
		elseif stem1_jungseong == 'ᅬ' then
			stem2 = prestem1 .. char(stem1last_basic - 28)
			haet = prestem1 .. char(stem1last_basic - 8)
			stem2a, hayeot = stem1 .. '어', stem1 .. '었'
			
		elseif stem1_jungseong == 'ᅳ' then
			if codepoint(sub(stem1,-1,-1)) == 47476 then
				if match(sub(stem1,-2,-1),'[누노푸]르') then
					irregtype = 'reo'
					stem2 = stem1 .. '러'
					haet = stem1 .. '렀'
				else
					irregtype = 'reu'
					antepenultimate = sub(prestem1,1,-2)
					penultimate = codepoint(sub(prestem1,-1,-1))
					penultimate_vowel = char(0x1161 + math.floor(((penultimate - 0xAC00) % 588) / 28))
					if match(penultimate_vowel,'[ᅡᅣᅩᅭ]') then
						stem2 = antepenultimate .. char(penultimate + 8) .. '라'
						haet = antepenultimate .. char(penultimate + 8) .. '랐'
					else
						stem2 = antepenultimate .. char(penultimate + 8) .. '러'
						haet = antepenultimate .. char(penultimate + 8) .. '렀'
					end
				end
			else
				if len(stem1) ~= 1 then
					penultimate = codepoint(sub(prestem1,-1,-1))
					penultimate_vowel = char(0x1161 + math.floor(((penultimate - 0xAC00) % 588) / 28))
				else
					penultimate_vowel = 'ᅥ'
				end
				if match(penultimate_vowel,'[ᅡᅣᅩᅭ]') then
					stem2 = prestem1 .. char(stem1last_basic - 504)
					haet = prestem1 .. char(stem1last_basic - 484)
				else
					stem2 = prestem1 .. char(stem1last_basic - 392)
					haet = prestem1 .. char(stem1last_basic - 372)
				end
			end
		elseif stem1_jungseong == 'ᅮ' then
			if sub(stem1,-1,-1) == '우' then
				stem2, haet = prestem1 .. '워', prestem1 .. '웠'
			else
				stem2, stem2a = stem1 .. '어', prestem1 .. char(stem1last_basic + 28)
				haet, hayeot = stem1 .. '었', prestem1 .. char(stem1last_basic + 48)
			end
		else
			stem2, haet = stem1 .. '어', stem1 .. '었'
		end
	else
		if irreg == 'y' then
			if stem1_jongseong == 'ᇂ' then
				cstem = 'y'
				irregtype = 'h'
				if (match(stem1, '[이요그고저조무]렇') or match(stem1, '어떻')) and not match(stem1, '[성더덩둥뚱댕뎅]그렇') then
					irregtype = 'det_h'
					stem2 = prestem1 .. char(stem1last_basic - 111)
					haet = prestem1 .. char(stem1last_basic - 91)
				else
					stem2 = prestem1 .. char(stem1last_basic + 1)
					haet = prestem1 .. char(stem1last_basic + 21)
				end
				stem3 = prestem1 .. char(stem1last_basic - 27)
				hal = prestem1 .. char(stem1last_basic - 19)
				ham = prestem1 .. char(stem1last_basic - 11)
				han = prestem1 .. char(stem1last_basic - 23)
			elseif stem1_jongseong == 'ᆺ' then
				cstem = 'y'
				irregtype = 's'
				de_s = char(stem1last_basic - 19)
				stem3 = prestem1 .. de_s .. '으'
				ham = prestem1 .. de_s .. '음'
				hal = prestem1 .. de_s .. '을'
				han = prestem1 .. de_s .. '은'
				if match(stem1_jungseong,'[ᅡᅣᅩᅭ]') then
					stem2 = prestem1 .. de_s .. '아'
					haet = prestem1 .. de_s .. '았'
				else
					stem2 = prestem1 .. de_s .. '어'
					haet = prestem1 .. de_s .. '었'
				end
			elseif stem1_jongseong == 'ᆸ' or stem1_jongseong == 'ᆲ' then
				cstem = 'y'
				irregtype = 'p'
				de_p = char(stem1last_basic - (stem1_jongseong == 'ᆲ' and 3 or 17))
				stem3 = prestem1 .. de_p .. '우'
				ham = prestem1 .. de_p .. '움'
				hal = prestem1 .. de_p .. '울'
				han = prestem1 .. de_p .. '운'
				if len(stem1) == 1 then
					if match(stem1_jungseong,'[ᅡᅣᅩᅭ]') then
						stem2 = prestem1 .. de_p .. '와'
						haet = prestem1 .. de_p .. '왔'
					else
						stem2 = prestem1 .. de_p .. '워'
						haet = prestem1 .. de_p .. '웠'
					end
				else
					stem2, haet = prestem1 .. de_p .. '워', prestem1 .. de_p .. '웠'
				end
			else
				return error("Irregular irregtype unrecognised.")
			end
		elseif stem1_jongseong == 'ᆯ' then
			cstem = 'n'
			irregtype = 'l'
			stem3 = prestem1 .. char(stem1last_basic - 8)
			ham = prestem1 .. char(stem1last_basic + 2)
			hal = stem1
			han = prestem1 .. char(stem1last_basic - 4)
			hap = prestem1 .. char(stem1last_basic + 9)
			if match(stem1_jungseong,'[ᅡᅣᅩᅭ]') then
				stem2 = stem1 .. '아'
			else
				stem2 = stem1 .. '어'
			end
		elseif stem1_jongseong == 'ᆸ' then
			if match(sub(stem1,-1,-1),'[답롭]') or sub(stem1,-2,-1) == '스럽' then
				cstem = 'y'
				irregtype = 'p'
				de_p = char(stem1last_basic - 17)
				stem3 = prestem1 .. de_p .. '우'
				ham = prestem1 .. de_p .. '움'
				hal = prestem1 .. de_p .. '울'
				han = prestem1 .. de_p .. '운'
				stem2, haet = prestem1 .. de_p .. '워', prestem1 .. de_p .. '웠'
			else
				cstem = 'y'
				stem3 = stem1 .. '으'
				if match(stem1_jungseong,'[ᅡᅣᅩᅭ]') then
					stem2 = stem1 .. '아'
				else
					stem2 = stem1 .. '어'
				end
			end
		else
			cstem = 'y'
			stem3 = stem1 .. '으'
			if match(stem1_jungseong,'[ᅡᅣᅩᅭ]') then
				stem2 = stem1 .. '아'
			else
				stem2 = stem1 .. '어'
			end
		end
	end
	if not haet then
		if stem2 == (stem1 .. '어') then
			haet = stem1 .. '었'
		elseif stem2 == (stem1 .. '아') then
			haet = stem1 .. '았'
		end
	end
	stem2 = stem2 or stem1
	stem3 = stem3 or stem1
	ham = ham or (stem1 .. '음')
	hal = hal or (stem1 .. '을')
	if not han then
		if match(sub(stem1,-1,-1),'[있없밌]') then
			irregtype = 'ex'
			han = stem1 .. '는'
		else
			han = stem1 .. '은'
		end
	end
	
	if form == 'hae' then
		return stem2
	elseif form == 'hae2' then
		return stem2a
	elseif form == 'hani' then
		return stem3 .. '니'
	end

	forms.lemma = stem1 .. '다'
	forms.ind_hrc = stem1 .. '다'
	forms.ind_hrc_past = haet .. '다'
	forms.ind_hc = stem2
	forms.ind_hc_past = haet .. '어'
	forms.ind_hyc = stem2 .. '요'
	forms.ind_hyc_past = haet .. '어요'
	forms.ind_hssoc_past = haet .. '습니다'
	forms.interrog_hrc = stem3 .. '냐'
	forms.interrog_hrc_past = haet .. '냐'
	forms.interrog_hc = stem2
	forms.interrog_hc_past = haet .. '어'
	forms.interrog_hyc = stem2 .. '요'
	forms.interrog_hyc_past = haet .. '어요'
	forms.interrog_hssoc_past = haet .. '습니까'
	forms.assert_hrc = stem1 .. '겠다'
	forms.assert_hc = stem1 .. '겠어'
	forms.assert_hyc = stem1 .. '겠어요'
	forms.assert_hssoc = stem1 .. '겠습니다'
	forms.cause_hrc = stem2
	forms.cause_hc = stem2 .. '서'
	forms.cause_hyc = stem3 .. '니'
	forms.cause_hssoc = stem3 .. '니까'
	forms.contrast_hrc = stem1 .. '지만'
	forms.contrast_hc = han .. '데'
	forms.contrast_hyc = stem1 .. '더니'
	forms.conjunction = stem1 .. '고'
	forms.condition_hc = stem2 .. '야'
	forms.vn_um = ham
	forms.vn_gi = stem1 .. '기'
	forms.vn_um_past = haet .. '음'
	forms.vn_gi_past = haet .. '기'
	forms.determ_pres = han
	forms.determ_fut = hal

	if irregtype ~= 'ha' and irregtype ~= 'i' then
		if stem2a then
			forms.ind_hyc_alt = stem2a .. '요'
			forms.interrog_hyc_alt = stem2a .. '요'
		end
	end
	if irregtype == 'i' then
		forms.ind_hc, forms.interrog_hc = stem1 .. '야', stem1 .. '야'
		if sub(stem1,-1,-1) == '이' then
			forms.ind_hyc_alt = prestem1 .. '예요'
			forms.interrog_hyc_alt = prestem1 .. '예요'
		end
		forms.interrog_hrc_past = haet .. '느냐'
		forms.cause_hc = stem2a .. '서'
		forms.condition_hc = stem2a .. '야'
		for key, term in pairs(forms) do
			if match(term, "이었") then
				forms[key] = forms[key] .. ', ' .. gsub(term, '이었', '였')
			end
		end
	end
	if match(sub(stem1,-1,-1),'[있없밌]') then
		forms.interrog_hrc = stem1 .. '느냐'
		forms.interrog_hrc_past = haet .. '느냐'
	end
	if cstem == 'y' then
		forms.ind_hssoc = stem1 .. '습니다'
		forms.interrog_hssoc = stem1 .. '습니까'
	else
		if not hap then
			forms.ind_hssoc = stem1 .. '읍니다'
			forms.interrog_hssoc = stem1 .. '읍니까'
		else
			forms.ind_hssoc = hap .. '니다'
			forms.interrog_hssoc = hap .. '니까'
		end
	end
	if stem1 == hal then
		forms.condition_hrc = stem1 .. '면'
	else
		forms.condition_hrc = stem3 .. '면'
	end
	if stem2a and irregtype ~= 'si' and irregtype ~= 'i' then
		forms.cause_hc_alt = stem2a .. '서'
		forms.condition_hc_alt = stem2a .. '야'
	end
	if hayeot then
		forms.vn_um_past_alt = hayeot .. '음'
		forms.vn_gi_past_alt = hayeot .. '기'
	end

	if forms.ind_hyc_alt then
		if irregtype == 'si' then
			forms.ind_hyc = forms.ind_hyc_alt .. ', ' .. forms.ind_hyc
		else
			forms.ind_hyc = forms.ind_hyc .. ', ' .. forms.ind_hyc_alt
		end
	end
	if forms.interrog_hyc_alt then
		if irregtype == 'si' then
			forms.interrog_hyc = forms.interrog_hyc_alt .. ', ' .. forms.interrog_hyc
		else
			forms.interrog_hyc = forms.interrog_hyc .. ', ' .. forms.interrog_hyc_alt
		end
	end
	if forms.cause_hc_alt then
		forms.cause_hc = forms.cause_hc .. ', ' .. forms.cause_hc_alt
	end
	if forms.condition_hc_alt then
		forms.condition_hc = forms.condition_hc .. ', ' .. forms.condition_hc_alt
	end
	if forms.vn_um_past_alt then
		forms.vn_um_past = forms.vn_um_past .. ', ' .. forms.vn_um_past_alt
	end
	if forms.vn_gi_past_alt then
		forms.vn_gi_past = forms.vn_gi_past .. ', ' .. forms.vn_gi_past_alt
	end

	for key, form in pairs(forms) do
		if forms[key] ~= '' then
			forms[key] = format_Korean(form, phonetic and replace(form, stem1, phonetic) or form)
		end
	end
	if honorific == 'yes' then
		honforms.ind_hrc = stem3 .. '시다'
		honforms.ind_hrc_past = stem3 .. '셨다'
		honforms.ind_hc = stem3 .. '셔'
		honforms.ind_hc_past = stem3 .. '셨어'
		honforms.ind_hyc = stem3 .. '세요'
		honforms.ind_hyc_alt = stem3 .. '셔요'
		honforms.ind_hyc_past = stem3 .. '셨어요'
		honforms.ind_hsc = stem3 .. '십니다'
		honforms.ind_hsc_past = stem3 .. '셨습니다'
		honforms.interrog_hrc = stem3 .. '시냐'
		honforms.interrog_hrc_past = stem3 .. '셨냐'
		honforms.interrog_hc = stem3 .. '셔'
		honforms.interrog_hc_past = stem3 .. '셨어'
		honforms.interrog_hyc = stem3 .. '세요'
		honforms.interrog_hyc_alt = stem3 .. '셔요'
		honforms.interrog_hyc_past = stem3 .. '셨어요'
		honforms.interrog_hsc = stem3 .. '십니까'
		honforms.interrog_hsc_past = stem3 .. '셨습니까'
		honforms.assert_hrc = stem3 .. '시겠다'
		honforms.assert_hc = stem3 .. '시겠어'
		honforms.assert_hyc = stem3 .. '시겠어요'
		honforms.assert_hsc = stem3 .. '시겠습니다'
		honforms.cause_hrc = stem3 .. '셔'
		honforms.cause_hc = stem3 .. '셔서'
		honforms.cause_hyc = stem3 .. '시니'
		honforms.cause_hsc = stem3 .. '시니까'
		honforms.contrast_hrc = stem3 .. '시지만'
		honforms.contrast_hc = stem3 .. '신데'
		honforms.contrast_hyc = stem3 .. '시더니'
		honforms.conjunction = stem3 .. '시고'
		honforms.condition_hrc = stem3 .. '시면'
		honforms.condition_hc = stem3 .. '셔야'
		honforms.vn_um = stem3 .. '심'
		honforms.vn_gi = stem3 .. '시기'
		honforms.vn_um_past = stem3 .. '셨음'
		honforms.vn_gi_past = stem3 .. '셨기'
		honforms.determ_pres = stem3 .. '신'
		honforms.determ_fut = stem3 .. '실' 
		
		honforms.ind_hyc = honforms.ind_hyc .. ', ' .. honforms.ind_hyc_alt
		honforms.interrog_hyc = honforms.interrog_hyc .. ', ' .. honforms.interrog_hyc_alt
		
		for honkey, honform in pairs(honforms) do
			honforms[honkey] = format_Korean(honform, phonetic and replace(honform, stem1, phonetic) or honform)
		end
		
		honorific = [=[
		
{| border="1" color="#cdcdcd" style="border-collapse:collapse; border:1px solid #555555; background:#F7F0F0; width:100%; text-align:center" class="inflection-table" cellpadding="5"
|- 
!colspan="100%" align="center" style="background:#C0C0C0" |'''Sentence-final forms with honorific''']=] .. (honorific_note or "") .. [=[ 
|- ]=] .. grey_bg .. [=[ 
|colspan=2|
!Plain (]=] .. format_Korean("[[해라체]]") .. [=[)
!Informal (]=] .. format_Korean("[[해체]]") .. [=[)
!Polite (]=] .. format_Korean("[[해요체]]") .. [=[)
!Formal (]=] .. format_Korean("[[하십시오체]]") .. [=[)
|- 
!rowspan=2]=] .. grey_bg .. [=[|Indicative
!]=] .. grey_bg .. [=[|Non-past
|]=] .. honforms.ind_hrc .. [=[ 
|]=] .. honforms.ind_hc .. [=[ 
|]=] .. honforms.ind_hyc .. [=[ 
|]=] .. honforms.ind_hsc .. [=[ 
|-
!]=] .. grey_bg .. [=[|Past
|]=] .. honforms.ind_hrc_past ..[=[ 
|]=] .. honforms.ind_hc_past ..[=[ 
|]=] .. honforms.ind_hyc_past ..[=[ 
|]=] .. honforms.ind_hsc_past ..[=[ 
|-
!rowspan=2]=] .. grey_bg .. [=[|Interrogative
!]=] .. grey_bg .. [=[|Non-past
|]=] .. honforms.interrog_hrc .. [=[ 
|]=] .. honforms.interrog_hc .. [=[ 
|]=] .. honforms.interrog_hyc .. [=[ 
|]=] .. honforms.interrog_hsc .. [=[ 
|-
!]=] .. grey_bg .. [=[|Past
|]=] .. honforms.interrog_hrc_past .. [=[ 
|]=] .. honforms.interrog_hc_past .. [=[ 
|]=] .. honforms.interrog_hyc_past .. [=[ 
|]=] .. honforms.interrog_hsc_past .. [=[ 
|-
!colspan=2]=] .. grey_bg .. [=[|Assertive
|]=] .. honforms.assert_hrc .. [=[||]=] .. honforms.assert_hc .. [=[||]=] .. honforms.assert_hyc .. [=[||]=] .. honforms.assert_hsc .. [=[ 
|-
!colspan="100%" align="center" style="background:#C0C0C0" |'''Connective forms with honorific'''
|- 
!colspan=2]=] .. grey_bg .. [=[|Cause/Reason
|]=] .. honforms.cause_hrc .. [=[||]=] .. honforms.cause_hc .. [=[||]=] .. honforms.cause_hyc .. [=[||]=] .. honforms.cause_hsc .. [=[ 
|- 
!colspan=2]=] .. grey_bg .. [=[|Contrast
|]=] .. honforms.contrast_hrc .. [=[||]=] .. honforms.contrast_hc .. [=[||]=] .. honforms.contrast_hyc .. [=[||
|-
!colspan=2]=] .. grey_bg .. [=[|Conjunction
|]=] .. honforms.conjunction .. [=[|| || ||
|-
!colspan=2]=] .. grey_bg .. [=[|Condition
|]=] .. honforms.condition_hrc .. [=[||]=] .. honforms.condition_hc .. [=[|| ||
|- 
!colspan="100%" align="center" style="background:#C0C0C0" |'''Noun and determiner forms with honorific'''
|-
!colspan="2"]=] .. grey_bg.. [=[| Verbal nouns
|]=] .. honforms.vn_um .. [=[||]=] .. honforms.vn_gi .. [=[ 
|-
!colspan="2"]=] .. grey_bg.. [=[| Past-tense verbal nouns
|]=] .. honforms.vn_um_past .. [=[||]=] .. honforms.vn_gi_past .. [=[ 
|-
!rowspan="2"]=] .. grey_bg.. [=[| Determiners
!]=] .. grey_bg.. [=[|Present
|
|]=] .. honforms.determ_pres .. [=[ 
|-
!]=] .. grey_bg.. [=[|Future
|
|]=] .. honforms.determ_fut .. [=[ 
|}]=]
	else
		honorific = honorific_note or "''This word is not usually used with an honorific.''"
	end
	
	stem_type = consonant_stem and "consonant-stem, " or "vowel-stem, "

	conjugation_type = stem_type .. conj_text(irregtype or "", "adjectives")

	if mw.title.getCurrentTitle().nsText == '' then
		conjugation_type = conjugation_type .. conj_category(irregtype or "", "adjectives")
	end
	
	return [=[
<div class="NavFrame">
<div class="NavHead" style="height:2em">&nbsp; &nbsp; Selected forms of the adjective ]=] .. format_Korean(word, phonetic and replace(word, stem1, phonetic) or word, true) .. ": " .. conjugation_type .. [=[</div>
<div class="NavContent">
{| border="1" color="#cdcdcd" style="border-collapse:collapse; border:1px solid #555555; background:#F4F7F0; width:100%; text-align:center" class="inflection-table" cellpadding="5"
|-
!colspan="100%" align="center" style="background:#C0C0C0" |'''Sentence-final forms'''
|-]=] .. grey_bg.. [=[ 
|colspan=2|
!Formal non-polite<br />(]=] .. format_Korean("[[해라체]]") ..[=[)
!Informal non-polite<br />(]=] .. format_Korean("[[해체]]") ..[=[)
!Informal polite<br />(]=] .. format_Korean("[[해요체]]") ..[=[)
!Formal polite<br />(]=] .. format_Korean("[[하십시오체]]") ..[=[)
|-
!rowspan=2]=] .. grey_bg .. [=[|Indicative
!]=] .. grey_bg .. [=[|Non-past
|]=] .. forms.ind_hrc .. [=[ 
|]=] .. forms.ind_hc .. [=[ 
|]=] .. forms.ind_hyc .. [=[ 
|]=] .. forms.ind_hssoc .. [=[ 
|-
!]=] .. grey_bg .. [=[|Past
|]=] .. forms.ind_hrc_past .. [=[ 
|]=] .. forms.ind_hc_past .. [=[ 
|]=] .. forms.ind_hyc_past .. [=[ 
|]=] .. forms.ind_hssoc_past .. [=[ 
|-
!rowspan=2]=] .. grey_bg .. [=[|Interrogative
!]=] .. grey_bg .. [=[|Non-past
|]=] .. forms.interrog_hrc .. [=[ 
|]=] .. forms.interrog_hc .. [=[ 
|]=] .. forms.interrog_hyc .. [=[ 
|]=] .. forms.interrog_hssoc .. [=[ 
|-
!]=] .. grey_bg .. [=[|Past
|]=] .. forms.interrog_hrc_past .. [=[ 
|]=] .. forms.interrog_hc_past .. [=[ 
|]=] .. forms.interrog_hyc_past .. [=[ 
|]=] .. forms.interrog_hssoc_past .. [=[ 
|-
!colspan=2]=] .. grey_bg .. [=[|Assertive
|]=] .. forms.assert_hrc .. [=[||]=] .. forms.assert_hc .. [=[||]=] .. forms.assert_hyc .. [=[||]=] .. forms.assert_hssoc .. [=[ 
|-
!colspan="100%" align="center"  style="background:#C0C0C0" |'''Connective forms'''
|-
!colspan=2]=] .. grey_bg .. [=[|Cause/Reason
|]=] .. forms.cause_hrc .. [=[||]=] .. forms.cause_hc .. [=[||]=] .. forms.cause_hyc .. [=[||]=] .. forms.cause_hssoc .. [=[ 
|-
!colspan=2]=] .. grey_bg .. [=[|Contrast
|]=] .. forms.contrast_hrc .. [=[||]=] .. forms.contrast_hc .. [=[||]=] .. forms.contrast_hyc .. [=[||
|-
!colspan=2]=] .. grey_bg .. [=[|Conjunction
|]=] .. forms.conjunction .. [=[|| || ||
|-
!colspan=2]=] .. grey_bg .. [=[|Condition
|]=] .. forms.condition_hrc .. [=[||]=] .. forms.condition_hc .. [=[|| ||
|-
!colspan="100%" align="center" style="background:#C0C0C0" |'''Noun and determiner forms'''
|-
!colspan="2"]=] .. grey_bg.. [=[|Verbal nouns
|]=] .. forms.vn_um .. [=[||]=] .. forms.vn_gi .. [=[ 
|-
!colspan="2"]=] .. grey_bg.. [=[|Past-tense verbal nouns
|]=] .. forms.vn_um_past .. [=[||]=] .. forms.vn_gi_past .. [=[ 
|-
!rowspan="2"]=] .. grey_bg.. [=[|Determiners
!]=] .. grey_bg.. [=[|Present
|
|]=] .. forms.determ_pres .. [=[ 
|-
!]=] .. grey_bg.. [=[|Future
|
|]=] .. forms.determ_fut .. [=[ 
|}

]=] .. honorific .. [=[</div></div>]=]
end

function export.verb(frame, args)
	local args = args or frame:getParent().args
	local word = args[1] or mw.title.getCurrentTitle().text
	local irreg = args["irreg"] or false
	local reg = args["reg"] or 'no'
	local hortative = args["hortative"] or false
	local imperative = args["imperative"] or false
	local honimperative = args["imperative"] or false
	local phonetic = args["phon"] and sub(args["phon"], 1, -2) or false
	local honorific = args["honorific"] or 'yes'
	local honorific_note = args["honorific_note"] or nil
	local form = args["form"] or false
	local forms = {}
	local honforms = {}
	local consonant_stem = true
	
	stem1 = sub(word,1,-2)
	prestem1 = sub(stem1,1,-2)
	stem1last_basic = codepoint(sub(stem1,-1,-1))
	stem1last = stem1last_basic - 0xAC00
	stem1_jongseong = stem1last % 28
	if stem1_jongseong == 0 then
		stem1_jongseong = false
	else
		stem1_jongseong = char(0x11A7 + stem1_jongseong)
	end
	
	stem1_jungseong = math.floor((stem1last % 588) / 28)
	stem1_jungseong = char(0x1161 + stem1_jungseong)
	
	if not stem1_jongseong then
		consonant_stem = false
		hal = prestem1 .. char(stem1last_basic + 8)
		ham = prestem1 .. char(stem1last_basic + 16)
		han = prestem1 .. char(stem1last_basic + 4)
		hap = prestem1 .. char(stem1last_basic + 17)
		if stem1_jungseong == 'ᅡ' then
			if codepoint(sub(stem1,-1,-1)) == 54616 then
				irregtype = 'ha'
				stem2 = prestem1 .. char(stem1last_basic + 28)
				haet = prestem1 .. '했'
				stem2a = stem1 .. '여'
				hayeot = stem1 .. '였'
			else
				haet = prestem1 .. char(stem1last_basic + 20)
				if codepoint(sub(stem1,-1,-1)) == 44032 then
					if reg == 'no' then
						irregtype = 'ga'
						stem2a = stem1 .. '거'
						stem2b = '가오'
					end
				end
			end
		
		elseif stem1_jungseong == 'ᅵ' then
			stem2 = prestem1 .. char(stem1last_basic - 392)
			haet = prestem1 .. char(stem1last_basic - 372)
			if codepoint(sub(stem1,-1,-1)) == 49884 then
				if irreg == 'y' then
					irregtype = 'si'
					hortative = 'no'
					honorific = 'no'
					stem2a = prestem1 .. '세'
					honorific_note = "''This verb is in honorific form.''"
				end
			end
			if irregtype ~= 'si' then
				stem2a, hayeot = stem1 .. '어', stem1 .. '었'
			end
			
		elseif match(stem1_jungseong,'[ᅢᅦᅰ]') then
			haet = prestem1 .. char(stem1last_basic + 20)
			stem2a, hayeot = stem1 .. '어', stem1 .. '었'
			
		elseif stem1_jungseong == 'ᅩ' then
			stem2 = prestem1 .. char(stem1last_basic + 28)
			haet = prestem1 .. char(stem1last_basic + 48)
			if codepoint(sub(stem1,-1,-1)) == 50724 then
				if reg == 'no' then
					irregtype = 'o'
					stem2a = stem1 .. '너'
					stem2b = '가오'
				else
					stem2a = stem1 .. '아'
					hayeot = stem1 .. '았'
				end
			else
				stem2a = stem1 .. '아'
				hayeot = stem1 .. '았'
			end
			
		elseif stem1_jungseong == 'ᅬ' then
			stem2 = prestem1 .. char(stem1last_basic - 28)
			haet = prestem1 .. char(stem1last_basic - 8)
			stem2a = stem1 .. '어'
			hayeot = stem1 .. '었'
			
		elseif stem1_jungseong == 'ᅳ' then
			if codepoint(sub(stem1,-1,-1)) == 47476 then
				if sub(stem1,-2,-1) == '따르' or sub(stem1,-3,-1) == '다다르' then
					stem2 = prestem1 .. '라'
					haet = prestem1 .. '랐'
				elseif match(sub(stem1,-2,-1),'[치들]르') or sub(stem1,-3,-1) == '우러르' then
					stem2 = prestem1 .. '러'
					haet = prestem1 .. '렀'
				elseif sub(stem1,-2,-1) == '이르' and irreg then
					irregtype = 'reo'
					stem2 = stem1 .. '러'
					haet = stem1 .. '렀'
				else
					irregtype = 'reu'
					antepenultimate = sub(prestem1,1,-2)
					penultimate = codepoint(sub(prestem1,-1,-1))
					penultimate_vowel = char(0x1161 + math.floor(((penultimate - 0xAC00) % 588) / 28))
					if match(penultimate_vowel,'[ᅡᅣᅩᅭ]') then
						stem2 = antepenultimate .. char(penultimate + 8) .. '라'
						haet = antepenultimate .. char(penultimate + 8) .. '랐'
					else
						stem2 = antepenultimate .. char(penultimate + 8) .. '러'
						haet = antepenultimate .. char(penultimate + 8) .. '렀'
					end
				end
			else
				if len(stem1) ~= 1 then
					penultimate = codepoint(sub(prestem1,-1,-1))
					penultimate_vowel = char(0x1161 + math.floor(((penultimate - 0xAC00) % 588) / 28))
				else
					penultimate_vowel = 'ᅥ'
				end
				if match(penultimate_vowel,'[ᅡᅣᅩᅭ]') then
					stem2 = prestem1 .. char(stem1last_basic - 504)
					haet = prestem1 .. char(stem1last_basic - 484)
				else
					stem2 = prestem1 .. char(stem1last_basic - 392)
					haet = prestem1 .. char(stem1last_basic - 372)
				end
			end
		elseif stem1_jungseong == 'ᅮ' then
			if irreg == 'y' then
				irregtype = 'u'
				stem2 = prestem1 .. char(stem1last_basic - 252)
				haet = prestem1 .. char(stem1last_basic - 232)
			elseif sub(stem1,-1,-1) == '우' then
				stem2 = prestem1 .. '워'
				haet = prestem1 .. '웠'
			else
				stem2 = stem1 .. '어'
				haet = stem1 .. '었'
				stem2a = prestem1 .. char(stem1last_basic + 28)
				hayeot = prestem1 .. char(stem1last_basic + 48)
			end
		elseif stem1_jungseong == 'ᅥ' and irreg == 'y' then
			irregtype = 'eo'
			stem2 = prestem1 .. char(stem1last_basic - 84)
			haet = prestem1 .. char(stem1last_basic - 64)
		else
			stem2 = stem1 .. '어'
			haet = stem1 .. '었'
		end
	else
		if irreg == 'y' then
			if stem1_jongseong == 'ᆺ' then
				cstem = 'y'
				irregtype = 's'
				de_s = char(stem1last_basic - 19)
				stem3 = prestem1 .. de_s .. '으'
				ham = prestem1 .. de_s .. '음'
				hal = prestem1 .. de_s .. '을'
				han = prestem1 .. de_s .. '은'
				hap = prestem1 .. de_s .. '읍'
				if match(stem1_jungseong,'[ᅡᅣᅩᅭ]') then
					stem2 = prestem1 .. de_s .. '아'
					haet = prestem1 .. de_s .. '았'
				else
					stem2 = prestem1 .. de_s .. '어'
					haet = prestem1 .. de_s .. '었'
				end
			elseif stem1_jongseong == 'ᆸ' then
				cstem = 'y'
				irregtype = 'p'
				de_p = char(stem1last_basic - 17)
				stem3 = prestem1 .. de_p .. '우'
				ham = prestem1 .. de_p .. '움'
				hal = prestem1 .. de_p .. '울'
				han = prestem1 .. de_p .. '운'
				if len(stem1) == 1 then
					if match(stem1_jungseong,'[ᅡᅣᅩᅭ]') then
						stem2 = prestem1 .. de_p .. '와'
						haet = prestem1 .. de_p .. '왔'
					else
						stem2 = prestem1 .. de_p .. '워'
						haet = prestem1 .. de_p .. '웠'
					end
				else
					stem2 = prestem1 .. de_p .. '워'
					haet = prestem1 .. de_p .. '웠'
				end
			elseif stem1_jongseong == 'ᆮ' then
				irregtype = 'd'
				cstem = 'y'
				d_to_r = char(stem1last_basic + 1)
				hal = prestem1 .. d_to_r .. '을'
				ham = prestem1 .. d_to_r .. '음'
				han = prestem1 .. d_to_r .. '은'
				hap = prestem1 .. d_to_r .. '읍'
				stem3 = prestem1 .. d_to_r .. '으'
				if match(stem1_jungseong,'[ᅡᅣᅩᅭ]') then
					stem2 = prestem1 .. d_to_r .. '아'
					haet = prestem1 .. d_to_r .. '았'
				else
					stem2 = prestem1 .. d_to_r .. '어'
					haet = prestem1 .. d_to_r .. '었'
				end
			else
				return error("Irregular irregtype unrecognised.")
			end
		elseif stem1_jongseong == 'ᆯ' then
			irregtype = 'l'
			cstem = 'n'
			stem1a = prestem1 .. char(stem1last_basic - 8)
			stem3 = prestem1 .. char(stem1last_basic - 8)
			ham = prestem1 .. char(stem1last_basic + 2)
			hal = stem1
			han = prestem1 .. char(stem1last_basic - 4)
			hap = prestem1 .. char(stem1last_basic + 9)
			if match(stem1_jungseong,'[ᅡᅣᅩᅭ]') then
				stem2 = stem1 .. '아'
			else
				stem2 = stem1 .. '어'
			end
		else
			cstem = 'y'
			stem3 = stem1 .. '으'
			if match(stem1_jungseong,'[ᅡᅣᅩᅭ]') then
				stem2 = stem1 .. '아'
				if sub(stem1, -1, -1) == '놓' then
					irregtype = 'noh'
					stem2a = gsub(stem1, '놓', '놔')
				end
			else
				stem2 = stem1 .. '어'
			end
		end
	end
	if not haet then
		if stem2 == (stem1 .. '어') then
			haet = stem1 .. '었'
		elseif stem2 == (stem1 .. '아') then
			haet = stem1 .. '았'
		end
	end
	stem1a = stem1a or stem1
	stem2 = stem2 or stem1
	stem3 = stem3 or stem1
	han = han or (stem1 .. '은')
	ham = ham or (stem1 .. '음')
	hal = hal or (stem1 .. '을')
	hap = hap or (stem1 .. '읍')
	
	if form == 'hae' then
		return stem2
	elseif form == 'hae2' then
		return stem2b and '' or stem2a
	elseif form == 'hani' then
		return stem3 .. '니'
	end
	
	forms.lemma = stem1 .. '다'
	forms.ind_hrc_past = haet .. '다'
	forms.ind_hc = stem2
	forms.ind_hc_past = haet .. '어'
	forms.ind_hyc = stem2 .. '요'
	forms.ind_hyc_past = haet .. '어요'
	forms.ind_hssoc_past = haet .. '습니다'
	forms.interrog_hrc = stem1a .. '느냐'
	forms.interrog_hrc_past = haet .. '느냐'
	forms.interrog_hc = stem2
	forms.interrog_hc_past = haet .. '어'
	forms.interrog_hyc = stem2 .. '요'
	forms.interrog_hyc_past = haet .. '어요'
	forms.interrog_hssoc_past = haet .. '습니까'
	forms.assert_hrc = stem1 .. '겠다'
	forms.assert_hc = stem1 .. '겠어'
	forms.assert_hyc = stem1 .. '겠어요'
	forms.assert_hssoc = stem1 .. '겠습니다'
	forms.cause_hrc = stem2
	forms.cause_hc = stem2 .. '서'
	forms.cause_hyc = stem3 .. '니'
	forms.cause_hssoc = stem3 .. '니까'
	forms.contrast_hrc = stem1 .. '지만'
	forms.contrast_hc = stem1a .. '는데'
	forms.contrast_hyc = stem1 .. '더니'
	forms.conjunction = stem1 .. '고'
	forms.condition_hc = stem2 .. '야'
	forms.vn_um = ham
	forms.vn_gi = stem1 .. '기'
	forms.vn_um_past = haet .. '음'
	forms.vn_gi_past = haet .. '기'
	forms.determ_past = han
	forms.determ_pres = stem1a .. '는'
	forms.determ_fut = hal
	
	if cstem == 'y' then
		forms.ind_hrc = stem1 .. '는다'
		forms.ind_hssoc = stem1 .. '습니다'
		forms.interrog_hssoc = stem1 .. '습니까'
	else
		forms.ind_hrc = han .. '다'
		forms.ind_hssoc = hap .. '니다'
		forms.interrog_hssoc = hap .. '니까'
	end
	if irregtype ~= 'ha' then
		if not stem2b then
			if stem2a then
				forms.ind_hyc_alt = stem2a .. '요'
				forms.interrog_hyc_alt = stem2a .. '요'
			end
		end
	end
	if stem2a then
		if (not stem2b) and irregtype ~= 'si' then
			forms.cause_hc_alt = stem2a .. '서'
			forms.condition_hc_alt = stem2a .. '야'
		end
	end
	if stem1 == hal then
		forms.condition_hrc = stem1 .. '면'
		forms.motive = stem1 .. '려고'
	else
		forms.condition_hrc = stem3 .. '면'
		forms.motive = stem3 .. '려고'
	end
	if hayeot then
		forms.vn_um_past_alt = hayeot .. '음'
		forms.vn_gi_past_alt = hayeot .. '기'
	end
		
	if hortative ~= 'no' then
		forms.hortative_hrc = stem1 .. '자'
		forms.hortative_hc = stem2
		forms.hortative_hyc = stem2 .. '요'
		if irregtype ~= 'ha' then
			if stem2a and not stem2b then
				forms.hortative_hyc_alt = stem2a .. '요'
			end
		end
		forms.hortative_hssoc = hap .. '시다'
	end
	if imperative ~= 'no' then
		if irregtype ~= 'si' then
			if stem2b then
				forms.imperative_hrc = stem2a .. '라'
				forms.imperative_hrc_alt = stem2 .. '라'
			else
				forms.imperative_hrc = stem2 .. '라'
				if stem2a then
					forms.imperative_hrc_alt = stem2a .. '라'
				end
			end
		end
		if irregtype ~= 'si' then
			forms.imperative_hc = stem2
		end
		forms.imperative_hyc = stem2 .. '요'
		if irregtype ~= 'ha' then
			if stem2a and not stem2b then
				forms.imperative_hyc_alt = stem2a .. '요'
			end
		end
		forms.imperative_hssoc = hap .. '시오'
	end
	
	if forms.ind_hyc_alt then
		if irregtype == 'si' then
			forms.ind_hyc = forms.ind_hyc_alt .. ", " .. forms.ind_hyc
		else
			forms.ind_hyc = forms.ind_hyc .. ", " .. forms.ind_hyc_alt
		end
	end

	if forms.interrog_hyc_alt then
		if irregtype == 'si' then
			forms.interrog_hyc = forms.interrog_hyc_alt .. ", " .. forms.interrog_hyc
		else
			forms.interrog_hyc = forms.interrog_hyc .. ", " .. forms.interrog_hyc_alt
		end
	end
	
	if hortative ~= 'no' then
		if forms.hortative_hyc_alt then
			forms.hortative_hyc = forms.hortative_hyc .. ", " .. forms.hortative_hyc_alt
		end
	end
	
	if imperative ~= 'no' then
		if forms.imperative_hrc_alt then
			forms.imperative_hrc = forms.imperative_hrc .. ", " .. forms.imperative_hrc_alt
		end
	
		if forms.imperative_hyc_alt then
			if irregtype == 'si' then
				forms.imperative_hyc = forms.imperative_hyc_alt .. ", " .. forms.imperative_hyc
			else
				forms.imperative_hyc = forms.imperative_hyc .. ", " .. forms.imperative_hyc_alt
			end
		end
	end

	if forms.cause_hc_alt then
		forms.cause_hc = forms.cause_hc .. ", " .. forms.cause_hc_alt
	end

	if forms.condition_hc_alt then
		forms.condition_hc = forms.condition_hc .. ", " .. forms.condition_hc_alt
	end

	if forms.vn_um_past_alt then
		forms.vn_um_past = forms.vn_um_past .. ", " .. forms.vn_um_past_alt
	end

	if forms.vn_gi_past_alt then
		forms.vn_gi_past = forms.vn_gi_past .. ", " .. forms.vn_gi_past_alt
	end
		
	for key, form in pairs(forms) do
		if forms[key] ~= '' then
			forms[key] = format_Korean(form, phonetic and replace(form, stem1, phonetic) or form)
		end
	end
	if hortative ~= 'no' then
		hortative = [=[
|-
!colspan=2]=] .. grey_bg .. [=[|Hortative
|]=] .. forms.hortative_hrc .. [=[||]=] .. forms.hortative_hc .. [=[||]=] .. forms.hortative_hyc .. [=[||]=] .. forms.hortative_hssoc .. [=[
]=]
	else
		hortative = ''
	end

	if imperative ~= 'no' then
		imperative = [=[
|-
!colspan=2]=] .. grey_bg .. [=[|Imperative
|]=] .. (forms.imperative_hrc or "") .. [=[||]=] .. (forms.imperative_hc or "") .. [=[||]=] .. forms.imperative_hyc .. [=[||]=] .. forms.imperative_hssoc .. [=[
]=]
	else
		imperative = ''
	end

	if honorific ~= 'no' then
		honforms.ind_hrc = stem3 .. '신다'
		honforms.ind_hrc_past = stem3 .. '셨다'
		honforms.ind_hc = stem3 .. '셔'
		honforms.ind_hc_past = stem3 .. '셨어'
		honforms.ind_hyc = stem3 .. '세요'
		honforms.ind_hyc_alt = stem3 .. '셔요'
		honforms.ind_hyc_past = stem3 .. '셨어요'
		honforms.ind_hsc = stem3 .. '십니다'
		honforms.ind_hsc_past = stem3 .. '셨습니다'
		honforms.interrog_hrc = stem3 .. '시느냐'
		honforms.interrog_hrc_past = stem3 .. '셨느냐'
		honforms.interrog_hc = stem3 .. '셔'
		honforms.interrog_hc_past = stem3 .. '셨어'
		honforms.interrog_hyc = stem3 .. '세요'
		honforms.interrog_hyc_alt = stem3 .. '셔요'
		honforms.interrog_hyc_past = stem3 .. '셨어요'
		honforms.interrog_hsc = stem3 .. '십니까'
		honforms.interrog_hsc_past = stem3 .. '셨습니까'
		honforms.assert_hrc = stem3 .. '시겠다'
		honforms.assert_hc = stem3 .. '시겠어'
		honforms.assert_hyc = stem3 .. '시겠어요'
		honforms.assert_hsc = stem3 .. '시겠습니다'
		honforms.cause_hrc = stem3 .. '셔'
		honforms.cause_hc = stem3 .. '셔서'
		honforms.cause_hyc = stem3 .. '시니'
		honforms.cause_hsc = stem3 .. '시니까'
		honforms.contrast_hrc = stem3 .. '시지만'
		honforms.contrast_hc = stem3 .. '시는데'
		honforms.contrast_hyc = stem3 .. '시더니'
		honforms.conjunction = stem3 .. '시고'
		honforms.condition_hrc = stem3 .. '시면'
		honforms.condition_hc = stem3 .. '셔야'
		honforms.motive = stem3 .. '시려고'
		honforms.vn_um = stem3 .. '심'
		honforms.vn_gi = stem3 .. '시기'
		honforms.vn_um_past = stem3 .. '셨음'
		honforms.vn_gi_past = stem3 .. '셨기'
		honforms.determ_past = stem3 .. '신'
		honforms.determ_pres = stem3 .. '시는'
		honforms.determ_fut = stem3 .. '실'
		
		if honimperative ~= 'no' then
			honforms.imperative_hrc = stem3 .. '시라'
			honforms.imperative_hc = stem3 .. '셔'
			honforms.imperative_hyc = stem3 .. '세요'
			honforms.imperative_hyc_alt = stem3 .. '셔요'
			honforms.imperative_hsc = stem3 .. '십시오'
		end
		
		honforms.ind_hyc = honforms.ind_hyc .. ", " .. honforms.ind_hyc_alt
		honforms.interrog_hyc = honforms.interrog_hyc .. ", " .. honforms.interrog_hyc_alt
		
		for honkey, honform in pairs(honforms) do
			if honforms[honkey] ~= '' then
				honforms[honkey] = format_Korean(honform, phonetic and replace(honform, stem1, phonetic) or honform)
			end
		end

		if honimperative ~= 'no' then	
			honimperative = [=[
|-
!colspan=2]=] .. grey_bg .. [=[|Imperative
|]=] .. honforms.imperative_hrc .. [=[||]=] .. honforms.imperative_hc .. [=[||]=] .. honforms.imperative_hyc .. [=[||]=] .. honforms.imperative_hsc .. [=[ 
]=]
		else
			honimperative = ''
		end
		
		honorific = [=[
{| border="1" color="#cdcdcd" style="border-collapse:collapse; border:1px solid #555555; background:#F7F0F0; width:100%; text-align:center" class="inflection-table" cellpadding="5"
|- 
!colspan="100%" align="center" style="background:#C0C0C0" |'''Sentence-final forms with honorific''']=] .. (honorific_note or "") .. [=[ 
|-]=] .. grey_bg.. [=[ 
|colspan=2|
!Formal non-polite<br />(]=] .. format_Korean("[[해라체]]") ..[=[)
!Informal non-polite<br />(]=] .. format_Korean("[[해체]]") ..[=[)
!Informal polite<br />(]=] .. format_Korean("[[해요체]]") ..[=[)
!Formal polite<br />(]=] .. format_Korean("[[하십시오체]]") ..[=[)
|-
!rowspan=2]=] .. grey_bg .. [=[|Indicative
!]=] .. grey_bg .. [=[|Non-past
|]=] .. honforms.ind_hrc .. [=[ 
|]=] .. honforms.ind_hc .. [=[ 
|]=] .. honforms.ind_hyc .. [=[ 
|]=] .. honforms.ind_hsc .. [=[ 
|-
!]=] .. grey_bg .. [=[|Past
|]=] .. honforms.ind_hrc_past .. [=[ 
|]=] .. honforms.ind_hc_past .. [=[ 
|]=] .. honforms.ind_hyc_past .. [=[ 
|]=] .. honforms.ind_hsc_past .. [=[ 
|-
!rowspan=2]=] .. grey_bg .. [=[|Interrogative
!]=] .. grey_bg .. [=[|Non-past
|]=] .. honforms.interrog_hrc .. [=[ 
|]=] .. honforms.interrog_hc .. [=[ 
|]=] .. honforms.interrog_hyc .. [=[ 
|]=] .. honforms.interrog_hsc .. [=[ 
|-
!]=] .. grey_bg .. [=[|Past
|]=] .. honforms.interrog_hrc_past .. [=[ 
|]=] .. honforms.interrog_hc_past .. [=[ 
|]=] .. honforms.interrog_hyc_past .. [=[ 
|]=] .. honforms.interrog_hsc_past .. [=[ 
|-]=] .. honimperative .. [=[ 
|-
!colspan=2]=] .. grey_bg .. [=[|Assertive
|]=] .. honforms.assert_hrc .. [=[||]=] .. honforms.assert_hc .. [=[||]=] .. honforms.assert_hyc .. [=[||]=] .. honforms.assert_hsc .. [=[ 
|-
!colspan="100%" align="center" style="background:#C0C0C0" |'''Connective forms with honorific'''
|- 
!colspan=2]=] .. grey_bg .. [=[|Cause/Reason
|]=] .. honforms.cause_hrc .. [=[||]=] .. honforms.cause_hc .. [=[||]=] .. honforms.cause_hyc .. [=[||]=] .. honforms.cause_hsc .. [=[ 
|- 
!colspan=2]=] .. grey_bg .. [=[|Contrast
|]=] .. honforms.contrast_hrc .. [=[||]=] .. honforms.contrast_hc .. [=[||]=] .. honforms.contrast_hyc .. [=[||
|-
!colspan=2]=] .. grey_bg .. [=[|Conjunction
|]=] .. honforms.conjunction .. [=[|| || ||
|-
!colspan=2]=] .. grey_bg .. [=[|Condition
|]=] .. honforms.condition_hrc .. [=[||]=] .. honforms.condition_hc .. [=[|| || 
|-
!colspan=2]=] .. grey_bg .. [=[|Motive
|]=] .. honforms.motive .. [=[|| || ||
|- 
!colspan="100%" align="center" style="background:#C0C0C0" |'''Noun and determiner forms with honorific'''
|-
!colspan="2"]=] .. grey_bg.. [=[| Verbal nouns
|]=] .. honforms.vn_um .. [=[||]=] .. honforms.vn_gi .. [=[ 
|-
!colspan="2"]=] .. grey_bg.. [=[| Past-tense verbal nouns
|]=] .. honforms.vn_um_past .. [=[||]=] .. honforms.vn_gi_past .. [=[ 
|-
!rowspan="3"]=] .. grey_bg.. [=[| Determiners
!]=] .. grey_bg.. [=[|Past
|]=] .. honforms.determ_past .. [=[ 
|-
!]=] .. grey_bg.. [=[|Present
|]=] .. honforms.determ_pres .. [=[ 
|-
!]=] .. grey_bg.. [=[|Future
|]=] .. honforms.determ_fut .. [=[ 
|}]=]
	else
		honorific = honorific_note or "''This word is not usually used with an honorific.''"
	end

	stem_type = consonant_stem and "consonant-stem, " or "vowel-stem, "
	
	conjugation_type = stem_type .. conj_text(irregtype or "", "verbs")

	if mw.title.getCurrentTitle().nsText == '' then
		conjugation_type = conjugation_type .. conj_category(irregtype or "", "verbs")
	end
	
	return [=[
<div class="NavFrame">
<div class="NavHead" style="height:2em">&nbsp; &nbsp; Selected forms of the verb ]=] .. format_Korean(word, phonetic and replace(word, stem1, phonetic) or word, true) .. ": " .. conjugation_type .. [=[</div>
<div class="NavContent">
{| border="1" color="#cdcdcd" style="border-collapse:collapse; border:1px solid #555555; background:#F4F7F0; width:100%; text-align:center" class="inflection-table" cellpadding="5"
|-
!colspan="100%" align="center" style="background:#C0C0C0" |'''Sentence-final forms'''
|-]=] .. grey_bg.. [=[ 
|colspan=2|
!Formal non-polite<br />(]=] .. format_Korean("[[해라체]]") ..[=[)
!Informal non-polite<br />(]=] .. format_Korean("[[해체]]") ..[=[)
!Informal polite<br />(]=] .. format_Korean("[[해요체]]") ..[=[)
!Formal polite<br />(]=] .. format_Korean("[[하십시오체]]") ..[=[)
|-
!rowspan=2]=] .. grey_bg .. [=[|Indicative
!]=] .. grey_bg .. [=[|Non-past
|]=] .. forms.ind_hrc .. [=[ 
|]=] .. forms.ind_hc .. [=[ 
|]=] .. forms.ind_hyc .. [=[ 
|]=] .. forms.ind_hssoc .. [=[ 
|-
!]=] .. grey_bg .. [=[|Past
|]=] .. forms.ind_hrc_past .. [=[ 
|]=] .. forms.ind_hc_past .. [=[ 
|]=] .. forms.ind_hyc_past .. [=[ 
|]=] .. forms.ind_hssoc_past .. [=[ 
|-
!rowspan=2]=] .. grey_bg .. [=[|Interrogative
!]=] .. grey_bg .. [=[|Non-past
|]=] .. forms.interrog_hrc .. [=[ 
|]=] .. forms.interrog_hc .. [=[ 
|]=] .. forms.interrog_hyc .. [=[ 
|]=] .. forms.interrog_hssoc .. [=[ 
|-
!]=] .. grey_bg .. [=[|Past
|]=] .. forms.interrog_hrc_past .. [=[ 
|]=] .. forms.interrog_hc_past .. [=[ 
|]=] .. forms.interrog_hyc_past .. [=[ 
|]=] .. forms.interrog_hssoc_past .. [=[ 
]=] .. hortative .. [=[ 
]=] .. imperative .. [=[ 
|-
!colspan=2]=] .. grey_bg .. [=[|Assertive
|]=] .. forms.assert_hrc .. [=[||]=] .. forms.assert_hc .. [=[||]=] .. forms.assert_hyc .. [=[||]=] .. forms.assert_hssoc .. [=[ 
|-
!colspan="100%" align="center"  style="background:#C0C0C0" |'''Connective forms'''
|-
!colspan=2]=] .. grey_bg .. [=[|Cause/Reason
|]=] .. forms.cause_hrc .. [=[||]=] .. forms.cause_hc .. [=[||]=] .. forms.cause_hyc .. [=[||]=] .. forms.cause_hssoc .. [=[ 
|-
!colspan=2]=] .. grey_bg .. [=[|Contrast
|]=] .. forms.contrast_hrc .. [=[||]=] .. forms.contrast_hc .. [=[||]=] .. forms.contrast_hyc .. [=[||
|-
!colspan=2]=] .. grey_bg .. [=[|Conjunction
|]=] .. forms.conjunction .. [=[|| || ||
|-
!colspan=2]=] .. grey_bg .. [=[|Condition
|]=] .. forms.condition_hrc .. [=[||]=] .. forms.condition_hc .. [=[|| ||
|-
!colspan=2]=] .. grey_bg .. [=[|Motive
|]=] .. forms.motive .. [=[|| || ||
|-
!colspan="100%" align="center" style="background:#C0C0C0" |'''Noun and determiner forms'''
|-
!colspan="2"]=] .. grey_bg.. [=[|Verbal nouns
|]=] .. forms.vn_um .. [=[||]=] .. forms.vn_gi .. [=[ 
|-
!colspan="2"]=] .. grey_bg.. [=[|Past-tense verbal nouns
|]=] .. forms.vn_um_past .. [=[||]=] .. forms.vn_gi_past .. [=[ 
|-
!rowspan="3"]=] .. grey_bg.. [=[|Determiners
!]=] .. grey_bg.. [=[|Past
|]=] .. forms.determ_past .. [=[ 
|-
!]=] .. grey_bg.. [=[|Present
|]=] .. forms.determ_pres .. [=[ 
|-
!]=] .. grey_bg.. [=[|Future
|]=] .. forms.determ_fut .. [=[ 
|}

]=] .. honorific .. [=[ 
</div></div>]=]
end

return export