Module:User:Φρύδια/la-data

local LAComposer = require('Module:User:Φρύδια/logic'):new { paradigms = { {			{ 'IND', 'SBJ', 'IMP', 'INF', 'PTCP' }, { 'PRS', 'PST', 'FUT' }, { 'NPRF', 'PRF' }, { 'ACT', 'PASS' } },		{			{ 'VN' }, { 'GER', 'SUP' } }	},	constraints = { PST = { true,  { 'IND', 'SBJ' } }, FUT = { false, { 'INF', 'SBJ' } }, PRF = { false, { 'IMP' } }, ACT = { false, { 'PTCP.+_PRF' } }, PASS = { true, { '^..[^C].+NPRF', 'PTCP_PRS_PRF', 'PTCP_FUT_NPRF' } } },	endings_map = { IMP_FUT_NPRF_ACT = '1|4', IMP_FUT_NPRF_PASS = '1|5', IMP_PRS_NPRF_ACT = '1|6', IMP_PRS_NPRF_PASS = '1|7', IND_PRS_PRF_ACT  = '1|3', ACT              = '1|1', PASS             = '1|2', GER              = '2|8', SUP              = '2|9', INF              = '', PTCP             = '' },	endings_refs = { { '1SG', '2SG', '3SG', '1PL', '2PL', '3PL' }, { 'GEN', 'DAT', 'ACC', 'ABL' }, },	endings = { { 'm',  's',    't',    'mus',  'tis',   'nt'    }, { 'r',  'ris',  'tur',  'mur',  'minī',  'ntur'  }, { 'ī',  'istī', 'it',   'imus', 'istis', 'ērunt' }, { nil,  'tō',   'tō',    nil,   'tōte',  'ntō'   }, { nil,  'tor',  'tor',   nil,    nil,    'ntor'  }, { nil,  '',      nil,    nil,   'te',     nil    }, { nil,  're',    nil,    nil,   'minī',   nil    }, { 'ndī', 'ndō', 'ndum', 'ndō' }, { nil,   nil,   'um',   'ū'   } } }

local base = { IMP_FUT_NPRF_ACT_3SG          = '@IMP_FUT_NPRF_ACT_2SG', IMP_FUT_NPRF_PASS_3SG         = '@IMP_FUT_NPRF_PASS_2SG', stm_SUP                       = '&@vwl&t', stm_PTCP_FUT_NPRF_ACT         = '@stm_SUP', stm_PTCP_PRS_PRF_PASS         = '@stm_SUP', vwl_SUP                       = '', vwl_PTCP_FUT_NPRF_ACT         = 'ū', vwl_PTCP_PRS_PRF_PASS         = 'u', vwl_PTCP_FUT_NPRF_PASS        = '@vwl_GER', affx_IND_PST_NPRF             = 'bA', affx_SBJ_PST_NPRF             = 'rE', affx_IND_FUT_PRF              = '&eri', affx_IND_FUT_PRF_1SG          = '@affx_PRF_ACT&er', affx_SBJ_PRS_PRF              = '&erI', affx_IND_PST_PRF              = '&erA', affx_SBJ_PST_PRF              = '&issE', end_IND_PRS_NPRF_ACT_1SG      = 'ō', end_IND_PRS_NPRF_PASS_1SG     = 'or', end_IND_FUT_PRF_ACT_1SG       = 'ō', end_INF_PRS_NPRF_ACT          = 're', end_INF_PRS_NPRF_PASS         = 'ī', end_INF_PRS_PRF_ACT           = 'isse', end_PTCP_PRS_NPRF_ACT         = 'ns', end_PTCP_FUT_NPRF_ACT         = 'rus', end_PTCP_PRS_PRF_PASS         = 's', end_PTCP_FUT_NPRF_PASS        = 'ndus' }

