Module:grc-decl: difference between revisions

From Wiktionary, the free dictionary
Jump to navigation Jump to search
Content deleted Content added
No edit summary
different requirement for nouns
(3 intermediate revisions by the same user not shown)
Line 2,248: Line 2,248:
dialform('GS','3ῶς','sever')
dialform('GS','3ῶς','sever')
dialform('AS','3οῦν','ion')
dialform('AS','3οῦν','ion')
end

local function paramError(i)
if not args[i] then
error('Parameter ' .. i .. ' has not been entered. Irregular adjective declension requires parameters 1-24 to be defined, though any of them can be empty. Irregular noun declension requires parameters 1-12 to be defined.')
end
end
end


inflections['irreg'] = function()
inflections['irreg'] = function()
for i = 1, 12 do
paramError(i)
end
ctable = irreg
ctable = irreg
stem = {args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11],args[12]}
stem = {args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11],args[12]}
Line 2,256: Line 2,265:


inflections['irreg2'] = function() --feminine part of irregular adjectives
inflections['irreg2'] = function() --feminine part of irregular adjectives
for i = 13, 22 do
paramError(i)
end
ctable = irreg
ctable = irreg
stem = {args[13],args[14],args[15],args[16],args[13],args[17],args[18],args[19],args[20],args[21],args[22]}
stem = {args[13],args[14],args[15],args[16],args[13],args[17],args[18],args[19],args[20],args[21],args[22]}
Line 2,261: Line 2,273:


inflections['irreg3'] = function() --neuter part of irregular adjectives
inflections['irreg3'] = function() --neuter part of irregular adjectives
local indices = { 3, 4, 7, 8, 10, 11, 23, 24 }
for _, i in pairs(indices) do
paramError(i)
end
ctable = irreg
ctable = irreg
stem = {args[23],args[3],args[4],args[23],args[23],args[7],args[8],args[24],args[10],args[11],args[24]}
stem = {args[23],args[3],args[4],args[23],args[23],args[7],args[8],args[24],args[10],args[11],args[24]}

Revision as of 04:44, 3 February 2017


This module is the backend to {{grc-decl}} and {{grc-adecl}}. It was created by ObsequiousNewt and then restructured by JohnC5 and Erutuon.

Odds and ends

The module tracks uses of {{grc-decl}} and {{grc-adecl}} in which parameter 1 does not have an accent mark using the tracking template grc-decl/no accent. Irregular and indeclinable paradigms are excluded from this check.

The module adds a breve or macron to mark the length of the monophthongs α, ι, υ (a, i, u) if they do not bear a macron, breve, circumflex, or iota subscript and the length can be deduced from the rules of accent. Thus, {{grc-decl|ἄστρον|ἄστρου}} generates the same forms as {{grc-decl|ᾰ̓́στρον|ᾰ̓́στρου}}. This is done by the mark_implied_length and harmonize_length functions in Module:grc-accent.

Nominative and genitive, masculine and feminine, or masculine and neuter endings containing the monophthongs α, ι, υ (a, i, u) need not be marked with macrons and breves if there is only one declension with the given endings when vowel length is ignored. Thus {{grc-decl|νεανίας|ου}} is fine because the only declension pattern with the endings -ας, -ου (-as, -ou) is -ᾱς, -ου (-ās, -ou), but {{grc-decl|αἰτία|ας}} will throw an error, because both -ᾰ, -ᾱς (-a, -ās) and -ᾱ, -ᾱς (-ā, -ās) are possible. This feature is made possible by Module:grc-decl/decl/staticdata.

Submodules

Module:grc-decl/decl contains functions that determine the declension class, generate the inflected forms, and retrieves the correct forms of the article.

Module:grc-decl/table generates the table using the inflected forms, the forms of the article (if any), and the dialect and |titleapp= parameters.

Module:grc-decl/params contains the lists of parameters used by {{grc-decl}} and {{grc-adecl}}.

Module:grc-decl/decl/data contains functions that return the forms of a given declension type, modifying the raw paradigms or the stems as necessary.

Module:grc-decl/decl/staticdata generates data that is copied to Module:grc-decl/decl/classes and used to determine the declension class based on the nominative and genitive (for nouns) or the masculine and feminine or neuter (for adjectives).

Module:grc-decl/decl/staticdata/paradigms contains raw paradigms for declension classes, as well as any variations with a different accent on the ending.

Module:grc-decl/decl/staticdata/dialects contains data for dialect groups.

Testcases

Lua error in package.lua at line 80: module 'Module:grc:Dialects' not found Lua error in package.lua at line 80: module 'Module:grc:Dialects' not found Lua error in package.lua at line 80: module 'Module:grc:Dialects' not found Lua error in package.lua at line 80: module 'Module:grc:Dialects' not found


local m_links = require('Module:links')
local m_accent = require('Module:grc-accent')
local m_dialects = require('Module:grc:Dialects')

local export = {}

local lang = require('Module:languages').getByCode('grc')

local inflections = {}
local adjinflections = {}
local adjinflections_con = {}

local args
local form -- args.form
local conjtype
local stem -- list of stems ordered by accent
local root -- the single 'root'
local ctable

function export.decl(frame)
	args = {}
	for k,v in pairs(frame:getParent().args) do
		args[k] = v
	end
	form = args['form'] or 'full'
	
	if args[1] ~= 'irreg' then
		conjtype,root = get_decl(args[1],args[2] )
		if conjtype == nil then error('conjtype is nil') end
	elseif form:match('N') then
		conjtype = 'irregN'
		root = ''
	else
		conjtype = 'irreg'
		root = ''
	end
	if mw.ustring.match(conjtype,'ᾰσ') then
		conjtype = mw.ustring.gsub(conjtype,'N-ᾰσ','cons')
		root = root..'ᾰσ'
	end
	
	if mw.ustring.sub(root,1,1) == '-' and not form:match('[MFN]') then form = form..'X' end
	if (not form:match('sing')) and (not form:match('dual')) and (not form:match('plur')) then form = form..'full' end
	--[=[
	[[Special:WhatLinksHere/Template:tracking/grc-decl/manual-breve]]
	[[Special:WhatLinksHere/Template:tracking/grc-decl/dial]]
	[[Special:WhatLinksHere/Template:tracking/grc-decl/dialtilde]]
	[[Special:WhatLinksHere/Template:tracking/grc-decl/titleapp]]
	]=]
	
	if mw.ustring.find(root,'˘') then require('Module:debug').track('grc-decl/manual-breve') end
	if args['dial'] then require('Module:debug').track('grc-decl/dial') end
	if args['dial'] and args['dial']:match('~') then
		require('Module:debug').track('grc-decl/dialtilde')
		args['dial'] = nil
	end
	if args['titleapp'] then require('Module:debug').track('grc-decl/titleapp') end

	if conjtype == '3rd-κλῆς' or mw.ustring.match(conjtype,'εσ') then
		out = ''
		if not form:match('con') then
			swapargs(1)
			args.titleapp = args.titleapp or '(Uncontracted)'
			makeconj(conjtype..'-open',root)
			out = make_table()
		end
		if not form:match('open') then
			swapargs(2)
			args.titleapp = args.titleapp2 or '(Contracted)'
			makeconj(conjtype,root)
			out = out .. make_table()
		end
		return out
	elseif conjtype:match('cons') and mw.ustring.match(root,'ᾰσ$') then
		out = ''
		if not form:match('con') then
			swapargs(1)
			args.titleapp = args.titleapp1 or '(Uncontracted)'
			makeconj(conjtype,mw.ustring.sub(root,1,-2) )
			out = make_table()
		end
		if not form:match('open') then
			swapargs(2)
			args.titleapp = args.titleapp2 or '(Contracted)'
			makeconj('3rd-N-ᾰσ-prx',mw.ustring.sub(root,1,-3) )
			out = out .. make_table()
		end
		return out
	else
		makeconj(conjtype,root)
		return make_table()
	end
end

function makeconj(ct,r)
	root = r
	if not inflections[ct] then
		error('unrecognized inflection type '..ct)
	end
	stem = {m_accent.ult(root),m_accent.penult(root),root}
	if not mw.ustring.match(ct,'prx') then stem[2] = m_accent.circ(root) end
	inflections[ct]()
	addforms()
	
	--set gender
	if form:match('M') then
		ctable.g = 'M'
	elseif form:match('F') then
		ctable.g = 'F'
	elseif form:match('N') then
		ctable.g = 'N'
	end
end

local adjective = false

local adverb,comparative,superlative

local atable = {}

function export.adecl(frame)
	adjective = true
	args = {}
	for k,v in pairs(frame:getParent().args) do
		args[k] = v
	end
	form = args['form'] or ''

	if args[1] ~= 'irreg' then
		conjtype, root = get_decl_adj(args[1],args[2] )
	else
		conjtype = 'irreg'
		root = ''
	end
	if not adjinflections[conjtype] then
		error('unrecognized inflection type '..conjtype)
	end

	if (not form:match('sing')) and (not form:match('dual')) and (not form:match('plur')) then form = form..'full' end

	--[=[
	[[Special:WhatLinksHere/Template:tracking/grc-adecl/manual-breve]]
	[[Special:WhatLinksHere/Template:tracking/grc-adecl/dial]]
	[[Special:WhatLinksHere/Template:tracking/grc-adecl/dialtilde]]
	[[Special:WhatLinksHere/Template:tracking/grc-adecl/titleapp]]
	]=]

	if mw.ustring.find(root,'˘') then require('Module:debug').track('grc-adecl/manual-breve') end
	if args['dial'] then require('Module:debug').track('grc-adecl/dial') end
	if args['dial'] and args['dial']:match('~') then
		require('Module:debug').track('grc-adecl/dialtilde')
		args['dial'] = nil
	end
	if args['titleapp'] then require('Module:debug').track('grc-adecl/titleapp') end

	barestem = root
	
	if adjinflections_con[conjtype] and not form:match('open') then
		out = ''
		if not form:match('con') and (args.dial == 'ion' or args.dial == 'att' or not args.dial) then
			swapargs(1)
			args.titleapp = args.titleapp1 or '(Uncontracted)'
			if conjtype:match('3rd%-εσ%-adj') then
				comparative = barestem .. 'έστερος'
			else
				comparative = barestem .. 'εώτερος' -- I assume—though I can't find examples
			end
			superlative = mw.ustring.sub(comparative,1,-5)..'ᾰτος'

			makeconj_adj(adjinflections[conjtype],barestem)
			out = make_table_adj()
		end
		if not form:match('open') then
			swapargs(2)
			
			if not args.dial then
				args.titleapp = args.titleapp2 or '(Contracted)'
			end
			
			if conjtype:match('3rd%-εσ%-adj') then
				comparative = barestem .. 'έστερος'
			else
				comparative = barestem .. 'εώτερος' -- I assume—though I can't find examples
			end
			superlative = mw.ustring.sub(comparative,1,-5)..'ᾰτος'

			makeconj_adj(adjinflections_con[conjtype],barestem)
			out = out .. make_table_adj()
		end
		return out
	else
		makeconj_adj(adjinflections[conjtype],barestem)
		if (args['comp'] == '') or (conjtype == '1&2-alp-prx' and mw.ustring.sub(root,-3) == 'τερ' and not args['comp'] ) then
			comparative = '('..atable['MNS']..')'
			superlative = mw.ustring.gsub(comparative,'τερος$','τᾰτος')
			adverb = atable['NNS']
			args['comp'] = nil
		elseif (args['super'] == '') or (conjtype == '1&2-alp-prx' and mw.ustring.sub(root,-3) == 'τᾰτ' and not args['super'] ) then
			superlative = '('..atable['MNS']..')'
			comparative = mw.ustring.gsub(superlative,'τᾰτος$','τερος')
			adverb = atable['NNP']
			args['super'] = nil
		elseif conjtype:match('ups') then
			comparative = barestem .. 'ῠ́τερος'
		elseif conjtype == '1&3-οτ' then
			comparative = '-'
			superlative = '-'
		elseif conjtype == '1&3-ᾰν-pax' then
			comparative = barestem .. 'ᾰ́ντερος'
		elseif conjtype == '1&3-εν-pax' then
			comparative = barestem .. 'έντερος'
		elseif conjtype == '1&3-εντ-pax' then
			comparative = barestem .. 'έστερος' -- hopefully this is general?
		elseif mw.ustring.match(conjtype,'ντ') then
			comparative = '-' --participles
			superlative = '-'
		elseif conjtype:match('cons') then
			if mw.ustring.match(root,'ον$') then
				comparative = barestem .. 'έστερος'
			elseif mw.ustring.match(barestem,'εσ$') then
				comparative = mw.ustring.sub(barestem,1,-3)..'έστερος'
			else
				comparative = '-' --not really regular afaict
				superlative = '-'
			end
		elseif ((m_accent.circ(barestem) == m_accent.ult(barestem)) or conjtype:match('att')) and not args.hp then
			comparative = barestem .. 'ώτερος'
		else
			comparative = barestem .. 'ότερος'
		end
		adverb = args['adv'] or adverb
		comparative = args['comp'] or comparative
		superlative = args['super'] or superlative or (comparative and mw.ustring.gsub(comparative,'ερος$','ᾰτος'))
		return make_table_adj()
	end
