Module:User:Vitalik/inflection/data/ru-noun

-- ru-noun v2.0.8
-- 2015-08-04

return {
	template = 'ru-decl-noun-table-z',
	affixes = {
		-- masculine singular
		m_hard_nom_sg = '',
		m_soft_nom_sg = 'ь',
		m_hard_gen_sg = 'а',
		m_soft_gen_sg = 'я',
		m_hard_dat_sg = 'у',
		m_soft_dat_sg = 'ю',
		m_hard_ins_sg = 'ом',
		m_soft_ins_sg_stressed = 'ём',
		m_soft_ins_sg_unstressed = 'ем',
		-- neuter singular
		n_hard_nom_sg = 'о',
		n_soft_nom_sg = 'е',  -- unstressed
		n_soft_nom_sg_stressed = 'ё',
		n_soft_nom_sg_unstressed = 'е',
		n_hard_gen_sg = 'а',
		n_soft_gen_sg = 'я',
		n_hard_dat_sg = 'у',
		n_soft_dat_sg = 'ю',
		n_hard_ins_sg = 'ом',
		n_soft_ins_sg_stressed = 'ём',
		n_soft_ins_sg_unstressed = 'ем',
		-- feminine singular
		f_hard_nom_sg = 'а',
		f_soft_nom_sg = 'я',
		f_hard_gen_sg = 'ы',
		f_soft_gen_sg = 'и',
		f_hard_dat_sg = 'е',
		f_soft_dat_sg_stressed = 'е',
		f_soft_dat_sg_unstressed = 'е',
		f_hard_acc_sg = 'у',
		f_soft_acc_sg = 'ю',
		f_hard_ins_sg = 'ой',
		f_soft_ins_sg_stressed = 'ёй',
		f_soft_ins_sg_unstressed = 'ей',
		-- common singular
		c_prp_sg_stressed = 'е',
		c_prp_sg_unstressed = 'е',
		-- masculine plural
		m_hard_nom_pl = 'ы',
		m_soft_nom_pl = 'и',
		m_hard_gen_pl_stressed = 'ов',  -- possibly we can join them together again (m_hard_gen_pl stressed and unstressed)
		m_hard_gen_pl_unstressed = 'ов',
		m_soft_gen_pl_stressed = 'ей',
		m_soft_gen_pl_unstressed = 'ей',
		-- neuter plural
		n_hard_nom_pl = 'а',
		n_soft_nom_pl = 'я',
		n_hard_gen_pl_stressed = '',
		n_hard_gen_pl_unstressed = '',
		n_soft_gen_pl_stressed = 'ей',
		n_soft_gen_pl_unstressed = 'ь',
		-- feminine plural
		f_hard_nom_pl = 'ы',
		f_soft_nom_pl = 'и',
		f_hard_gen_pl_stressed = '',
		f_hard_gen_pl_unstressed = '',
		f_soft_gen_pl_stressed = 'ей',
		f_soft_gen_pl_unstressed = 'ь',
		-- common plural
		c_hard_dat_pl = 'ам',
		c_soft_dat_pl = 'ям',
		c_hard_ins_pl = 'ами',
		c_soft_ins_pl = 'ями',
		c_hard_prp_pl = 'ах',
		c_soft_prp_pl = 'ях',
	},
	conditions = {
		-------------------------------------------------------------------------------------------
		{SECTION = 'A. Preparation'},
		-------------------------------------------------------------------------------------------
		{
			class = 'common',
			word = {'arg_replace', 'word_stressed', '́', ''},
		},
		{
			comment = 'Remove ending (-а, -е, -ё, -о, -я, -й, -ь) to get stem',

			stem = {'replace', 'word', '[аеёояйь]$', ''},
			stem_stressed = {'arg_replace', 'word_stressed', '[аеёояйь]́?$', ''},  -- it was also removed last stress here
		},
		{
			comment = "Add stress to stem_stressed if stress is absent (i.e. there is only one syllable or stress was on the ending)",

			_if = {
				stem_stressed__not_match = '[́ё]',
			},
			_then = {
				{
					_if = {stress_type = {'f', "f'", '6', "6'"}},
					stem_stressed = {'var_replace', 'stem_stressed', '^([^аеиоуыэюя]*)([аеиоуыэюя])', '%1%2́'},
				},
				{
					_if = {stress_type = {'a', 'b', 'c', 'd', "d'", 'e', '1', '2', '3', '4', "4'", '5',    "b'" }},  -- temp b'
					stem_stressed = {'var_replace', 'stem_stressed', '([аеиоуыэюя])([^аеиоуыэюя]*)$', '%1́%2'},
				},
				-- TODO: process cases with * (stress on penultimate syllable)
			}
		},
		{
			comment = 'Parse "gender_animacy" argument and get values for "gender" and "animate"',
			gender = {'match_arg', 'gender_animacy', '([mnf])%-[ia]n'},
			animate = {'match_arg', 'gender_animacy', '[mnf]%-([ia]n)'},
		},

		-------------------------------------------------------------------------------------------
		{SECTION = 'B. Determination of stem type'},
		-------------------------------------------------------------------------------------------
		{
			stem_type = '',
		},
		{
			_if = {stem__endswith = '[гкх]'},
			stem_type = 'velar',
		},
		{
			_if = {stem__endswith = '[жчшщ]'},
			stem_type = 'sibilant',
		},
		{
			_if = {stem__endswith = 'ц'},
			stem_type = 'letter-ц',
		},
		{
			_if = {stem__endswith = {'[йь]', '[аоеёуыэюя]'}},
			stem_type = 'vowel',
		},
		{
			_if = {stem__endswith = 'и'},
			stem_type = 'letter-и',
		},
		{
			_if = {stem__not_endswith = {'[гкх]', '[жчшщ]', 'ц', '[йь]', '[аоеёуыэюя]', 'и'}},
			_then = {
				{
					_if = {gender = 'm'},
					_then = {
						{
							_if = {stem = '<word>'},
							stem_type = 'hard',
						},
						{
							_if = {word__endswith = 'ь', word__not_endswith = 'путь'},
							stem_type = 'soft',
						},
						{
							_if = {word__endswith = 'путь'},
							stem_type = 'm-3rd',
						},
					},
				},
				{
					_if = {gender = 'f'},
					_then = {
						{
							_if = {word__endswith = 'а'},
							stem_type = 'hard',
						},
						{
							_if = {word__endswith = 'я'},
							stem_type = 'soft',
						},
						{
							_if = {word__endswith = 'ь'},
							stem_type = 'f-3rd',
						},
					},
				},
				{
					_if = {gender = 'n'},
					_then = {
						{
							_if = {word__endswith = 'о'},
							stem_type = 'hard',
						},
						{
							_if = {word__endswith = 'е'},
							stem_type = 'soft',
						},
						{
							_if = {word__endswith = 'мя'},
							stem_type = 'n-3rd',
						},
					},
				},
			},
		},
		{
			_if = {
				gender = 'f', 
				stem_type = 'sibilant',
				word__endswith = 'ь',
			},
			stem_type = 'f-3rd-sibilant',
		},
		{
			_if = {stem_type = ''},
			stem_type = 'hard',
		},
		
		-------------------------------------------------------------------------------------------
		{SECTION = 'C. Special changes in endings for velar, sibilant, vowel etc. stem types'},
		-------------------------------------------------------------------------------------------
		{
			comment = 'Replace "ы" to "и"',

			_if = {stem_type = {'velar', 'sibilant'}},
			f_hard_gen_sg = 'и',
			m_hard_nom_pl = 'и',
			f_hard_nom_pl = 'и',
		},
		{
			comment = 'Replace unstressed "о" to "е"',

			_if = {
				stem_type = {'sibilant', 'letter-ц'},
				stress_type = {'a', 'c', 'e', '1', '3', '5'},
			},
			n_hard_nom_sg = 'е',
			m_hard_ins_sg = 'ем',
			n_hard_ins_sg = 'ем',
			f_hard_ins_sg = 'ей',
			m_hard_gen_pl_stressed = 'ев',
			m_hard_gen_pl_unstressed = 'ев',
		},
		{
			comment = 'Replace "ов", "ев", "ёв" and null to "ей"',

			_if = {stem_type = {'sibilant'}},
			m_hard_gen_pl_stressed = 'ей',
			m_hard_gen_pl_unstressed = 'ей',
			n_hard_gen_pl_stressed = 'ей',
			-- n_hard_gen_pl_unstressed = '',  this is just don't changed
			f_hard_gen_pl_stressed = 'ей',
			-- f_hard_gen_pl_unstressed = '',  this is just don't changed
		},
		{
			comment = 'Replace "ь" to "й"',

			_if = {stem_type = {'vowel', 'letter-и'}},
			m_soft_nom_sg = 'й',
			n_soft_gen_pl_unstressed = 'й',
			f_soft_gen_pl_unstressed = 'й',
		},
		{
			comment = 'Replace "ей" to "ев/ёв", and "ь,ей" to "й"',

			_if = {stem_type = {'vowel', 'letter-и'}},
			m_soft_gen_pl_stressed = 'ёв',
			m_soft_gen_pl_unstressed = 'ев',
			n_soft_gen_pl_stressed = 'й',
			n_soft_gen_pl_unstressed = 'й',
			f_soft_gen_pl_stressed = 'й',
			f_soft_gen_pl_unstressed = 'й',
		},
		{
			_if = {stem_type = {'letter-и'}},
			f_soft_dat_sg_unstressed = 'и',
			c_prp_sg_unstressed = 'и',				
		},
		{
			_if = {stem_type = {'m-3rd'}},
			m_soft_gen_sg = 'и',
			m_soft_dat_sg = 'и',
			c_prp_sg_stressed = 'и',
			c_prp_sg_unstressed = 'и',
		},
		{
			_if = {stem_type = {'f-3rd', 'f-3rd-sibilant'}},
			f_soft_nom_sg = 'ь',
			f_soft_dat_sg_stressed = 'и',
			f_soft_dat_sg_unstressed = 'и',
			f_soft_acc_sg = 'ь',
			f_soft_ins_sg_stressed = 'ью',
			f_soft_ins_sg_unstressed = 'ью',
			c_prp_sg_stressed = 'и',
			c_prp_sg_unstressed = 'и',
			f_soft_gen_pl_stressed = 'ей',
			f_soft_gen_pl_unstressed = 'ей',
		},
		{
			_if = {stem_type = {'f-3rd-sibilant'}},
			c_soft_dat_pl = 'ам',
			c_soft_ins_pl = 'ами',
			c_soft_prp_pl = 'ах',
		},

		-------------------------------------------------------------------------------------------
		{SUBSECTION = 'If we have specific (1) or (2)'},
		{
			_if = {specific__match = '%(1%)'},
			{
				m_hard_nom_pl = 'а',
				m_soft_nom_pl = 'я',
				n_hard_nom_pl = 'ы',
				n_soft_nom_pl = 'и',
			},
			{
				comment = 'Replace "ы" to "и"',

				_if = {stem_type = {'velar', 'sibilant'}},
				n_hard_nom_pl = 'и',
			},
		},
		{
			_if = {specific__match = '%(2%)'},
			{
				m_hard_gen_pl_stressed = '',
				m_hard_gen_pl_unstressed = '',
				m_soft_gen_pl_stressed = 'ь',
				m_soft_gen_pl_unstressed = 'ь',
				n_hard_gen_pl_stressed = 'ов',
				n_hard_gen_pl_unstressed = 'ов',
				n_soft_gen_pl_stressed = 'ёв',
				n_soft_gen_pl_unstressed = 'ев',
				f_hard_gen_pl_stressed = 'ей',
				f_hard_gen_pl_unstressed = 'ей',
				f_soft_gen_pl_stressed = 'ей',
				f_soft_gen_pl_unstressed = 'ей',
			},
			{
				comment = 'Replace unstressed "о" to "е"',

				_if = {
					stem_type = {'sibilant', 'letter-ц'},
					stress_type = {'a', 'c', 'e', '1', '3', '5'},
				},
				n_hard_gen_pl_unstressed = 'ев',
			},
--[=[ Possibly we don't need this:
			{
				comment = 'Replace "ов", "ев", "ёв" and null to "ей"',

				_if = {stem_type = {'sibilant'}},
				n_hard_gen_pl_stressed = 'ей',
				n_hard_gen_pl_unstressed = 'ей',
				m_hard_gen_pl_stressed = 'ей',
			},
			{
				comment = 'Replace "ь" to "й"',

				_if = {stem_type = {'vowel', 'letter-и'}},
				m_soft_gen_pl_stressed = 'й',
				m_soft_gen_pl_unstressed = 'й',
			},
			{
				comment = 'Replace "ей" to "ев/ёв", and "ь,ей" to "й"',

				_if = {stem_type = {'vowel', 'letter-и'}},
				f_soft_gen_pl_stressed = 'ёв',
				f_soft_gen_pl_unstressed = 'ев',
				m_soft_gen_pl_stressed = 'й',
				m_soft_gen_pl_unstressed = 'й',
			},
]=]--
		},

		-------------------------------------------------------------------------------------------
		{SECTION = 'D. Resolve stressed/unstressed cases of endings'},
		-------------------------------------------------------------------------------------------
		{
			_if = {stress_type = {'a', 'c', 'e', '1', '3', '5'}},
			f_soft_dat_sg = '<f_soft_dat_sg_unstressed>',
			m_soft_ins_sg = '<m_soft_ins_sg_unstressed>',
			n_soft_ins_sg = '<n_soft_ins_sg_unstressed>',
			f_soft_ins_sg = '<f_soft_ins_sg_unstressed>',
			r_prp_sg = '<c_prp_sg_unstressed>',
		},
		{
			_if = {stress_type = {'b', 'd', "d'", 'f', "f'", '2', '4', "4'", '6', "6'",    "b'" }},  -- temp b'
			f_soft_dat_sg = '<f_soft_dat_sg_stressed>',
			m_soft_ins_sg = '<m_soft_ins_sg_stressed>',
			n_soft_ins_sg = '<n_soft_ins_sg_stressed>',
			f_soft_ins_sg = '<f_soft_ins_sg_stressed>',
			r_prp_sg = '<c_prp_sg_stressed>',
		},
		{
			_if = {stress_type = {'a', 'd', "d'", '1', '4', "4'"}},
			m_hard_gen_pl = '<m_hard_gen_pl_unstressed>',
			m_soft_gen_pl = '<m_soft_gen_pl_unstressed>',
			n_hard_gen_pl = '<n_hard_gen_pl_unstressed>',
			n_soft_gen_pl = '<n_soft_gen_pl_unstressed>',
			f_hard_gen_pl = '<f_hard_gen_pl_unstressed>',
			f_soft_gen_pl = '<f_soft_gen_pl_unstressed>',
		},
		{
			_if = {stress_type = {'b', 'c', 'e', 'f', "f'", '2', '3', '5', '6', "6'",    "b'" }},  -- temp b'
			m_hard_gen_pl = '<m_hard_gen_pl_stressed>',
			m_soft_gen_pl = '<m_soft_gen_pl_stressed>',
			n_hard_gen_pl = '<n_hard_gen_pl_stressed>',
			n_soft_gen_pl = '<n_soft_gen_pl_stressed>',
			f_hard_gen_pl = '<f_hard_gen_pl_stressed>',
			f_soft_gen_pl = '<f_soft_gen_pl_stressed>',
		},
		{
			_if = {
				gender = 'n',
				word__endswith = 'ё',
			},
			n_soft_nom_sg = 'ё',
		},

		-------------------------------------------------------------------------------------------
		{SECTION = 'E. Determination of ending (depending on gender and stem type)'},
		-------------------------------------------------------------------------------------------
		{
			_if = {stem_type = {'hard', 'velar', 'sibilant', 'letter-ц', }},
			_then = {
				r_dat_pl = '<c_hard_dat_pl>',
				r_ins_pl = '<c_hard_ins_pl>',
				r_prp_pl = '<c_hard_prp_pl>',
				{
					_if = {gender = 'm'},
					r_nom_sg = '<m_hard_nom_sg>',
					r_gen_sg = '<m_hard_gen_sg>',
					r_dat_sg = '<m_hard_dat_sg>',
					r_ins_sg = '<m_hard_ins_sg>',
					r_nom_pl = '<m_hard_nom_pl>',
					r_gen_pl = '<m_hard_gen_pl>',
				},
				{
					_if = {gender = 'n'},
					r_nom_sg = '<n_hard_nom_sg>',
					r_gen_sg = '<n_hard_gen_sg>',
					r_dat_sg = '<n_hard_dat_sg>',
					r_ins_sg = '<n_hard_ins_sg>',
					r_nom_pl = '<n_hard_nom_pl>',
					r_gen_pl = '<n_hard_gen_pl>',
				},
				{
					_if = {gender = 'f'},
					r_nom_sg = '<f_hard_nom_sg>',
					r_gen_sg = '<f_hard_gen_sg>',
					r_dat_sg = '<f_hard_dat_sg>',
					r_acc_sg = '<f_hard_acc_sg>',
					r_ins_sg = '<f_hard_ins_sg>',
					r_nom_pl = '<f_hard_nom_pl>',
					r_gen_pl = '<f_hard_gen_pl>',
				},
			},
		},
		{
			_if = {stem_type = {'soft', 'vowel', 'letter-и', 'm-3rd', 'f-3rd', 'f-3rd-sibilant'}},
			_then = {
				r_dat_pl = '<c_soft_dat_pl>',
				r_ins_pl = '<c_soft_ins_pl>',
				r_prp_pl = '<c_soft_prp_pl>',
				{
					_if = {gender = 'm'},
					r_nom_sg = '<m_soft_nom_sg>',
					r_gen_sg = '<m_soft_gen_sg>',
					r_dat_sg = '<m_soft_dat_sg>',
					r_ins_sg = '<m_soft_ins_sg>',
					r_nom_pl = '<m_soft_nom_pl>',
					r_gen_pl = '<m_soft_gen_pl>',
				},
				{
					_if = {gender = 'n'},
					r_nom_sg = '<n_soft_nom_sg>',
					r_gen_sg = '<n_soft_gen_sg>',
					r_dat_sg = '<n_soft_dat_sg>',
					r_ins_sg = '<n_soft_ins_sg>',
					r_nom_pl = '<n_soft_nom_pl>',
					r_gen_pl = '<n_soft_gen_pl>',
				},
				{
					_if = {gender = 'f'},
					r_nom_sg = '<f_soft_nom_sg>',
					r_gen_sg = '<f_soft_gen_sg>',
					r_dat_sg = '<f_soft_dat_sg>',
					r_acc_sg = '<f_soft_acc_sg>',
					r_ins_sg = '<f_soft_ins_sg>',
					r_nom_pl = '<f_soft_nom_pl>',
					r_gen_pl = '<f_soft_gen_pl>',
				},
			},
		},


		-------------------------------------------------------------------------------------------
		{SECTION = 'If we have "ё" specific'},
		-------------------------------------------------------------------------------------------
		{
			_if = {specific__match = 'ё'},
			stem_stressed = {'replace', 'stem_stressed', 'е́?([^е]*)$', 'ё%1'},
		},

		-------------------------------------------------------------------------------------------
		{SECTION = 'F. Apply stress type'},
		-------------------------------------------------------------------------------------------
		{
			_if = {stress_type = {'a', 'c', 'e', '1', '3', '5'}},
			stem_sg = '<stem_stressed>',
		},
		{
			_if = {stress_type = {'b', 'd', "d'", 'f', "f'", '2', '4', "4'", '6', "6'",    "b'" }},  -- temp b'
			stem_sg = '<stem>',
			r_nom_sg = {'replace', 'r_nom_sg', '^([аеиоуыюя])', '%1́'},  -- it was added stress here
			r_gen_sg = {'replace', 'r_gen_sg', '^([аеиоуыюя])', '%1́'},  -- it was added stress here
			r_dat_sg = {'replace', 'r_dat_sg', '^([аеиоуыюя])', '%1́'},  -- it was added stress here
			r_ins_sg = {'replace', 'r_ins_sg', '^([аеиоуыюя])', '%1́'},  -- it was added stress here
			r_prp_sg = {'replace', 'r_prp_sg', '^([аеиоуыюя])', '%1́'},  -- it was added stress here
		},
		{
			_if = {
				gender = 'f',
				stress_type = {'b', 'd', 'f', '2', '4', '6',    "b'" },  -- temp b'
			},
			r_acc_sg = {'replace', 'r_acc_sg', '^([аеиоуыюя])', '%1́'},  -- it was added stress here
		},
		{
			_if = {stress_type = {'a', 'd', "d'", 'e', 'f', "f'", '1', '4', "4'", '5', '6', "6'"}},
			stem_pl_nom = '<stem_stressed>',
		},		
		{
			_if = {stress_type = {'b', 'c', '2', '3',    "b'" }},  -- temp b'
			stem_pl_nom = '<stem>',
			r_nom_pl = {'replace', 'r_nom_pl', '^([аеиоуыюя])', '%1́'},  -- it was added stress here
		},		
		{
			_if = {stress_type = {'a', 'd', "d'", '1', '4', "4'"}},
			stem_pl = '<stem_stressed>',
		},		
		{
			_if = {stress_type = {'b', 'c', 'e', 'f', "f'", '2', '3', '5', '6', "6'",    "b'" }},  -- temp b'
			stem_pl = '<stem>',
			r_gen_pl = {'replace', 'r_gen_pl', '^([аеиоуыюя])', '%1́'},  -- it was added stress here
			r_dat_pl = {'replace', 'r_dat_pl', '^([аеиоуыюя])', '%1́'},  -- it was added stress here
			r_ins_pl = {'replace', 'r_ins_pl', '^([аеиоуыюя])', '%1́'},  -- it was added stress here
			r_prp_pl = {'replace', 'r_prp_pl', '^([аеиоуыюя])', '%1́'},  -- it was added stress here
		},

		-------------------------------------------------------------------------------------------
		{SECTION = 'G. Changes for reduced letters cases'},
		-------------------------------------------------------------------------------------------
		{ -- temp solution
			stem_sg_nom = '<stem_sg>',
			stem_pl_gen = '<stem_pl>',
		},
		{
			_if = {specific__match = '%*'},
			{
				{
					_if = {gender = 'm'},
					reduced = 'A',
				},
				{
					_if = {gender = 'n'},
					reduced = 'B',
				},
				{
					_if = {gender = 'f'},
					{
						_if = {stem_type = {'f-3rd', 'f-3rd-sibilant'}},
						_then = {reduced = 'A'},
						_else = {reduced = 'B'},
					},
				},
			},
			{
				_if = {reduced = 'A'},
				_then = {
					{
						reduced_letter = {'match', 'word', '([аеёиоуыэюя])[^аеёиоуыэюя]+$'},
					},
					{
						_if = {reduced_letter = 'о'},
						stem_sg = {'replace', 'stem_sg', 'о́?([^о]+)$', '%1'},
						stem_pl = {'replace', 'stem_pl', 'о́?([^о]+)$', '%1'},
						stem_pl_nom = {'replace', 'stem_pl_nom', 'о́?([^о]+)$', '%1'},
					},
					{
						_if = {reduced_letter = {'е', 'ё'}},
						_then = {
							prev = {'match', 'word', '(.)[её][^её]+$'},
							{
								_if = {prev__match = '[аеёиоуыэюя]'},
								stem_sg = {'replace', 'stem_sg', '[её]́?([^её]+)$', 'й%1'},
								stem_pl = {'replace', 'stem_pl', '[её]́?([^её]+)$', 'й%1'},
								stem_pl_nom = {'replace', 'stem_pl_nom', '[её]́?([^её]+)$', 'й%1'},
								reduced_processed = '1',
							},
							{
								_if = {
									_or = {
										stem_type = 'vowel',
										{
											stem_type = 'velar',
											prev__match = '[^аеёиоуыэюяшжчщц]',
										},
										{
											stem_type__not = {'vowel', 'velar'},
											prev = 'л',
										}
									}
								},
								stem_sg = {'replace', 'stem_sg', '[её]́?([^её]*)$', 'ь%1'},
								stem_pl = {'replace', 'stem_pl', '[её]́?([^её]*)$', 'ь%1'},
								stem_pl_nom = {'replace', 'stem_pl_nom', '[её]́?([^её]*)$', 'ь%1'},
								reduced_processed = '1',
							},
							{
								_if = {reduced_processed__not = '1'},
								stem_sg = {'replace', 'stem_sg', '[её]́?([^её]*)$', '%1'},
								stem_pl = {'replace', 'stem_pl', '[её]́?([^её]*)$', '%1'},
								stem_pl_nom = {'replace', 'stem_pl_nom', '[её]́?([^её]*)$', '%1'},
							},
						}
					},
				},
			},
			{ -- temp solution
				stem_pl_gen = '<stem_pl>',
			},
			{
				_if = {
					reduced = 'B',
					_not = {
						-- we should ignore asterix for 2*b and 2*f (so to process it just like 2b or 2f)
						-- and also the same for (2)-specific and 3,5,6 stem-types
						_or = {
							{
								stem_type = 'soft',
								stress_type = {'b', 'f'},
							},
							{
								specific__match = '(2)',
								stem_type = {'velar', 'letter-ц', 'vowel'},
							},
						},
					},
				},
				_then = {
					{
						_if = {stem_type = 'vowel'},  -- 1).
						_then = {
							_if = {stress_type = {'b', 'c', 'e', 'f', "f'", '2', '3', '5', '6', "6'",    "b'" }},  -- temp b'  -- gen_pl ending stressed  -- TODO: special vars for that
							_then = {stem_pl_gen = {'replace', 'stem_pl_gen', 'ь$', 'е́'}},
							_else = {stem_pl_gen = {'replace', 'stem_pl_gen', 'ь$', 'и'}},
						},
						_else = {
							_if = {stem__match = '[ьй][^аеёиоуыэюя]$'},  -- 2).
							_then = {
								_if = {
									_or = {
										stress_type = {'a', 'd', "d'", '1', '4', "4'"},  -- gen_pl ending unstressed  -- TODO: special vars for that
										stem_type = 'letter-ц',
									},
								},  
								_then = {stem_pl_gen = {'replace', 'stem_pl_gen', '[ьй]([^аеёиоуыэюя])$', 'е%1'}},
								_else = {stem_pl_gen = {'replace', 'stem_pl_gen', '[ьй]([^аеёиоуыэюя])$', 'ё%1'}},
							},
							_else = {  -- 3).
								prev = {'match', 'stem', '(.)[^аеёиоуыэюя]$'},
								{
									_if = {
										_or = {
											prev__match = '[кгх]',  -- 3). а).
											{                       -- 3). б).
												stem_type = 'velar',
												prev__match = '[^жшчщц]',
											},
										},
									},
									stem_pl_gen = {'replace', 'stem_pl_gen', '(.)([^аеёиоуыэюя])$', '%1о%2'},
									reduced_processed = '1',
								},
								{
									_if = {reduced_processed__not = '1'},  -- 3). в).
									_then = {
										_if = {stem_type = 'letter-ц'},
										_then = {stem_pl_gen = {'replace', 'stem_pl_gen', '(.)([^аеёиоуыэюя])$', '%1е%2'}},
										_else = {
											_if = {stress_type = {'b', 'c', 'e', 'f', "f'", '2', '3', '5', '6', "6'",    "b'" }},  -- temp b'  -- gen_pl ending stressed  -- TODO: special vars for that
											_then = {
												_if = {prev__match = '[жшчщ]'},
												_then = {stem_pl_gen = {'replace', 'stem_pl_gen', '(.)([^аеёиоуыэюя])$', '%1о́%2'}},
												_else = {stem_pl_gen = {'replace', 'stem_pl_gen', '(.)([^аеёиоуыэюя])$', '%1ё%2'}},
											},
											_else = {
												stem_pl_gen = {'replace', 'stem_pl_gen', '(.)([^аеёиоуыэюя])$', '%1е%2'},
											},
										},
									},
								},
							},
						},
					},
					{
						_if = {
							stem_type = 'soft',
							word__endswith = 'ня',
							stress_type = 'a',
						},
						r_gen_pl = '',
					},
				},
			},
		},

		-------------------------------------------------------------------------------------------
		{SECTION = 'If we have "ё" specific'},
		-------------------------------------------------------------------------------------------
		{
			_if = {
				specific__match = 'ё',
				r_gen_pl__not_match = '[аеёиоуыэюя]',
				stem_pl_gen__not_match = 'ё',
			},
			stem_pl_gen = {'replace', 'stem_pl_gen', 'е́?([^е]*)$', 'ё%1'},
		},

		-------------------------------------------------------------------------------------------
		{SECTION = 'H. Generate forms'},
		-------------------------------------------------------------------------------------------
		{
			form_nom_sg = '<stem_sg_nom><r_nom_sg>',
			form_gen_sg = '<stem_sg><r_gen_sg>',
			form_dat_sg = '<stem_sg><r_dat_sg>',
			form_ins_sg = '<stem_sg><r_ins_sg>',
			form_prp_sg = '<stem_sg><r_prp_sg>',
			form_nom_pl = '<stem_pl_nom><r_nom_pl>',
			form_gen_pl = '<stem_pl_gen><r_gen_pl>',
			form_dat_pl = '<stem_pl><r_dat_pl>',
			form_ins_pl = '<stem_pl><r_ins_pl>',
			form_prp_pl = '<stem_pl><r_prp_pl>',
		},
		{
			_if = {
				gender = 'f',
				stem_type__not = {'f-3rd', 'f-3rd-sibilant'},
			},
			form_acc_sg = '<stem_sg><r_acc_sg>',
		},
		{
			_if = {stem_type = {'f-3rd', 'f-3rd-sibilant'}},
			_then = { -- temp solution for b'
				_if = {stress_type = "b'"},
				_then = {form_ins_sg = '<stem_stressed><r_ins_sg>'},
				_else = {form_ins_sg = '<stem_sg_nom><r_ins_sg>'},
			},
		},
		{  -- TODO: refactoring
			_if = {
				gender = 'f',
				stress_type = {"d'", "f'", "4'", "6'"},
			},
			form_acc_sg = '<stem_stressed><r_acc_sg>',
		},

		-------------------------------------------------------------------------------------------
		{SUBSECTION = "Add stress if there is no one"},
		{ -- perhaps this is redundant for nom_sg?
			_if = {
				form_nom_sg__match_several = '[аеиоуыэюя]',
				form_nom_sg__not_match = '[́ё]',
			},
			form_nom_sg = {'var_replace', 'form_nom_sg', '([аеиоуыэюя])([^аеиоуыэюя]*)$', '%1́%2'},
		},
		{
			_if = {
				form_gen_pl__match_several = '[аеёиоуыэюя]',
				form_gen_pl__not_match = '[́ё]',
			},
			form_gen_pl = {'var_replace', 'form_gen_pl', '([аеиоуыэюя])([^аеиоуыэюя]*)$', '%1́%2'},
		},

		-------------------------------------------------------------------------------------------
		{SUBSECTION = "Remove stress if there is only one syllable"},
		{ -- TODO: with using NEW functions mechanism
			_if = {form_nom_sg__match_once = '[аеёиоуыэюя]'},
			form_nom_sg = {'var_replace', 'form_nom_sg', '́', ''},
		},
		{
			_if = {form_gen_sg__match_once = '[аеёиоуыэюя]'},
			form_gen_sg = {'var_replace', 'form_gen_sg', '́', ''},
		},
		{
			_if = {form_dat_sg__match_once = '[аеёиоуыэюя]'},
			form_dat_sg = {'var_replace', 'form_dat_sg', '́', ''},
		},
		{
			_if = {form_ins_sg__match_once = '[аеёиоуыэюя]'},
			form_ins_sg = {'var_replace', 'form_ins_sg', '́', ''},
		},
		{
			_if = {form_prp_sg__match_once = '[аеёиоуыэюя]'},
			form_prp_sg = {'var_replace', 'form_prp_sg', '́', ''},
		},
		{
			_if = {form_nom_pl__match_once = '[аеёиоуыэюя]'},
			form_nom_pl = {'var_replace', 'form_nom_pl', '́', ''},
		},
		{
			_if = {form_gen_pl__match_once = '[аеёиоуыэюя]'},
			form_gen_pl = {'var_replace', 'form_gen_pl', '́', ''},
		},
		{
			_if = {form_dat_pl__match_once = '[аеёиоуыэюя]'},
			form_dat_pl = {'var_replace', 'form_dat_pl', '́', ''},
		},
		{
			_if = {form_acc_pl__match_once = '[аеёиоуыэюя]'},
			form_acc_pl = {'var_replace', 'form_acc_pl', '́', ''},
		},
		{
			_if = {form_ins_pl__match_once = '[аеёиоуыэюя]'},
			form_ins_pl = {'var_replace', 'form_ins_pl', '́', ''},
		},
		{
			_if = {form_prp_pl__match_once = '[аеёиоуыэюя]'},
			form_prp_pl = {'var_replace', 'form_prp_pl', '́', ''},
		},

		-------------------------------------------------------------------------------------------
		{SUBSECTION = "Replace 'ё' with 'е' when unstressed"},
		{ -- TODO: with using NEW functions mechanism
			_if = {
				form_nom_sg__match_once = 'ё',
				form_nom_sg__match = '́',
			},
			form_nom_sg = {'replace', 'form_nom_sg', 'ё', 'е'},
		},
		{
			_if = {
				form_gen_sg__match_once = 'ё',
				form_gen_sg__match = '́',
			},
			form_gen_sg = {'replace', 'form_gen_sg', 'ё', 'е'},
		},
		{
			_if = {
				form_dat_sg__match_once = 'ё',
				form_dat_sg__match = '́',
			},
			form_dat_sg = {'replace', 'form_dat_sg', 'ё', 'е'},
		},
		{
			_if = {
				form_acc_sg__match_once = 'ё',
				form_acc_sg__match = '́',
			},
			form_acc_sg = {'replace', 'form_acc_sg', 'ё', 'е'},
		},
		{
			_if = {
				form_ins_sg__match_once = 'ё',
				form_ins_sg__match = '́',
			},
			form_ins_sg = {'replace', 'form_ins_sg', 'ё', 'е'},
		},
		{
			_if = {
				form_prp_sg__match_once = 'ё',
				form_prp_sg__match = '́',
			},
			form_prp_sg = {'replace', 'form_prp_sg', 'ё', 'е'},
		},
		{
			_if = {
				form_nom_pl__match_once = 'ё',
				form_nom_pl__match = '́',
			},
			form_nom_pl = {'replace', 'form_nom_pl', 'ё', 'е'},
		},
		{
			_if = {
				form_gen_pl__match_once = 'ё',
				form_gen_pl__match = '́',
			},
			form_gen_pl = {'replace', 'form_gen_pl', 'ё', 'е'},
		},
		{
			_if = {
				form_dat_pl__match_once = 'ё',
				form_dat_pl__match = '́',
			},
			form_dat_pl = {'replace', 'form_dat_pl', 'ё', 'е'},
		},
		{
			_if = {
				form_acc_pl__match_once = 'ё',
				form_acc_pl__match = '́',
			},
			form_acc_pl = {'replace', 'form_acc_pl', 'ё', 'е'},
		},
		{
			_if = {
				form_ins_pl__match_once = 'ё',
				form_ins_pl__match = '́',
			},
			form_ins_pl = {'replace', 'form_ins_pl', 'ё', 'е'},
		},
		{
			_if = {
				form_prp_pl__match_once = 'ё',
				form_prp_pl__match = '́',
			},
			form_prp_pl = {'replace', 'form_prp_pl', 'ё', 'е'},
		},

		-------------------------------------------------------------------------------------------
		{SUBSECTION = 'Choose accusative forms'},
		{
			_if = {gender = 'n'},
			form_acc_sg = '<form_nom_sg>',
		},
		{
			_if = {gender = 'm'},
			_then = {
				{
					_if = {animate = 'in'},
					form_acc_sg = '<form_nom_sg>',
				},
				{
					_if = {animate = 'an'},
					form_acc_sg = '<form_gen_sg>',
				},
			},
		},
		{
			_if = {stem_type = {'f-3rd', 'f-3rd-sibilant'}},
			form_acc_sg = '<form_nom_sg>',
		},
		{
			_if = {animate = 'in'},
			form_acc_pl = '<form_nom_pl>',
		},
		{
			_if = {animate = 'an'},
			form_acc_pl = '<form_gen_pl>',
		},

		-------------------------------------------------------------------------------------------
		{SECTION = 'If there are no plural forms'},
		-------------------------------------------------------------------------------------------
		{
			comment = 'This rule should be the last one. Otherwise — removing of plural form can be overriden by other classes',

			_if = {st = '1'},  -- if we've received argument "st" equals to "1"
			class = 'singularia_tantum',
		},
	},
	classes = {
		common = {
			nom_sg = '<form_nom_sg>',
			gen_sg = '<form_gen_sg>',
			dat_sg = '<form_dat_sg>',
			acc_sg = '<form_acc_sg>',
			ins_sg = '<form_ins_sg>',
			prp_sg = '<form_prp_sg>',
			nom_pl = '<form_nom_pl>',
			gen_pl = '<form_gen_pl>',
			dat_pl = '<form_dat_pl>',
			acc_pl = '<form_acc_pl>',
			ins_pl = '<form_ins_pl>',
			prp_pl = '<form_prp_pl>',
			stem_type = '<stem_type>',  -- just for testcases
		},
		singularia_tantum = {
			nom_pl = '—',
			gen_pl = '—',
			dat_pl = '—',
			acc_pl = '—',
			ins_pl = '—',
			prp_pl = '—',
		},
	},
}