local regular = { ['ā'] = { vwl_IND_PRS_NPRF          = 'A', vwl_SBJ_PRS_NPRF          = 'E', vwl_IND_PRS_NPRF_1SG      = '', vwl_GER                   = 'a', vwl_IMP                   = 'A', affx_PRF_ACT              = 'v', affx_IND_FUT_NPRF         = 'bi', affx_IND_FUT_NPRF_1SG     = 'b', affx_IND_FUT_NPRF_3PL     = 'bu', affx_IND_FUT_NPRF_PASS_2SG = 'be', affx_INF_PRS_NPRF_PASS    = 'r', end_IND_FUT_NPRF_ACT_1SG  = 'ō', end_IND_FUT_NPRF_PASS_1SG = 'or' },	['ē'] = { vwl_IND_PRS_NPRF          = 'E', vwl_SBJ_PRS_NPRF          = 'eA', vwl_PRF_ACT               = '', vwl_GER                   = 'e', vwl_IMP                   = 'E',

affx_IND_FUT_NPRF         = 'bi', affx_IND_FUT_NPRF_1SG     = 'b', affx_IND_FUT_NPRF_3PL     = 'bu', affx_IND_FUT_NPRF_PASS_2SG = 'be', affx_INF_PRS_NPRF_PASS    = 'r', end_IND_FUT_NPRF_ACT_1SG  = 'ō', end_IND_FUT_NPRF_PASS_1SG = 'or' },	['e'] = { vwl_IND_PRS_NPRF          = 'i', vwl_IND_PRS_NPRF_3PL      = 'u', vwl_IMP                   = 'i', vwl_IMP_3PL               = 'u', vwl_IMP_PRS_NPRF_ACT_2SG  = 'e', vwl_PRS_NPRF_PASS_2SG     = 'e', vwl_SBJ_PRS_NPRF          = 'A', vwl_PRF_ACT               = '', vwl_IND_PST_NPRF          = 'ē', vwl_IND_FUT_NPRF          = 'E', vwl_IND_FUT_NPRF_1SG      = 'a', vwl_IND_PRS_NPRF_1SG      = '', vwl_PTCP_PRS_NPRF_ACT     = 'ē', vwl_GER                   = 'e', vwl_INF_PRS_NPRF_PASS     = '' },	['ī'] = { vwl_IND_PRS_NPRF          = 'I', vwl_SBJ_PRS_NPRF          = 'iA', vwl_IND_PST_NPRF          = 'iē', vwl_IND_FUT_NPRF          = 'iE', vwl_FUT_NPRF_1SG          = 'ia', vwl_IND_PRS_NPRF_3PL      = 'iu', vwl_IMP_FUT_3PL           = 'iu', vwl_PTCP_PRS_NPRF_ACT     = 'iē', vwl_GER                   = 'ie', affx_PRF_ACT              = 'v', affx_INF_PRS_NPRF_PASS    = 'r'	} }

-- no, put this in the template call. saves LOTS of code local irregular = { ['tegere'] = { stm_PRF                   = 'tēx', stm_SUP                   = 'tēct' },	['dīcere'] = { stm_PRF                   = 'dīx', stm_SUP                   = 'dict' },	['legere'] = { stm_PRF                   = 'lēg', stm_SUP                   = 'lect' },	['canere'] = { stm_PRF                   = 'cecin', stm_SUP                   = 'cant' },	['vidēre'] = { stm_PRF                   = 'vīd', stm_SUP                   = 'vīs' } }

local vwl_forms = { A = { 'a', 'ā' }, E = { 'e', 'ē' }, I = { 'i', 'ī' } }

local vwl_map = { ['1SG'] = { 0, 0 }, ['2SG'] = { 1, 1 }, ['3SG'] = { 0, 1 }, ['1PL'] = { 1, 1 }, ['2PL'] = { 1, 1 }, ['3PL'] = { 0, 0 } }

local long_cnjgs = { ['ā'] = 1, ['ē'] = 2, ['ī'] = 4 }

function LAComposer:make_tables(lemma) local long_vwl = lemma:sub(-4, -3) local long_cnjg = long_cnjgs[long_vwl] local _stm = lemma:sub(1, long_cnjg and -5 or -4) local _vwl = long_cnjg and long_vwl or 'e'	local init_data = { inf = lemma, stm = _stm, vwl = _vwl, affx = '' } return { init_data, base, regular[_vwl], irregular[lemma] } end

function LAComposer:assemble_form(stm, vwl, affx, endg, pdgm, ref) local is_pass = pdgm:find 'PASS' and 1 or 0 local form = stm..vwl..affx..endg return form:gsub('(%u)', function(v)		local make = vwl_map[ref]		return vwl_forms[v][make and make[is_pass+1]+1 or 1] end) end

return LAComposer