end

function makeconj_adj(ct,barestem)
	makeconj(ct[1],barestem..(ct['a1'] or '') )
	for k,v in pairs(ctable) do atable['M'..k] = v end
	if ct[2] then
		makeconj(ct[2],args.fstem or (barestem..(ct['a2'] or '') ) )
		for k,v in pairs(ctable) do atable['F'..k] = v end
	end
	makeconj(ct[3],barestem..(ct['a1'] or '') )
	for k,v in pairs(ctable) do atable['N'..k] = v end
end

function swapargs(suffix)
	--This function has undefined behaviour if both <arg> and <arg><suffix> are
	--specified; use e.g. <arg>1 and <arg>2 instead.
	args_ = args
	args = {}
	for code,value in pairs(args_) do
		if type(code) == 'number' then
			args[code] = value
		else
			args[mw.ustring.gsub(code,suffix..'$','')] = value
		end
	end
end

function addforms()
	--add stem to forms
	for k,v in pairs(ctable) do
		if conjtype:match('irreg') and type(ctable[k] ) == 'number' then
			ctable[k] = args[k] or stem[ctable[k]]
		else
			-- concat stem to suffix
			for i,j in pairs(stem) do
				ctable[k] = mw.ustring.gsub(ctable[k],i,j)
			end
		end
		if args.dial == 'les' then
			ctable[k] = m_accent.antepenult(m_accent.strip_tone(ctable[k]))
		end
	end
end

adjinflections['1&2-alp'] = {'2nd','1st-alp','2nd-N'}
adjinflections['1&2-alp-pax'] = {'2nd-pax','1st-alp-pax','2nd-N-pax'}
adjinflections['1&2-alp-prx'] = {'2nd-prx','1st-alp-pax','2nd-N-prx'}
adjinflections['1&2-alp-con-con'] = {'2nd-prx','1st-alp-pax','2nd-N-prx',a1='ε',a2='ε'} -- avoid collisions
adjinflections['1&2-eta'] = {'2nd','1st-eta','2nd-N'}
adjinflections['1&2-eta-pax'] = {'2nd-pax','1st-eta-pax','2nd-N-pax'}
adjinflections['1&2-eta-prx'] = {'2nd-prx','1st-eta-pax','2nd-N-prx'}
adjinflections['1&2-eta-con-con'] = {'2nd-prx','1st-alp-pax','2nd-N-prx',a1='ε',a2='ε'}
adjinflections['1&3-ups'] = {'3rd-weak-υ','1st-als-pax','3rd-N-weak-υ',a2='ει'}
adjinflections['1&3-ups-prx'] = {'3rd-weak-υ-prx','1st-als-prx','3rd-N-weak-υ-prx',a2='ει'}
adjinflections['1&3-ups-pax'] = adjinflections['1&3-ups-prx']
adjinflections['1&3-ᾰν-pax'] = {'3rd-cons-prx','1st-ets-prx','3rd-N-cons-prx',a1='ᾰν',a2='αιν'}
adjinflections['1&3-εν-pax'] = {'3rd-cons-prx','1st-ets-prx','3rd-N-cons-prx',a1='εν',a2='ειν'}
adjinflections['1&3-εντ-pax'] = {'3rd-cons-pax','1st-ets-prx','3rd-N-cons-pax',a1='εντ',a2='εσσ'}
adjinflections['1&3-ουντ'] = {'3rd-cons','1st-ets-pax','3rd-N-cons',a1='οντ',a2='ουσ'}
-- <participles> --
adjinflections['1&3-οτ'] = {'3rd-cons','1st-als-pax','3rd-N-cons',a1='οτ',a2='υι'}					-- perfect active
adjinflections['1&3-εντ'] = {'3rd-cons','1st-ets-pax','3rd-N-cons',a1='εντ',a2='εισ'}				-- *h₁ and aorist passive
adjinflections['1&3-ᾰντ'] = {'3rd-cons','1st-ets-pax','3rd-N-cons',a1='ᾰντ',a2='ᾱσ'}				-- *h₂
adjinflections['1&3-ᾰντ-pax'] = {'3rd-cons-pax','1st-ets-prx','3rd-N-cons-pax',a1='ᾰντ',a2='ᾱσ'}	-- 1st aorist active
adjinflections['1&3-οντ'] = {'3rd-cons','1st-ets-pax','3rd-N-cons',a1='οντ',a2='ουσ'}				-- *h₃
adjinflections['1&3-οντ-con'] = {'3rd-cons','1st-ets-pax','3rd-N-cons',a1='ουντ',a2='ουσ'}			-- έω/όω contract
adjinflections['1&3-οντ-pax'] = {'3rd-cons-pax','1st-ets-prx','3rd-N-cons-pax',a1='οντ',a2='ουσ'}	-- thematic active
adjinflections['1&3-ῠντ'] = {'3rd-cons','1st-ets-pax','3rd-N-cons',a1='ῠντ',a2='ῡσ'}				-- νῡμι active
adjinflections['1&3-ωντ-con'] = {'3rd-cons','1st-ets-pax','3rd-N-cons',a1='ωντ',a2='ωσ'}			-- άω contract
-- </participles> --
adjinflections['2nd'] = {'2nd',nil,'2nd-N'}
adjinflections['2nd-pax'] = {'2nd-pax',nil,'2nd-N-pax'}
adjinflections['2nd-prx'] = {'2nd-prx',nil,'2nd-N-prx'}
adjinflections['2nd-att-prx'] = {'2nd-att-prx',nil,'2nd-N-att-prx'}
adjinflections['3rd-cons'] = {'3rd-cons',nil,'3rd-N-cons'}
adjinflections['3rd-cons-pax'] = {'3rd-cons-pax',nil,'3rd-N-cons-pax'}
adjinflections['3rd-cons-prx'] = {'3rd-cons-prx',nil,'3rd-N-cons-prx'}
adjinflections['3rd-εσ-adj'] = {'3rd-εσ-adj-open',nil,'3rd-N-εσ-adj-open'}
adjinflections['3rd-εσ-adj-prx'] = {'3rd-εσ-adj-prx-open',nil,'3rd-N-εσ-adj-prx-open'}
adjinflections['irreg'] = {'irreg','irreg2','irreg3'}
adjinflections['irreg-2pt'] = {'irreg',nil,'irreg3'}

adjinflections_con['1&2-alp-con-con'] = {'2nd-con','1st-alp-con','2nd-N-con'}
adjinflections_con['1&2-eta-con-con'] = {'2nd-con','1st-eta-con','2nd-N-con'}
adjinflections_con['3rd-εσ-adj'] = {'3rd-εσ-adj',nil,'3rd-N-εσ-adj'}
adjinflections_con['3rd-εσ-adj-prx'] = {'3rd-εσ-adj-prx',nil,'3rd-N-εσ-adj-prx'}

local declfirst = '[[Appendix:Ancient Greek first declension|First declension]]'
local declsecond = '[[Appendix:Ancient Greek second declension|Second declension]]'
local declthird = '[[Appendix:Ancient Greek third declension|Third declension]]'
local declatt = '[[Appendix:Ancient Greek Attic declension|Attic second declension]]'
local declirreg = 'Irregular declension'
local decldecl = 'Declension'

art_att_M = {
['decl']=declirreg,
['NS']='ὁ',
['GS']='τοῦ',
['DS']='τῷ',
['AS']='τὸν',
['ND']='τὼ',
['GD']='τοῖν',
['DD']='τοῖν',
['AD']='τὼ',
['NP']='οἱ',
['GP']='τῶν',
['DP']='τοῖς',
['AP']='τοὺς',
}

art_att_F = {
['decl']=declirreg,
['NS']='ἡ',
['GS']='τῆς',
['DS']='τῇ',
['AS']='τὴν',
['ND']='τὼ',
['GD']='τοῖν',
['DD']='τοῖν',
['AD']='τὼ',
['NP']='αἱ',
['GP']='τῶν',
['DP']='ταῖς',
['AP']='τᾱ̀ς',
}

art_att_N = {
['decl']=declirreg,
['NS']='τὸ',
['GS']='τοῦ',
['DS']='τῷ',
['AS']='τὸ',
['ND']='τὼ',
['GD']='τοῖν',
['DD']='τοῖν',
['AD']='τὼ',
['NP']='τᾰ̀',
['GP']='τῶν',
['DP']='τοῖς',
['AP']='τᾰ̀',
}

alp_pax = {
['decl']=declfirst,
['g']='F',
['NS']='1ᾱ',
['GS']='1ᾱς',
['DS']='1ᾳ',
['AS']='1ᾱν',
['ND']='1ᾱ',
['GD']='1αιν',
['NP']='2αι',
['GP']='3ῶν',
['DP']='1αις',
['AP']='1ᾱς',
}
eta_pax = {
['decl']=declfirst,
['g']='F',
['NS']='1η',
['GS']='1ης',
['DS']='1ῃ',
['AS']='1ην',
['ND']='1ᾱ',
['GD']='1αιν',
['NP']='2αι',
['GP']='3ῶν',
['DP']='1αις',
['AP']='1ᾱς',
}
alp = {
['decl']=declfirst,
['g']='F',
['NS']='3ᾱ́',
['GS']='3ᾶς',
['DS']='3ᾷ',
['AS']='3ᾱ́ν',
['ND']='3ᾱ́',
['GD']='3αῖν',
['NP']='3αί',
['GP']='3ῶν',
['DP']='3αῖς',
['AP']='3ᾱ́ς',
}
eta = {
['decl']=declfirst,
['g']='F',
['NS']='3ή',
['GS']='3ῆς',
['DS']='3ῇ',
['AS']='3ήν',
['ND']='3ᾱ́',
['GD']='3αῖν',
['NP']='3αί',
['GP']='3ῶν',
['DP']='3αῖς',
['AP']='3ᾱ́ς',
}
als_prx = {
['decl']=declfirst,
['g']='F',
['NS']='2ᾰ',
['GS']='1ᾱς',
['DS']='1ᾳ',
['AS']='2ᾰν',
['ND']='1ᾱ',
['GD']='1αιν',
['NP']='2αι',
['GP']='3ῶν',
['DP']='1αις',
['AP']='1ᾱς',
}
ets_prx = {
['decl']=declfirst,
['g']='F',
['NS']='2ᾰ',
['GS']='1ης',
['DS']='1ῃ',
['AS']='2ᾰν',
['ND']='1ᾱ',
['GD']='1αιν',
['NP']='2αι',
['GP']='3ῶν',
['DP']='1αις',
['AP']='1ᾱς',
}
alp_con = {
['decl']=declfirst,
['g']='F',
['NS']='3ᾶ',
['GS']='3ᾶς',
['DS']='3ᾷ',
['AS']='3ᾶν',
['ND']='3ᾶ',
['GD']='3αῖν',
['NP']='3αῖ',
['GP']='3ῶν',
['DP']='3αῖς',
['AP']='3ᾶς',
}
eta_con = {
['decl']=declfirst,
['g']='F',
['NS']='3ῆ',
['GS']='3ῆς',
['DS']='3ῇ',
['AS']='3ῆν',
['ND']='3ᾶ',
['GD']='3αῖν',
['NP']='3αῖ',
['GP']='3ῶν',
['DP']='3αῖς',
['AP']='3ᾶς',
}
M_alp_pax = {
['decl']=declfirst,
['g']='M',
['NS']='1ᾱς',
['GS']='1ου',
['DS']='1ᾳ',
['AS']='1ᾱν',
['ND']='1ᾱ',
['GD']='1αιν',
['NP']='2αι',
['GP']='3ῶν',
['DP']='1αις',
['AP']='1ᾱς',
}
M_eta_pax = {
['decl']=declfirst,
['g']='M',
['NS']='1ης',
['GS']='1ου',
['DS']='1ῃ',
['AS']='1ην',
['ND']='1ᾱ',
['GD']='1αιν',
['NP']='2αι',
['GP']='3ῶν',
['DP']='1αις',
['AP']='1ᾱς',
}
M_eta = {
['decl']=declfirst,
['g']='M',
['NS']='3ής',
['GS']='3οῦ',
['DS']='3ῇ',
['AS']='3ήν',
['ND']='3ᾱ́',
['GD']='3αῖν',
['NP']='3αί',
['GP']='3ῶν',
['DP']='3αῖς',
['AP']='3ᾱ́ς',
}
M_alp_con = {
['decl']=declfirst,
['g']='M',
['NS']='3ᾶς',
['GS']='3ᾶ',
['DS']='3ᾷ',
['AS']='3ᾶν',
['ND']='3ᾶ',
['GD']='3αῖν',
['NP']='3αῖ',
['GP']='3ῶν',
['DP']='3αῖς',
['AP']='3ᾶς',
}
M_eta_con = {
['decl']=declfirst,
['g']='M',
['NS']='3ῆς',
['GS']='3οῦ',
['DS']='3ῇ',
['AS']='3ῆν',
['ND']='3ᾶ',
['GD']='3αῖν',
['NP']='3αῖ',
['GP']='3ῶν',
['DP']='3αῖς',
['AP']='3ᾶς',
}
second_prx = {
['decl']=declsecond,
['g']='M',
['NS']='2ος',
['GS']='1ου',
['DS']='1ῳ',
['AS']='2ον',
['VS']='2ε',
['ND']='1ω',
['GD']='1οιν',
['NP']='2οι',
['GP']='1ων',
['DP']='1οις',
['AP']='1ους',
}
second = {
['decl']=declsecond,
['g']='M',
['NS']='3ός',
['GS']='3οῦ',
['DS']='3ῷ',
['AS']='3όν',
['VS']='3έ',
['ND']='3ώ',
['GD']='3οῖν',
['NP']='3οί',
['GP']='3ῶν',
['DP']='3οῖς',
['AP']='3ούς',
}
second_N_prx = {
['decl']=declsecond,
['g']='N',
['NS']='2ον',
['GS']='1ου',
['DS']='1ῳ',
['ND']='1ω',
['GD']='1οιν',
['NP']='2ᾰ',
['GP']='1ων',
['DP']='1οις',
}
second_N = {
['decl']=declsecond,
['g']='N',
['NS']='3όν',
['GS']='3οῦ',
['DS']='3ῷ',
['ND']='3ώ',
['GD']='3οῖν',
['NP']='3ᾰ́',
['GP']='3ῶν',
['DP']='3οῖς',
}
second_con = {
['decl']=declsecond,
['g']='M',
['NS']='3οῦς',
['GS']='3οῦ',
['DS']='3ῷ',
['AS']='3οῦν',
['VS']='3οῦ',
['ND']='3ώ',
['GD']='3οῖν',
['NP']='3οῖ',
['GP']='3ῶν',
['DP']='3οῖς',
['AP']='3οῦς',
}
second_con_pax = {
['decl']=declsecond,
['g']='M',
['NS']='1ους',
['GS']='1ου',
['DS']='1ῳ',
['AS']='1ουν',
['VS']='1ου',
['ND']='1ω',
['GD']='1οιν',
['NP']='1οι',
['GP']='1ων',
['DP']='1οις',
['AP']='1ους',
}
second_N_con = {
['decl']=declsecond,
['g']='N',
['NS']='3οῦν',
['GS']='3οῦ',
['DS']='3ῷ',
['ND']='3ώ',
['GD']='3οῖν',
['NP']='3ᾶ',
['GP']='3ῶν',
['DP']='3οῖς',
}
second_att = {
['decl']=declatt,
['g']='M',
['NS']='3ώς',
['GS']='3ώ',
['DS']='3ῴ',
['AS']='3ώ(ν)',
['ND']='3ώ',
['GD']='3ῴν',
['NP']='3ῴ',
['GP']='3ών',
['DP']='3ῴς',
['AP']='3ώς',
}
second_att_prx = {
['decl']=declatt,
['g']='M',
['NS']='1ως',
['GS']='1ω',
['DS']='1ῳ',
['AS']='1ω(ν)',
['ND']='1ω',
['GD']='1ῳν',
['NP']='1ῳ',
['GP']='1ων',
['DP']='1ῳς',
['AP']='1ως',
}
second_N_att_prx = {
['decl']=declatt,
['g']='M',
['NS']='1ων',
['GS']='1ω',
['DS']='1ῳ',
['ND']='1ω',
['GD']='1ῳν',
['NP']='1ᾰ',
['GP']='1ων',
['DP']='1ῳς',
}
second_att_con = {
['decl']=declatt,
['g']='M',
['NS']='3ῶς',
['GS']='3ῶ',
['DS']='3ῷ',
['AS']='3ῶ(ν)',
['ND']='3ῶ',
['GD']='3ῷν',
['NP']='3ῷ',
['GP']='3ῶν',
['DP']='3ῷς',
['AP']='3ῶς',
}
lp = {
['decl']=declthird,
['GS']='3ός',
['DS']='3ῐ́',
['AS']='2ᾰ',
['ND']='2ε',
['GD']='3οῖν',
['NP']='2ες',
['GP']='3ῶν',
['AP']='2ᾰς',
}
lp_prx = {
['decl']=declthird,
['GS']='2ος',
['DS']='2ῐ',
['AS']='2ᾰ',
['ND']='2ε',
['GD']='1οιν',
['NP']='2ες',
['GP']='1ων',
['AP']='2ᾰς',
}
es_adj = {
['decl']=declthird,
['NS']='3ής',
['GS']='3οῦς',
['DS']='3εῖ',
['AS']='3ῆ',
['VS']='3ές',
['ND']='3εῖ',
['GD']='3οῖν',
['NP']='3εῖς',
['GP']='3ῶν',
['DP']='3έσῐ(ν)',
['AP']='3εῖς',
}
es_adj_prx = {
['decl']=declthird,
['NS']='1ης',
['GS']='1ους',
['DS']='1ει',
['AS']='1η',
['VS']='2ες',
['ND']='1ει',
['GD']='1οιν',
['NP']='1εις',
['GP']='1ων',
['DP']='1εσῐ(ν)',
['AP']='1εις',
}
es_adj_open = {
['decl']=declthird,
['NS']='3ής',
['GS']='3έος',
['DS']='3έῐ̈',
['AS']='3έᾰ',
['VS']='3ές',
['ND']='3έε',
['GD']='3έοιν',
['NP']='3έες',
['GP']='3έων',
['DP']='3έσῐ(ν)',
['AP']='3έες',
}
es_adj_prx_open = {
['decl']=declthird,
['NS']='1ης',
['GS']='1εος',
['DS']='1εῐ̈',
['AS']='1εᾰ',
['VS']='2ες',
['ND']='1εε',
['GD']='1εοιν',
['NP']='1εες',
['GP']='1εων',
['DP']='1εσῐ(ν)',
['AP']='1εες',
}
N_lp = {
['decl']=declthird,
['g']='N',
['GS']='3ός',
['DS']='3ῐ́',
['ND']='2ε',
['GD']='3οῖν',
['NP']='2ᾰ',
['GP']='3ῶν',
}
N_lp_prx = {
['decl']=declthird,
['g']='N',
['GS']='2ος',
['DS']='2ῐ',
['ND']='2ε',
['GD']='1οιν',
['NP']='2ᾰ',
['GP']='1ων',
}
N_es_adj = {
['decl']=declthird,
['g']='N',
['NS']='3ές',
['GS']='3οῦς',
['DS']='3εῖ',
['ND']='3εῖ',
['GD']='3οῖν',
['NP']='3ῆ',
['GP']='3ῶν',
['DP']='3έσῐ(ν)',
}
N_es_adj_prx = {
['decl']=declthird,
['g']='N',
['NS']='2ες',
['GS']='1ους',
['DS']='1ει',
['ND']='1ει',
['GD']='1οιν',
['NP']='1η',
['GP']='1ων',
['DP']='1εσῐ(ν)',
}
N_es_prx = {
['decl']=declthird,
['g']='N',
['NS']='2ος',
['GS']='1ους',
['DS']='1ει',
['ND']='1ει',
['GD']='3οῖν',
['NP']='1η',
['GP']='3ῶν',
['DP']='1εσῐ(ν)',
}
N_as_prx = {
['decl']=declthird,
['g']='N',
['NS']='2ᾰς',
['GS']='1ως',
['DS']='1αι/1ᾳ',
['ND']='1ᾱ',
['GD']='3ῷν',
['NP']='1ᾱ',
['GP']='3ῶν',
['DP']='1ᾰσῐ(ν)',
}
N_es_adj_open = {
['decl']=declthird,
['g']='N',
['NS']='3ές',
['GS']='3έος',
['DS']='3έῐ̈',
['ND']='3έε',
['GD']='3έοιν',
['NP']='3έᾰ',
['GP']='3έων',
['DP']='3έσῐ(ν)',
}
N_es_adj_prx_open = {
['decl']=declthird,
['g']='N',
['NS']='2ες',
['GS']='1εος',
['DS']='1εῐ̈',
['ND']='1εε',
['GD']='1εοιν',
['NP']='1εᾰ',
['GP']='1εων',
['DP']='1εσῐ(ν)',
}
N_es_prx_open = {
['decl']=declthird,
['g']='N',
['NS']='2ος',
['GS']='1εος',
['DS']='1εῐ̈',
['ND']='1εε',
['GD']='3έοιν',
['NP']='1εᾰ',
['GP']='3έων',
['DP']='1εσῐ(ν)',
}
kles = {
['decl']=declthird,
['g']='M',
['NS']='3κλῆς',
['GS']='3κλέους',
['DS']='3κλεῖ',
['AS']='3κλέᾱ',
['VS']='1κλεις',
}
kles_open = {
['decl']=declthird,
['g']='M',
['NS']='3κλέης',
['GS']='3κλέους',
['DS']='3κλέει',
['AS']='3κλέᾱ',
['VS']='1κλεες',
}
weak_i_prx = {
['decl']=declthird,
['NS']='2ῐς',
['GS']='1εως',
['DS']='1ει/1εῐ̈',
['AS']='2ῐν',
['VS']='2ῐ',
['ND']='1ει/1εε',
['GD']='3έοιν',
['NP']='1εις/2εες',
['GP']='1εων',
['DP']='1εσῐ(ν)',
['AP']='1εις',
}
weak_u = {
['decl']=declthird,
['NS']='3ῠ́ς',
['GS']='3έως',
['DS']='3εῖ/3έῐ̈',
['AS']='3ῠ́ν',
['VS']='3ῠ́',
['ND']='3έε',
['GD']='3έοιν',
['NP']='3εῖς/3έες',
['GP']='3έων',
['DP']='3έσῐ(ν)',
['AP']='3εῖς',
}
weak_u_prx = {
['decl']=declthird,
['NS']='2ῠς',
['GS']='1εως',
['DS']='1ει/1εῐ̈',
['AS']='2ῠν',
['VS']='2ῠ',
['ND']='1ει/1εε',
['GD']='3έοιν',
['NP']='1εις/1εες',
['GP']='1εων',
['DP']='1εσῐ(ν)',
['AP']='1εις',
}
N_weak_i_prx = {
['decl']=declthird,
['g']='N',
['NS']='2ῐ',
['GS']='1εως',
['DS']='1ει/1εῐ̈',
['ND']='1ει/1εε',
['GD']='3έοιν',
['NP']='1η/1εᾰ',
['GP']='1εων',
['DP']='1εσῐ(ν)',
}
N_weak_u = {
['decl']=declthird,
['g']='N',
['NS']='3ῠ́',
['GS']='3έως',
['DS']='3εῖ/2έῐ̈',
['ND']='3εῖ/2έε',
['GD']='3έοιν',
['NP']='3έᾰ',
['GP']='3έων',
['DP']='3έσῐ(ν)',
}
N_weak_u_prx = {
['decl']=declthird,
['g']='N',
['NS']='2ῠ',
['GS']='1εως',
['DS']='1ει/1εῐ̈',
['ND']='1ει/1εε',
['GD']='3έοιν',
['NP']='1η/1εᾰ',
['GP']='1εων',
['DP']='1εσῐ(ν)',
}
pure_i_prx = {
['decl']=declthird,
['NS']='2ῐς',
['GS']='1ῐος',
['DS']='1ῑ',
['AS']='2ῐν',
['VS']='2ῐ',
['ND']='1ῐε',
['GD']='3ῐ́οιν',
['NP']='1ῐες',
['GP']='3ῐ́ων',
['DP']='1ῐσῐ(ν)',
['AP']='1ῑς/1ῐᾰς',
}
N_pure_i_prx = {
['decl']=declthird,
['g']='N',
['NS']='2ῐ',
['GS']='1ῐος',
['DS']='1ῑ',
['ND']='1ῐε',
['GD']='3ῐ́οιν',
['NP']='1ῐες',
['GP']='3ῐ́ων',
['DP']='1ῐσῐ(ν)',
}
pure_u_prx = {
['decl']=declthird,
['NS']='2ῠς',
['GS']='1ῠος',
['DS']='1ῠῐ̈/1υι',
['AS']='2ῠν',
['VS']='2ῠ',
['ND']='1ῠε',
['GD']='3ῠ́οιν',
['NP']='1ῠες',
['GP']='3ῠ́ων',
['DP']='1ῠσῐ(ν)',
['AP']='1ῡς/1ῠᾰς',
}
pure_u_long_prx = {
['decl']=declthird,
['NS']='1ῡς',
['GS']='1ῠος',
['DS']='1ῠῐ̈/1υι',
['AS']='1ῡν',
['VS']='1ῡ',
['ND']='1ῠε',
['GD']='3ῠ́οιν',
['NP']='1ῠες',
['GP']='3ῠ́ων',
['DP']='1ῠσῐ(ν)',
['AP']='1ῡς/1ῠᾰς',
}
pure_u_long = {
['decl']=declthird,
['NS']='3ῡ́ς',
['GS']='3ῠ́ος',
['DS']='3ῠ́ῐ̈',
['AS']='3ῡ́ν',
['VS']='3ῡ́',
['ND']='3ῠ́ε',
['GD']='3ῠ́οιν',
['NP']='3ῠ́ες',
['GP']='3ῠ́ων',
['DP']='3ῠσῐ(ν)',
['AP']='3ῦς/3ῠ́ᾰς',
}
pure_u = {
['decl']=declthird,
['NS']='3ῠ́ς',
['GS']='3ῠός',
['DS']='3ῠῐ̈́',
['AS']='3ῠ́ν',
['VS']='3ῠ́',
['ND']='3ῠ́ε',
['GD']='3ῠοῖν',
['NP']='3ῠ́ες',
['GP']='3ῠῶν',
['DP']='3ῠσῐ́(ν)',
['AP']='3ῦς/3ῠ́ᾰς',
}
N_pure_u_prx = {
['decl']=declthird,
['g']='N',
['NS']='2ῠ',
['GS']='1ῠος',
['DS']='1ῠῐ̈',
['ND']='1ῠε',
['GD']='3ῠ́οιν',
['NP']='1ῠᾰ',
['GP']='3ῠ́ων',
['DP']='1ῠσῐ(ν)',
}
eus = {
['decl']=declthird,
['g']='M',
['NS']='3εύς',
['GS']='3έως',
['DS']='3έῐ̈/3εῖ',
['AS']='3έᾱ',
['VS']='3εῦ',
['ND']='3ῆ',
['GD']='3έοιν',
['NP']='3ῆς',
['GP']='3έων',
['DP']='3εῦσῐ(ν)',
['AP']='3έᾱς',
}
eus_hwos = {
['decl']=declthird,
['g']='M',
['NS']='3εύς',
['GS']='3ῆϝος',
['DS']='3ῆϝῐ',
['AS']='3ῆϝᾰ',
['VS']='3εῦ',
['ND']='3ῆϝε',
['GD']='3ήϝοιν',
['NP']='3ῆϝες',
['GP']='3ήϝων',
['DP']='3εῦσῐ',
['AP']='3ῆϝᾰς',
}
eus_hos = {
['decl']=declthird,
['g']='M',
['NS']='3εύς',
['GS']='3ῆος',
['DS']='3ῆῐ̈',
['AS']='3ῆᾰ',
['VS']='3εῦ',
['ND']='3ῆε',
['GD']='3ήοιν',
['NP']='3ῆες',
['GP']='3ήων',
['DP']='3εῦσῐ',
['AP']='3ῆᾰς',
}
eus_eios = {
['decl']=declthird,
['g']='M',
['NS']='3εύς',
['GS']='3εῖος',
['DS']='3εῖῐ̈',
['AS']='3εῖᾰ',
['VS']='3εῦ',
['ND']='3εῖε',
['GD']='3είοιν',
['NP']='3εῖες',
['GP']='3είων',
['DP']='3εῦσῐ',
['AP']='3εῖᾰς',
}
oi = {
['decl']=declthird,
['g']='F',
['NS']='3ώ',
['GS']='3οῦς',
['DS']='3οῖ',
['AS']='3ώ',
['VS']='3οῖ',
}
irreg = {
['decl']=declirreg,
['NS']=1,
['GS']=2,
['DS']=3,
['AS']=4,
['VS']=5,
['ND']=6,
['GD']=7,
['NP']=8,
['GP']=9,
['DP']=10,
['AP']=11,
}
indecl = {
['decl']=decldecl,
['NS']=1,
['GS']=1,
['DS']=1,
['ND']=1,
['GD']=1,
['NP']=1,
['GP']=1,
['DP']=1,
}

inflinfo = {
[alp_pax] = '1st-alp',
[eta_pax] = '1st-eta',
[als_prx] = '1st-als',
[ets_prx] = '1st-ets',
[M_alp_pax] = '1st-M-alp',
[M_eta_pax] = '1st-M-eta',
[M_alp_con] = '1st-M-alp',
[second] = '2nd',
[second_N] = '2nd-N',
[second_att] = '2nd-att',
[second_N_att_prx] = '2nd-N-att',
[es_adj] = '3rd-εσ-adj',
[N_es_adj] = '3rd-N-εσ-adj',
[N_es_prx] = '3rd-N-εσ',
[N_as_prx] = '3rd-N-ᾰσ',
[kles] = '3rd-κλῆς',
[weak_i_prx] = '3rd-weak-ι',
[weak_u] = '3rd-weak-υ',
[N_weak_i_prx] = '3rd-N-weak-ι',
[N_weak_u] = '3rd-N-weak-υ',
[pure_i_prx] = '3rd-pure-ι',
[N_pure_i_prx] = '3rd-N-pure-ι',
[pure_u_long_prx] = '3rd-pure-υ-long',
[pure_u] = '3rd-pure-υ',
[N_pure_u_prx] = '3rd-N-pure-υ',
[eus] = '3rd-ευς',
[oi] = '3rd-οι',}

function get_decl(nom,gen)
	if nom == gen then
		return 'indecl',nom
	end
	nomstrip = m_accent.strip_tone(nom)
	genstrip = m_accent.strip_tone(gen)
	if not mw.ustring.match(nom,'ῠς?$') then
		genstrip = mw.ustring.gsub(genstrip,'εος','ους')
		genstrip = mw.ustring.gsub(genstrip,'ᾰος','ως')
	end
	for k,v in pairs(inflinfo) do
		if mw.ustring.match(nomstrip, mw.ustring.sub(m_accent.strip_tone(k.NS),2)..'$') and
		   mw.ustring.match(genstrip, mw.ustring.sub(m_accent.strip_tone(k.GS),2)..'$') then
			local suffix = ''
			if m_accent.ult(nomstrip) == nom then
			elseif m_accent.circ(nomstrip) == nom then
				suffix = '-con'
			elseif m_accent.pencirc(nomstrip) == nom and inflections[v..'-pax'] then
				suffix = '-pax'
			else
				suffix = '-prx'
			end
			return v..suffix,mw.ustring.sub(nomstrip,1,-mw.ustring.len(m_accent.strip_tone(k.NS) ) )
		end
	end
	if mw.ustring.match(genstrip,'ος$') then
		suffix = ''
		if m_accent.circ(nomstrip) == nom or m_accent.ult(nomstrip) == nom then
		elseif m_accent.pencirc(nomstrip) == nom then
			suffix = '-pax'
		else
			suffix = '-prx'
		end
		root = mw.ustring.sub(genstrip,1,-3)
		if form:match('N') or (mw.ustring.match(root,'[ᾰᾱα]τ$') and not form:match('[MF]')) then
			return '3rd-N-cons'..suffix,root
		end
		return '3rd-cons'..suffix,root
	end
	error("can't find a conjtype")
end

inflinfo_adj = {
['1&2-alp'] = {'ος','ᾱ'},
['1&2-eta'] = {'ος','η'},
['1&2-alp-con'] = {'ους','ᾱ'},
['1&2-eta-con'] = {'ους','η'},
['1&3-ups'] = {'ῠς','ειᾰ'},
['1&3-οτ'] = {'ως','υιᾰ'},
['1&3-ᾰν'] = {'ᾱς','αινᾰ'},
['1&3-εν'] = {'ην','εινᾰ'},
['1&3-εντ'] = {'εις','ᾰ'},
['1&3-ᾰντ'] = {'ᾱς','ᾱσᾰ'},
['1&3-οντ'] = {'ων','ουσᾰ'},
['1&3-ῠντ'] = {'ῡς','ῡσᾰ'},
['1&3-ωντ'] = {'ων','ωσᾰ'},
['1&3-ουντ'] = {'ους','ουσᾰ'},
['2nd'] = {'ος','ον'},
['2nd-att'] = {'ως','ων'},
['3rd-εσ-adj'] = {'ης','ες'},

}

function get_decl_adj(masc,fem)
	mstrip = m_accent.strip_tone(masc)
	if fem then fstrip = m_accent.strip_tone(fem) end
	if fem == nil then
		suffix = '-prx'
		if masc == m_accent.ult(mstrip) then
			suffix = ''
		elseif masc == m_accent.pencirc(mstrip) then
			suffix = '-pax'
		end
		return '3rd-cons'..suffix,mstrip
	end
	for k,v in pairs(inflinfo_adj) do
		if mw.ustring.match(mstrip, v[1]..'$') and mw.ustring.match(fstrip, v[2]..'$') then
			if k == '1&2-alp-con' and mw.ustring.match(fstrip,'ουσα$') then
				k = '1&3-ουντ'
			end
			suffix = '-prx'
			if masc == m_accent.ult(mstrip) then
				suffix = ''
			elseif masc == m_accent.circ(mstrip) then
				suffix = '-con'
			elseif masc == m_accent.pencirc(mstrip) and k ~= '3rd-εσ-adj' then
				suffix = '-pax'
			end
			return k..suffix,mw.ustring.sub(mstrip,1,-1-mw.ustring.len(v[1] ) )
		end
	end
	error("can't find a conjtype "..mstrip .. ' ' .. fstrip)
end

dialgroups = {
	['ark'] = {ara=true,kyp=true,ark=true},
	['severe'] = {ara=true,kyp=true,ark=true,ele=true,lak=true,her=true,kre=true,les=true}, -- lesbian was omitted from §25 — by mistake?
	['buck9'] = { boi=true,kyp=true,				  lak=true,her=true,kre=true},
	['buck78'] = {the=true,ark=true,ara=true,kyp=true,thr=true,koa=true},
	['northwest'] = {pho=true,del=true,lok=true,ele=true},
	['doric'] = {lak=true,her=true,meg=true,krn=true,kor=true,arg=true,rho=true,pam=true,koa=true,thr=true,kre=true},
	['west'] = {pho=true,del=true,lok=true,ele=true,
				lak=true,her=true,meg=true,krn=true,kor=true,arg=true,rho=true,pam=true,koa=true,thr=true,kre=true,
				dor=true},
	['nonIA'] = {ara=true,kyp=true,ark=true,
				 les=true,the=true,boi=true,
				 pho=true,del=true,lok=true,ele=true,
				 lak=true,her=true,meg=true,krn=true,kor=true,arg=true,rho=true,pam=true,koa=true,thr=true,kre=true,
				 dor=true},
}

function dialform(f,suffix,dialect,dialect2)
	if args.dial and (args.dial == dialect or 
					args.dial == dialect2 or 
					(dialgroups[dialect] and dialgroups[dialect][args.dial] ) ) then
		ctable[f] = suffix
	end
end

function infl_art(gender)
	local art = {}
	arttable = nil
	if form:match('M') then
		gender = 'M'
	elseif form:match('F') then
		gender = 'F'
	elseif form:match('N') then
		gender = 'N'
	elseif form:match('X') then
		return {}
	end
	if gender == 'M' then
		arttable = art_att_M
	elseif gender == 'F' then
		arttable = art_att_F
	elseif gender == 'N' then
		arttable = art_att_N
	else
		error('Gender not specified.')
	end
	for code, suffix in pairs(arttable) do
		if (form:match('MF') or gender == 'MF') and art_att_M[code] ~= art_att_F[code] then
			art[code] = art_att_M[code] .. ', ' .. art_att_F[code]
		else
			art[code] = suffix
		end
		if args.dial == 'epi' then art[code] = '' end
		if adjective then art[code] = '' end
	end

	if gender == 'F' then
		if dialgroups['nonIA'][args.dial] then
			art['NS'] = 'ᾱ̔' -- 104.1-4
			art['GS'] = 'τᾶς'
			art['DS'] = 'τᾷ'
			art['AS'] = 'τᾱ̀ν'
		end
		
		if args.dial == 'the' or args.dial == 'les' then
			art['DS'] = 'τᾶ' -- 39
		elseif args.dial == 'boi' or args.dial == 'ara' or args.dial == 'ele' then
			art['DS'] = 'ται' -- 104.3
		end
		
		if dialgroups['nonIA'][args.dial] then
			art['GP'] = 'τᾶν' -- 104.6
		end
		
		if args.dial == 'ato' then
			art['DP'] = 'τῆσῐ(ν)' -- 104.7
		elseif args.dial == 'ion' then
			art['DP'] = 'τῇσῐ(ν)' -- 104.7
		end
		
		if dialgroups['buck78'][args.dial] then
			art['AP'] = 'τᾰ̀ς' -- 104.8
		elseif args.dial == 'kre' or args.dial == 'arg' then
			art['AP'] = 'τὰνς'
		elseif args.dial == 'les' then
			art['AP'] = 'ταῖς'
		elseif args.dial == 'ele' then
			art['AP'] = 'ταὶρ'
		end
		
		if args.dial == 'kre' or args.dial == 'les' or args.dial == 'kyp' then
			art['NS'] = 'ᾱ̓' -- 57
			art['NP'] = 'αἰ'
		elseif args.dial == 'ele' then
			art['NS'] = 'ᾱ̓'
			art['NP'] = 'ταὶ'
		elseif args.dial == 'boi' then
			art['NP'] = 'τὴ' -- 104.5
		elseif dialgroups['west'][args.dial] then --boeotian is covered above
			art['NP'] = 'ταὶ'
		end
		
	end
	if gender == 'M' or gender == 'N' then
		if args.dial == 'the' then
			art['GS'] = 'τοῖ' -- 106.1
			art['DS'] = 'τοῦ' -- 23
			art['ND'] = 'τοὺ'
			art['GP'] = 'τοῦν'
		end
		
		if args.dial == 'les' then
			art['DS'] = 'τῶ' -- 106.2
		elseif args.dial == 'boi' or args.dial == 'ara' or args.dial == 'ele' or args.dial == 'eub' then
			art['DS'] = 'τοι' -- 106.2
		end
		
		if args.dial == 'ato' or args.dial == 'ion' then
			art['DP'] = 'τοῖσῐ(ν)' -- 106.4
		end
		
		if gender == 'M' then
			if dialgroups['buck78'][args.dial] then
				art['AP'] = 'τὸς' -- 106.5
			elseif args.dial == 'kre' or args.dial == 'arg' then
				art['AP'] = 'τὸνς'
			elseif args.dial == 'les' then
				art['AP'] = 'τοῖς'
			elseif args.dial == 'ele' then
				art['AP'] = 'τοὶρ'
			elseif dialgroups['severe'][args.dial] or args.dial == 'boi' then
				art['AP'] = 'τὼς'
			end

			if args.dial == 'kre' or args.dial == 'les' or args.dial == 'kyp' then
				art['NS'] = 'ὀ' -- 57
				art['NP'] = 'οἰ'
			elseif args.dial == 'ele' then
				art['NS'] = 'ὀ'
				art['NP'] = 'τοὶ'
			elseif dialgroups['west'][args.dial] or args.dial == 'boi' then
				art['NP'] = 'τοὶ'
			end
		end
		
		if args.dial == 'ele' then
			art['GD'] = 'τοίοις'
--		elseif args.dial == 'ara' then
--			art['GD'] = 'τοιυν'
		end
	end

	return art
end

function dialforms_first()
	dialform('GD','1αι(ῐ)ν or 1ῃῐν','epi')
	dialform('GP','3ᾱ́ων/3έων/3ῶν','epi')
	dialform('DP','1ῃσῐ/1ῃς/1αις','epi')

	dialform('DS','1η','boi') -- 104.3
	dialform('DS','1αι','ara','ele')
	dialform('DS','1ᾱ','the','les')
	
	dialform('GP','3έων/3ῶν','ion') -- 104.6
	dialform('GP','3ᾶν','nonIA')
	dialform('GP','3ᾱ́ων','boi')
	
	dialform('DP','1ῃσῐ(ν)','ion') -- 104.7, ato must be dealt with separately
	dialform('DP','1αισῐ(ν)','les')
	
	dialform('AP','1ᾰς','buck78') -- 104.8
	dialform('AP','1ᾰνς','kre','arg')
	dialform('AP','1αις','les')
	dialform('AP','1αιρ','ele')

	dialform('GD','3αίαιρ','ele')
end

function dialforms_firstoxy()
	dialform('GD','3αῖ(ῐ)ν or 3ῇῐν','epi')
	dialform('GP','3ᾱ́ων/3έων/3ῶν','epi')
	dialform('DP','3ῇσῐ/1ῇς/1αῖς','epi')

	dialform('DS','3ῆ','boi') -- 104.3
	dialform('DS','3αῖ','ara','ele')
	dialform('DS','3ᾶ','the','les')
	
	dialform('GP','3έων/3ῶν','ion') -- 104.6
	dialform('GP','3ᾶν','nonIA')
	dialform('GP','3ᾱ́ων','boi')
	
	dialform('DP','3ῇσῐ(ν)','ion') -- 104.7, ato must be dealt with separately
	dialform('DP','1αισῐ(ν)','les')
	
	dialform('AP','3ᾰ́ς','buck78') -- 104.8
	dialform('AP','3ᾰ́νς','kre','arg')
	dialform('AP','1αις','les')
	dialform('AP','3αίρ','ele')

	dialform('GD','3αίαιρ','ele')
end

inflections['1st-alp-pax'] = function()
	ctable = alp_pax
	dialforms_first()
	dialform('DP','1ᾱσῐ(ν)','ato')
	if adjective then
		stem[2] = m_accent.circ(root)
		ctable['GP'] = '1ων'
	end
end

inflections['1st-eta-pax'] = function()
	ctable = eta_pax
	dialforms_first()
	dialform('DP','1ησῐ(ν)','ato')
	if adjective then
		stem[2] = m_accent.circ(root)
		ctable['GP'] = '1ων'
	end
end

inflections['1st-alp'] = function()
	ctable = alp
	dialforms_firstoxy()
	dialform('DP','3ᾶσῐ(ν)','ato')
end

inflections['1st-eta'] = function()
	ctable = eta
	dialforms_firstoxy()
	dialform('DP','3ῆσῐ(ν)','ato')
end

inflections['1st-als-pax'] = function()
	ctable = als_prx
	dialforms_first()
	dialform('DP','1ᾱσῐ(ν)','ato')
end

inflections['1st-als-prx'] = function()
	ctable = als_prx
	dialforms_first()
	dialform('DP','1ᾱσῐ(ν)','ato')
end

inflections['1st-ets-pax'] = function()
	ctable = ets_prx
	dialforms_first()
	dialform('DP','1ησῐ(ν)','ato')
end

inflections['1st-ets-prx'] = function()
	ctable = ets_prx
	dialforms_first()
	dialform('DP','1ησῐ(ν)','ato')
end

inflections['1st-alp-con'] = function()
	ctable = alp_con
end

inflections['1st-eta-con'] = function()
	ctable = eta_con
end

inflections['1st-M-alp-pax'] = function()
	ctable = M_alp_pax
	dialforms_first()
	dialform('GS','1ᾱο/1ε͜ω/1ω','epi')
	
	dialform('GS','1εω/1ω','ion')
	dialform('GS','1ᾱ','nonIA')
	dialform('GS','1ᾱο','boi')
	dialform('GS','1ᾱυ','ark')
end

inflections['1st-M-eta-pax'] = function()
	ctable = M_eta_pax
	dialforms_first()
	dialform('GS','1ᾱο/1ε͜ω/1ω','epi')

	if args['voc'] == 'α' then
		ctable['VS'] = '2ᾰ'
	end

	dialform('GS','1εω/1ω','ion')
	dialform('GS','1ᾱ','nonIA')
	dialform('GS','1ᾱο','boi')
	dialform('GS','1ᾱυ','ark')
end

inflections['1st-M-eta'] = function()
	ctable = M_eta
	dialforms_firstoxy()
	dialform('GS','3ᾶο/3έ͜ω/3ῶ','epi')

	if args['voc'] == 'α' then
		ctable['VS'] = '3ᾰ́'
	end

	dialform('GS','3έω/3ῶ','ion')
	dialform('GS','3ᾶ','nonIA')
	dialform('GS','3ᾶο','boi')
	dialform('GS','3ᾶυ','ark')
end

inflections['1st-M-alp-con'] = function()
	ctable = M_alp_con
end

inflections['1st-M-eta-con'] = function()
	ctable = M_eta_con
end

function dialforms_second()
	dialform('GS','1ου/3οῖο/1οιο/3όο/1οο','epi')
	dialform('GD','1οιῐν','epi')
	dialform('DP','1οισῐ/1οις','epi')
	
	dialform('GS','1οιο','dor')
	
	dialform('GS','1οι','the') -- 106.1
	dialform('GS','1ω','severe','boi')
	dialform('GS','1ων','kyp')
	
	dialform('DS','1ω','les') -- 106.2
	dialform('DS','1ου','the')
	dialform('DS','1οι','ele','boi')
	dialform('DS','1οι','ara','eub')
	
	dialform('DP','1οισῐ(ν)','ato','ion') -- 106.4
	dialform('DP','1οισῐ','les')
	
	dialform('AP','1ως','severe') -- 106.5
	dialform('AP','1ος','buck78')
	dialform('AP','1ονς','kre','arg')
	dialform('AP','1οις','les')
	dialform('AP','1οιρ','ele')
	
	dialform('GD','3οίοιρ','ele') -- 106.6

	dialform('ND','1ου','the') -- 23
	dialform('GP','1ουν','the')
end

function dialforms_secondoxy()
	dialform('GS','3οῦ/3οῖο/3όο','epi')
	dialform('GD','3οῖῐν','epi')
	dialform('DP','3οῖσῐ/3οῖς','epi')
	
	dialform('GS','3οῖο','dor')
	
	dialform('GS','3οῖ','the') -- 106.1
	dialform('GS','3ῶ','severe','boi')
	dialform('GS','3ῶν','kyp')
	
	dialform('DS','1ω','les') -- 106.2
	dialform('DS','3οῦ','the')
	dialform('DS','3οῖ','ele','boi')
	dialform('DS','3οῖ','ara','eub')
	
	dialform('DP','3οῖσῐ(ν)','ato','ion') -- 106.4
	dialform('DP','1οισῐ','les')
	
	dialform('AP','3ώς','severe') -- 106.5
	dialform('AP','3ός','buck78')
	dialform('AP','3όνς','kre','arg')
	dialform('AP','3οίς','les')
	dialform('AP','3οίρ','ele')
	
	dialform('GD','3οίοιρ','ele') -- 106.6
	
	dialform('ND','3ού','the') -- 23
	dialform('GP','3οῦν','the')
end

inflections['2nd-prx'] = function()
	ctable = second_prx
	dialforms_second()
end

inflections['2nd-pax'] = function()
	ctable = second_prx
	dialforms_second()
end

inflections['2nd'] = function()
	ctable = second
	dialforms_secondoxy()
end

inflections['2nd-N-prx'] = function()
	ctable = second_N_prx
	dialforms_second()
end

inflections['2nd-N-pax'] = function()
	ctable = second_N_prx
	dialforms_second()
end

inflections['2nd-N'] = function()
	ctable = second_N
	dialforms_secondoxy()
end

inflections['2nd-con'] = function()
	ctable = second_con
end

inflections['2nd-con-pax'] = function()
	ctable = second_con_pax
end

inflections['2nd-N-con'] = function()
	ctable = second_N_con
end

inflections['2nd-att-prx'] = function()
	ctable = second_att_prx
	stem = {m_accent.penult(root)}
end

inflections['2nd-att-pax'] = function()
	ctable = second_att_prx
end

inflections['2nd-att'] = function()
	ctable = second_att
end

inflections['2nd-N-att-prx'] = function()
	ctable = second_N_att_prx
	stem = {m_accent.penult(root)}
end

inflections['2nd-att-con'] = function()
	ctable = second_att_con
end

function third_nom()
	if ctable == nil then error('two') end
	local conss = mw.ustring.sub(root,-2)
	local cons = mw.ustring.sub(root,-1)
	local nom = mw.ustring.sub(root,1,-2)
	local dp = nil
	if mw.ustring.match('πφβ',cons) then
		nom = nom .. 'ψ'
	elseif 'κτ' == conss then
		nom = mw.ustring.sub(root,1,-3)..'ξ'
	elseif mw.ustring.match('κχγ',cons) then
		nom = nom .. 'ξ'
	elseif 'ντ' == conss then
		local cons3 = mw.ustring.sub(root,-3)
		local nom3 = mw.ustring.sub(root,1,-4)
		if ctable['g'] == 'N' then
		elseif cons3 == 'ᾰντ' then
			nom = nom3..'ᾱς'
			dp = nom3..'ᾱσ'
		elseif conjtype == '1&3-ουντ' then
			nom = nom3..'ους'
			dp = nom3..'ουσ'
		elseif conjtype == '1&3-οντ' then
			--nom = mw.ustring.sub(root,1,-5)..'ους'
			dp = nom3..'ουσ'
		elseif cons3 == 'οντ' then
			nom = nom3..'ων'
			dp = nom3..'ουσ'
		elseif cons3 == 'εντ' then
			nom = nom3..'εις'
			dp = nom3..'εσ'
		elseif cons3 == 'ωντ' then
			nom = nom3..'ων'
			dp = nom3..'ωσ'
		elseif cons3 == 'ῠντ' then
			nom = nom3..'ῡς'
			dp = nom3..'ῡσ'
		elseif mw.ustring.sub(root,-4) == 'ουντ' then
			nom = mw.ustring.sub(root,1,-5)..'ους'
			dp = mw.ustring.sub(root,1,-5)..'ουσ'
		end
		ctable['g'] = ctable['g'] or 'M'
	elseif mw.ustring.match('τδθ',cons) then
		dp = nom .. 'σ'
		if not adjective then
			if mw.ustring.sub(root,-3) == 'τητ' then
				ctable['g'] = ctable['g'] or 'F'
			elseif conss == 'ητ' or cons == 'ωτ' then
				ctable['g'] = ctable['g'] or 'M'
			elseif mw.ustring.match('δθ',cons) then
				ctable['g'] = ctable['g'] or 'F'
			elseif mw.ustring.match(conss,'[ᾰᾱα]τ') then
				ctable['g'] = ctable['g'] or 'N'
			end
		end
		if ctable['g'] ~= 'N' then
			nom = nom .. 'ς'
			if conss == 'οτ' then
				nom = mw.ustring.sub(root,1,-3)..'ως'
			end
		else
			if conss == 'οτ' then
				nom = nom .. 'ς'
			end
		end
	elseif mw.ustring.match('ρν',cons) then
		local vowel = mw.ustring.sub(root,-2,-2)
		if cons == 'ρ' then
			dp = root .. 'σ'
		else
			dp = nom .. 'σ'
		end
		if ctable['g'] == 'N' then
			nom = root
		elseif vowel == 'ε' then
			nom = mw.ustring.sub(root,1,-3)..'η'..cons
		elseif vowel == 'ο' then
			nom = mw.ustring.sub(root,1,-3)..'ω'..cons
		elseif vowel == 'ῑ' then --ῥίς etc.
			nom = nom .. 'ς'
		elseif (vowel == 'ᾰ' and ctable['g'] ~= 'N') then
			nom = mw.ustring.sub(root,1,-3)..'ᾱς'
		else
			nom = root
		end
		if mw.ustring.sub(root,-3) == 'γον' or mw.ustring.sub(root,-3) == 'δον' then
			ctable['g'] = ctable['g'] or 'F'
		elseif mw.ustring.match(conss,'[ᾰᾱα]ρ') then
			ctable['g'] = ctable['g'] or 'N'
		else
			ctable['g'] = ctable['g'] or 'M'
		end
	elseif cons == 'σ' then
		dp = root
		if ctable['g'] == 'N' then
			nom = nom..'ς'
		else
			nom = mw.ustring.sub(root,1,-3)..'ης'
		end
		ctable['DS'] = '2ῐ̈'
	elseif cons == 'ω' then
		if ctable == lp_prx then
			ctable['DS'] = m_accent.penult(nom..'ῳ').. '/2ῐ̈'
			ctable['AS'] = '2/2ᾰ'
		else
			ctable['DS'] = '5ῐ̈́'
			ctable['AS'] = '2/5ᾰ́'
		end
		dp = nom .. 'ωσ'
		nom = nom .. 'ως'
		ctable['g'] = ctable['g'] or 'M'
	else
		error('Stem does not end in a consonant: '..root)
	end
	dp = dp or nom
	if adjective and ctable['g'] == 'N' then
	else
		nom = args[1] or nom
	end
	return nom,dp
end

function dialforms_third()
	ctable['DP'] = ctable['DP']..'ῐ'
	
	dialform('DP',ctable['DP']..'/1εσσῐ/1εσῐ','epi')
	dialform('GD','1οιῐν','epi')
	
	dialform('DP','1εσσῐ','dor')

	dialform('AS','2ᾰν','kyp')

	dialform('DP','1εσσῐ','les','the')
	dialform('DP','1εσσῐ','boi')
	dialform('DP','1οις','lok','ele')

	dialform('AP','2ες','ark','ele')
	dialform('AP','2ᾰς/2ᾰνς','kre')
end

function dialforms_third_oxy()
	ctable['DP'] = ctable['DP']..'ῐ́'
	dialform('GD','3οῖῐν','epi')
	dialform('DP',ctable['DP']..'/1εσσῐ/1εσῐ','epi')
	
	dialform('DP','1εσσῐ','dor')

	dialform('AS','2ᾰν','kyp')

	dialform('DP','1εσσῐ','les','the')
	dialform('DP','1εσσῐ','boi')
	dialform('DP','3οῖς','lok','ele')

	dialform('AP','2ες','ark','ele')
	dialform('AP','2ᾰς/2ᾰνς','kre')
end

inflections['3rd-cons-prx'] = function()
	ctable = lp_prx
	ctable['NS'],ctable['DP'] = third_nom()
	ctable['NS'] = m_accent.antepenult(ctable['NS'] )
	ctable['DP'] = m_accent.penult(ctable['DP'] )
	local q = mw.ustring.sub(root,-2)
	if q == 'ῐδ' or q == 'ῐτ' or q == 'ῑθ' then
		dialform('AS',ctable['AS'],'epi','ion') -- i.e. -χάριν; also poetic
		ctable['AS'] = m_accent.antepenult(mw.ustring.sub(root,1,-2)..'ν')
		ctable['VS'] = m_accent.antepenult(mw.ustring.sub(root,1,-2) )
	elseif q == 'ντ' and not adjective then
		ctable['VS'] = m_accent.antepenult(mw.ustring.sub(root,1,-2) )
	elseif mw.ustring.match(root,'[ρν]$') then
		ctable['VS'] = m_accent.antepenult(root)
	elseif mw.ustring.sub(root,-1) == 'ε' then
		ctable['VS'] = m_accent.antepenult(root..'ς')
	end
	dialforms_third()
end

inflections['3rd-N-cons-prx'] = function()
	ctable = N_lp_prx
	ctable['NS'],ctable['DP'] = third_nom()
	ctable['NS'] = m_accent.antepenult(ctable['NS'] )
	ctable['DP'] = m_accent.penult(ctable['DP'])
	dialforms_third()
end

inflections['3rd-cons-pax'] = function()
	ctable = lp_prx
	stem[2] = m_accent.penult(root)
	ctable['NS'],ctable['DP'] = third_nom()
	ctable['NS'] = m_accent.pencirc(ctable['NS'])
	ctable['DP'] = m_accent.penult(ctable['DP'])
	local q = mw.ustring.sub(root,-2)
	if q == 'ῐδ' or q == 'ῐτ' or q == 'ῑθ' then
		dialform('AS',ctable['AS'],'epi','ion') -- i.e. -χάριν; also poetic
		ctable['AS'] = m_accent.pencirc(mw.ustring.sub(root,1,-2)..'ν')
		ctable['VS'] = m_accent.pencirc(mw.ustring.sub(root,1,-2) )
	elseif q == 'ντ' and (conjtype == '1&3-εντ-pax' or not adjective) then
		ctable['VS'] = m_accent.pencirc(mw.ustring.sub(root,1,-2) )
	elseif mw.ustring.match(root,'[ρν]$') then
		ctable['VS'] = m_accent.pencirc(root)
	elseif mw.ustring.sub(root,-1) == 'ε' then
		ctable['VS'] = m_accent.pencirc(root..'ς')
	end
	dialforms_third()
end

inflections['3rd-N-cons-pax'] = function()
	ctable = N_lp_prx
	stem[2] = m_accent.penult(root)
	ctable['NS'],ctable['DP'] = third_nom()
	ctable['NS'] = m_accent.pencirc(ctable['NS'])
	ctable['DP'] = m_accent.penult(ctable['DP'])
	dialforms_third()
end

inflections['3rd-cons'] = function()
	local mono = (m_accent.penult(root) == m_accent.circ(root))
	ctable = mono and lp or lp_prx
	ctable['NS'],ctable['DP'] = third_nom()
	local q = mw.ustring.sub(root,-2)
	if q == 'ῐδ' or q == 'ῐτ' or q == 'ῑθ' then
		ctable['VS'] = m_accent.ult(mw.ustring.sub(root,1,-2))
	elseif q == 'ντ' and not adjective then
		ctable['VS'] = m_accent.circ(mw.ustring.sub(root,1,-2))
	end
	if conjtype:match('con') then
		ctable['NS'] = m_accent.circ(ctable['NS'])
	else
		ctable['NS'] = m_accent.ult(ctable['NS'])
	end
	if mono and not mw.ustring.match(conjtype,'ντ') then --no participles are oxytone in oblique forms
		dialforms_third_oxy()
	else
		ctable['DP'] = m_accent.circ(ctable['DP'])
		dialforms_third()
	end
end

inflections['3rd-N-cons'] = function()
	local mono = (m_accent.penult(root) == m_accent.circ(root))
	ctable = mono and N_lp or N_lp_prx
	if ctable == nil then error('one') end
	ctable['NS'],ctable['DP'] = third_nom()
	local q = mw.ustring.sub(root,-2)
	if conjtype:match('con') then
		ctable['NS'] = m_accent.circ(ctable['NS'])
	else
		ctable['NS'] = m_accent.ult(ctable['NS'])
	end
	if mono and not mw.ustring.match(conjtype,'ντ') then
		dialforms_third_oxy()
	else
		dialforms_third()
	end
end

function dialforms_es()
	dialform('GS','1εος','nonIA')
	dialform('GS','1ιος','buck9')
	dialform('GS','1εος/1ευς','ion')
	dialform('AS','1εᾰ','nonIA','ion')
	dialform('AS','1ιᾰ','buck9')
	dialform('GD','3έοιν','nonIA','ion')
	dialform('GD','3ίοιν','buck9')
	dialform('GP','3έων','nonIA','ion')
	dialform('GP','3ίων','buck9')
	dialform('AP','1εᾰς','nonIA','ion')
	dialform('AP','1ιᾰς','buck9')
end

function dialforms_es_oxy()
	dialform('GS','3έος','nonIA')
	dialform('GS','3ίος','buck9')
	dialform('GS','3έος/3εῦς','ion')
	dialform('AS','3έᾰ','nonIA','ion')
	dialform('AS','3ίᾰ','buck9')
	dialform('GD','3έοιν','nonIA','ion')
	dialform('GD','3ίοιν','buck9')
	dialform('GP','3έων','nonIA','ion')
	dialform('GP','3ίων','buck9')
	dialform('AP','3έᾰς','nonIA','ion')
	dialform('AP','3ίᾰς','buck9')
end

inflections['3rd-N-εσ-adj-prx'] = function()
	ctable = N_es_adj_prx
	
	dialforms_es()
end

inflections['3rd-εσ-adj-prx'] = function()
	ctable = es_adj_prx

	dialforms_es()
	dialform('NS','1εις','boi','the')
end

inflections['3rd-N-εσ-prx'] = function()
	ctable = N_es_prx

	dialforms_es()
end

inflections['3rd-εσ-adj'] = function()
	ctable = es_adj

	dialforms_es_oxy()
	dialform('NS','3εῖς','boi','the')
end

inflections['3rd-N-εσ-adj'] = function()
	ctable = N_es_adj

	dialforms_es_oxy()
end

inflections['3rd-N-εσ-adj-prx-open'] = function()
	ctable = N_es_adj_prx_open
end

inflections['3rd-εσ-adj-prx-open'] = function()
	ctable = es_adj_prx_open
end

inflections['3rd-N-εσ-prx-open'] = function()
	ctable = N_es_prx_open
end

inflections['3rd-εσ-adj-open'] = function()
	ctable = es_adj_open
end

inflections['3rd-N-εσ-adj-open'] = function()
	ctable = N_es_adj_open
end

inflections['3rd-N-ᾰσ-prx'] = function()
	ctable = N_as_prx
end

inflections['3rd-κλῆς'] = function()
	ctable = kles
	form = form:gsub('full','sing')
	dialform('GS','3κλέος','nonIA')
	dialform('GS','3κλεῖος','boi')
end

inflections['3rd-κλῆς-open'] = function()
	ctable = kles_open
	form = form:gsub('full','sing')
	dialform('GS','3κλῆος/3κλέος','epi','ion')
	dialform('DS','3κλῆῐ̈/3κλέῐ̈','epi','ion')
	dialform('AS','3κλῆᾰ/3κλέᾱ','epi','ion')
end

inflections['3rd-weak-ι-prx'] = function()
	ctable = weak_i_prx
end
inflections['3rd-weak-ι-pax'] = inflections['3rd-weak-ι-prx']

inflections['3rd-N-weak-ι-prx'] = function()
	ctable = N_weak_i_prx
end
inflections['3rd-N-weak-ι-pax'] = inflections['3rd-N-weak-ι-prx']

function dialforms_weak_u()
	dialform('GS','3έος','epi','ion')
	dialform('GD','3έοιῐν','epi')
	dialform('DP','3έεσσῐ/3έεσῐ/1εσῐ','epi')
	
	dialform('DP','3έεσσῐ','dor')
end

function dialforms_weak_u_prx()
	dialform('GS','1εος','epi','ion')
	dialform('GD','3έοιῐν','epi')
	dialform('DP','3έεσσῐ/3έεσῐ/1εσῐ','epi')

	dialform('DP','3έεσσῐ','dor')
end

inflections['3rd-weak-υ'] = function()
	ctable = weak_u
	dialforms_weak_u()
	if adjective then
		ctable['ND'] = '3έε'
	end
end

inflections['3rd-N-weak-υ'] = function()
	ctable = N_weak_u
	dialforms_weak_u()
	if adjective then
		ctable['ND'] = '3έε'
	end
end

inflections['3rd-weak-υ-prx'] = function()
	ctable = weak_u_prx
	dialforms_weak_u_prx()
	if adjective then
		ctable['ND'] = '1εε'
	end
end

inflections['3rd-N-weak-υ-prx'] = function()
	ctable = N_weak_u_prx
	dialforms_weak_u_prx()
	if adjective then
		ctable['ND'] = '1εε'
	end
end

inflections['3rd-pure-ι-prx'] = function()
	ctable = pure_i_prx
	dialform('GS','1ῐος/1ηος','epi')
	dialform('DS','1ῐῐ/1ῑ/1ηῐ̈/2ει','epi')
	dialform('GD','3ῐ́οιῐν','epi')
	dialform('NP','1ῐες/1ηες','epi')
	dialform('DP','3ῐ́εσσῐ/1εσῐ/1ῐσῐ','epi')
	dialform('AP','1ῐᾰς/1ηᾰς/1ῑς','epi')
	
	dialform('DP','1ῐ́εσσῐ','dor')
end
inflections['3rd-pure-ι-pax'] = inflections['3rd-pure-ι-prx']

inflections['3rd-N-pure-ι-prx'] = function()
	ctable = N_pure_i_prx
end
inflections['3rd-N-pure-ι-pax'] = inflections['3rd-N-pure-ι-prx']

inflections['3rd-pure-υ-prx'] = function()
	ctable = pure_u_prx
	dialform('GD','3ῠ́οιῐν','epi')
	dialform('DP','3ῠ́εσσῐ/1ῠσῐ/1ῠσσῐ','epi')
	dialform('DP','3ῠ́εσσῐ','dor')
end

inflections['3rd-pure-υ-long-prx'] = function()
	ctable = pure_u_long_prx
	dialform('GD','3ῠ́οιῐν','epi')
	dialform('DP','3ῠ́εσσῐ/1ῡσῐ/1ῡσσῐ','epi')
	dialform('DP','3ῠ́εσσῐ','dor')
end

inflections['3rd-pure-υ-long'] = function()
	ctable = pure_u_long
	dialform('GD','3ῠ́οιῐν','epi')
	dialform('DP','3ῠ́εσσῐ/1ῠσῐ/1ῠσσῐ','epi')
	dialform('DP','3ῠ́εσσῐ','dor')
end

inflections['3rd-pure-υ'] = function()
	ctable = pure_u
	dialform('GD','3ῠ́οιῐν','epi')
	dialform('DP','3ῠ́εσσῐ/1ῠσῐ/1ῠσσῐ','epi')
	dialform('DP','3ῠ́εσσῐ','dor')
end

inflections['3rd-N-pure-υ-prx'] = function()
	ctable = pure_u_prx
	dialform('GD','3ῠ́οιῐν','epi')
	dialform('DP','3ῠ́εσσῐ/1ῠσῐ/1ῠσσῐ','epi')
	dialform('DP','3ῠ́εσσῐ','dor')
end

inflections['3rd-ευς'] = function()
	if args.dial == 'kyp' or args.dial == 'boi' then
		ctable = eus_hwos
	elseif args.dial == 'les' or args.dial == 'epi' then
		ctable = eus_hos

		dialform('GS','3ῆος/3έος','epi')
		dialform('DS','3ῆῐ̈/3έῐ̈','epi')
		dialform('AS','3ῆᾰ/3έᾰ','epi')
		dialform('GD','3ήοιῐν','epi')
		dialform('DP','3ήεσσῐ/3εῦσῐ','epi')
	elseif args.dial == 'the' or args.dial == 'ele' then
		ctable = eus_eios
	else
		ctable = eus
		
		dialform('DP','3έεσσῐ','dor') -- this is somewhat conjectured

		dialform('GS','3έος','nonIA','ion')

		dialform('AS','3έᾰ','nonIA','ion')
		dialform('AS','3ῆ','doric','del')
		dialform('AS','3έᾰ','lok','kre')

		dialform('NP','3εῖς','nonIA','ion')
		dialform('NP','3ῆς','koa','lak')
		dialform('NP','3ῆς','ara')
		dialform('NP','3έες','kre')
		dialform('NP','3εῖς','late')

		dialform('AP','3έᾰς','nonIA','ion')
		
		dialform('NS','3ής','ara')
		dialform('AS','3ήν','ara')
	end
end

inflections['3rd-οι'] = function()
	ctable = oi
	form = form:gsub('full','sing')
	dialform('GS','3ῶς','sever')
	dialform('AS','3οῦν','ion')
end

local function paramError(i)
	if not args[i] then
		error('Parameter ' .. i .. ' has not been entered. Irregular adjective declension requires parameters 1-24 to be defined, though any of them can be empty. Irregular noun declension requires parameters 1-12 to be defined.')
	end
end

inflections['irreg'] = function()
	for i = 1, 12 do
		paramError(i)
	end
	ctable = irreg
	stem = {args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11],args[12]}
end

inflections['irreg2'] = function() --feminine part of irregular adjectives
	for i = 13, 22 do
		paramError(i)
	end
	ctable = irreg
	stem = {args[13],args[14],args[15],args[16],args[13],args[17],args[18],args[19],args[20],args[21],args[22]}
end

inflections['irreg3'] = function() --neuter part of irregular adjectives
	local indices = { 3, 4, 7, 8, 10, 11, 23, 24 }
	for _, i in pairs(indices) do
		paramError(i)
	end
	ctable = irreg
	stem = {args[23],args[3],args[4],args[23],args[23],args[7],args[8],args[24],args[10],args[11],args[24]}
end

inflections['irregN'] = function() --neuter irregular nouns
	ctable = irreg
	stem = {args[2],args[3],args[4],args[2],args[2],args[5],args[6],args[7],args[8],args[9],args[7]}
end

inflections['indecl'] = function()
	ctable = indecl
	stem = {args[2]}
end

local article

local nums = {}

function make_table()
	article = infl_art(ctable.g)
	if form:match('full') then nums = {'Singular','Dual','Plural'} end
	if form:match('sing') then table.insert(nums,'Singular') end
	if form:match('dual') then table.insert(nums,'Dual') end
	if form:match('plur') then table.insert(nums,'Plural') end
	s = [=[<div class="NavFrame" style="clear:both; width:]=] .. (form:match('full') and '100%' or '44%') .. [=[;">
	<div class="NavHead" align="center">]=].. make_title() ..[=[</div>
<div class="NavContent">
<center>
{| style="width:100%; background:#A9A9A9; color:#000000; text-align:center;" class="inflection-table" cellspacing="1"
!style="background:#B0C4DE;font-style:italic;width:]=] .. (form:match('full') and '16%' or '37%') .. [=[;"| Case / #
]=]
	local width = form:match('full') and 'width:28%;' or ''
	for _,j in ipairs(nums) do
		s = s ..'!style="background:#C0C0C0;font-style:italic;'..width..'"| '..j..'\n'
	end
	s = s .. make_rows() .. make_notes() .. [=[|}</center></div></div>]=]
	return s
end

function make_title()
	local q = ctable['decl']..' of '
	if form:match('plur') then
		q = q .. link_form('NP',true)..'; '..link_form('GP',true)
	elseif form:match('dual') then
		q = q .. link_form('ND',true)..'; '..link_form('GD',true)
	else
		q = q .. link_form('NS',true)..'; '..link_form('GS',true)
	end

	local dialtitle = args.dial
	if dialtitle then
		local dd = m_dialects[dialtitle]
		if dd then
			dialtitle = dd.link and ('[[w:'..dd.link..'|'..dd.display..']]') or dd.display
		end
		dialtitle = '('..dialtitle..')'
	end

	return q .. ' ' .. (args['titleapp'] or dialtitle or '') 
end

local form_cache = {}

function make_rows()
	local s = ''
	form_cache = {}
	for _,i in ipairs({'Nominative','Genitive','Dative','Accusative','Vocative'} ) do
		s = s .. '|-\n!style="background:#C0C0C0;font-style:italic;"| ' .. i .. '\n'
		for _,j in ipairs(nums) do
			local f = i:sub(1,1)..j:sub(1,1)
			s = s .. '|style="background:#F5F5F5;"| ' .. link_form(f) .. '\n'
		end
	end
	return s
end

function make_table_adj()
	threept = (adjinflections[conjtype][2] )
	colspan = threept and '3' or '2'
	th = threept and [=[''
!style="background:#C0C0C0;"| '']=] or [=[ / ]=]
	if form:match('full') then nums = {'Singular','Dual','Plural'} end
	if form:match('sing') then table.insert(nums,'Singular') end
	if form:match('dual') then table.insert(nums,'Dual') end
	if form:match('plur') then table.insert(nums,'Plural') end
	s = [=[<div class="NavFrame" style="clear:both; width:100%;">
	<div class="NavHead" align="center">]=].. make_title_adj() ..[=[</div>
<div class="NavContent">
<center>
{| style="width:100%; background:#A9A9A9; color:#000000; text-align:center;" class="inflection-table" cellspacing="1"
!style="background:#CECECE;"| ''Number''
]=]
	for _,j in ipairs(nums) do
		s = s .. [=[!style="width:0.5%" |
		!style="background:#CECECE;width:28%" colspan=]=]..colspan.."| ''"..j.."''\n"
	end
	s = s .. [=[|-
!style="background:#B0C4DE;"|''Case/Gender''
]=]
	for _,j in ipairs(nums) do
		s = s .. [=[|
!style="background:#C0C0C0;"| ''Masculine]=]..th..[=[Feminine''
!style="background:#C0C0C0;"| ''Neuter''
]=]
	end
	s = s .. make_rows_adj() .. make_acs_adj() .. make_notes() .. [=[|}</center></div></div>]=]
	return s
end

function make_title_adj()
	local q = 'Declension of '
	if adjinflections[conjtype][2] then
		q = q .. link_form('MNS',true)..'; '..link_form('FNS',true)..'; '..link_form('NNS',true)
	else
		q = q .. link_form('MNS',true)..'; '..link_form('NNS',true)
	end

	local dialtitle = args.dial
	if dialtitle then
		local dd = m_dialects[dialtitle]
		if dd then
			dialtitle = dd.link and ('[[w:'..dd.link..'|'..dd.display..']]') or dd.display
		end
		dialtitle = '('..dialtitle..')'
	end

	return q .. ' ' .. (args['titleapp'] or dialtitle or '') 
end

function make_rows_adj()
	local s = ''
	form_cache = {}
	local width = form:match('full') and 'width:28%;' or ''
	for _,i in ipairs({'Nominative','Genitive','Dative','Accusative','Vocative'} ) do
		s = s .. '|-\n!style="background:#C0C0C0;font-style:italic;"| ' .. i .. '\n'
		for _,j in ipairs(nums) do
			s = s .. '|\n'
			local f = i:sub(1,1)..j:sub(1,1)
			s = s .. '|style="background:#F5F5F5;"| ' .. link_form('M'..f) .. '\n'
			if adjinflections[conjtype][2] then
				s = s .. '|style="background:#F5F5F5;"| ' .. link_form('F'..f) .. '\n'
			end
			s = s .. '|style="background:#F5F5F5;"| ' .. link_form('N'..f) .. '\n'
		end
	end
	return s
end

function make_acs_adj()
	-- this should only apply to pronouns. I think.
	if #nums < 3 then return '' end
	
	-- get the adverb (we couldn't do this before)
	atable['adv'] = adverb or mw.ustring.gsub(mw.ustring.gsub(atable['MGP'],'ν$','ς'),'ν<','ς<')
	atable['comp'] = comparative
	atable['super'] = superlative
	
	colspan = (adjinflections[conjtype][2]) and '3' or '2'
	local s = [=[|-
!style="background:#B0C4DE;" rowspan="2"| ''Derived forms''
|
|style="background:#C0C0C0;" colspan=]=]..colspan..[=[ | ''Adverb''
|
|style="background:#C0C0C0;" colspan=]=]..colspan..[=[ | ''Comparative''
|
|style="background:#C0C0C0;" colspan=]=]..colspan..[=[ | ''Superlative''
|-
|
|style="background:#F5F5F5;" colspan=]=]..colspan.." | " .. link_form('adv') .. [=[ 
|
|style="background:#F5F5F5;" colspan=]=]..colspan.." | " .. link_form('comp') .. [=[ 
|
|style="background:#F5F5F5;" colspan=]=]..colspan.." | " .. link_form('super') .. [=[ 
]=]
	return s
end

function make_notes()
	s = args.notes or ''
	if args.dial and args.dial ~= 'att' then
		s = 'Dialects other than Attic are not well attested. Some forms may be based on conjecture. Use with caution.\n' .. s
	else
		s = 'This table gives Attic inflectional endings. For declension in dialects other than Attic, see [[Appendix:Ancient Greek dialectal declension]].\n' .. s
	end
	if contractnote then
		s = '† [[Appendix:Ancient Greek contraction|contracted]]\n' .. s -- should go first
	end
	return '|-\n!style="background:#C0C0C0;font-style:italic;"| Notes:\n|'..(adjective and '\n|' or '')..'style="background:#F5F5F5; text-align:left; font-size:90%;" colspan="13"| <span class="use-with-mention">' .. s .. '</span>\n'
end

local target = nil

form_redirects = {
['AS'] = 'NS',
['VS'] = 'NS',
['DD'] = 'GD',
['AD'] = 'ND',
['VD'] = 'ND',
['AP'] = 'NP',
['VP'] = 'NP',
}

function link_form(f,istitle)
	local t = adjective and atable or ctable
	local q
	
	-- grab from cache?
	if args[f] then
		q = args[f]
		require('Module:debug').track('grc-decl/form-override')
	elseif f == 'NDP' then
		q = form_cache['MDP']
	elseif t[f] then
		q = t[f]
	elseif form_redirects[f] then
		q = form_cache[form_redirects[f] ]
	elseif form_redirects[f:sub(2)] then
		q = form_cache[f:sub(1,1)..form_redirects[f:sub(2)]]
	elseif f:match('N[^N].') then
		q = form_cache['M'..f:sub(2)]
	end

	-- if it is a title form, strip all but the first variation
	if istitle then
		if q == nil then return '—' end
		q = mw.ustring.match(q,'[^,/]+') --capture up to comma or slash (needs standardization)
		q = mw.ustring.gsub(q,' +$','') --strip final whitespace
	end
	
	if q == nil then return '' end

	q = mw.ustring.gsub(q,' ?/ ?',' / ') -- space the slashes for legibility
	if qn then qn = mw.ustring.gsub(qn,' ?/ ?',' / ') end

	form_cache[f] = q
	
	if q == '' then return q end
	
	-- concat article
	if (not adjective) and article[f] and f:sub(1,1) ~= 'V' then
		q = article[f] .. ' ' .. q
	end
	
	-- Link the form
	link = function(alt)
		if alt == 'ν' then
			target = target .. alt
		else
			target = alt
		end
		target = mw.ustring.gsub(target,'͜','')
		target = mw.ustring.gsub(target,'σ$','ς')
		return m_links.full_link({lang = lang, term = target, alt = alt, tr = '-'})
	end
	
	if q == nil then error(f) end
	x,_ = mw.ustring.gsub(q,'([*%-́̀̈̓̔͜ΐ-ώϘ-ϡἀ-ῼ]+)',link)
	
	return x
end
return export