--[=[ This module implements the headword templates {{ru-noun}}, {{ru-adj}}, {{ru-adv}}, {{ru-noun+}}, etc. The main entry point is show(), which is meant to be called from one of the above templates. However, {{ru-noun+}} uses the entry point noun_plus(), and {{ru-noun-m}} (not currently used) uses the entry point noun_multi(). When calling show(), the first parameter of the #invoke call is the part of speech. Other parameters are taken from the parent template call. The implementations for different types of headwords (different parts of speech) are set in pos_functions[POS] for a given POS (part of speech). The value is a 2-argument function of (ARGS, DATA): -- ARGS on entry is initialized to the parent template call's arguments, with blank arguments converted to nil. -- DATA on entry is initialized to a table, with entries like this: local data = {lang = lang, pos_category = poscat, categories = {}, heads = {}, translits = {}, genders = {}, inflections = {}} where: -- LANG is an object describing the language. -- POS_CATEGORY is the (plural) part of speech, e.g. "nouns" or "verbs". -- CATEGORIES on entry is a list of categories. There will be one category corresponding to the part of speech (e.g. [[Category:Russian adverbs]]), and possibly additional categories such as [[Category:Russian terms needing accents]] and [[Category:Russian terms with irregular pronunciations]]. On exit it may contain additional categories to place the page in. -- HEADS on entry is a list of the headwords, taken directly from arguments 'head', 'head2', 'head3', ... -- TRANSLITS on entry is a list of translits, matching one-to-one with heads in HEADS. These come either from 'tr', 'tr2', etc. or from auto-transliterating the corresponding head (i.e. the translits will always be non-empty whether or not the user explicitly specified the translit). -- GENDERS on entry is an empty list. On exit it should be the appropriate gender settings, and will be passed directly to full_headword() in [[Module:headword]]. See the documentation for that module for info on the format of this setting. -- INFLECTIONS on entry is an empty list. On exit it should be the appropriate inflections to be displayed in the headword, and will be passed directly to full_headword() in [[Module:headword]]. See the documentation for that module for info on the format of this setting.]=]--localm_common=require("Module:ru-common")localm_links=require("Module:links")localm_headword=require("Module:headword")localm_utilities=require("Module:utilities")localut=require("Module:utils")localm_table_tools=require("Module:table tools")localm_debug=require("Module:debug")localm_ru_translit=require("Module:ru-translit")localexport={}localpos_functions={}locallang=require("Module:languages").getByCode("ru")localIRREGMARKER="△"localHYPMARKER="⟐"locallatin_text_class="[a-zščžěáéíóúýàèìòùỳâêîôûŷạẹịọụỵȧėȯẏ]"-- Forward referenceslocaldo_nounlocalu=mw.ustring.charlocalrfind=mw.ustring.findlocalrsubn=mw.ustring.gsublocalrmatch=mw.ustring.matchlocalrsplit=mw.text.splitlocalulower=mw.ustring.lowerlocalAC=u(0x0301)-- acute = ́localfunctionine(x)returnx~=""andx;end-- version of rsubn() that discards all but the first return valuelocalfunctionrsub(term,foo,bar)localretval=rsubn(term,foo,bar)returnretvalend-- version of rsubn() that returns a 2nd argument boolean indicating whether-- a substitution was made.localfunctionrsubb(term,foo,bar)localretval,nsubs=rsubn(term,foo,bar)returnretval,nsubs>0endlocalfunctiontrack(page)m_debug.track("ru-headword/"..page)returntrueend-- Clone parent's args while also assigning nil to empty strings.localfunctionclone_args(frame)localargs={}forpname,paraminpairs(frame:getParent().args)doifparam==""thenargs[pname]=nilelseargs[pname]=paramendendreturnargsend-- Iterate over a chain of parameters, FIRST then PREF2, PREF3, ...,-- inserting into LIST (newly created if omitted). Return LIST.localfunctionprocess_arg_chain(args,first,pref,list)ifnotlistthenlist={}endlocalval=args[first]locali=2whilevaldotable.insert(list,val)val=args[pref..i]i=i+1endreturnlistend-- The main entry point.functionexport.show(frame)localargs=clone_args(frame)localPAGENAME=mw.title.getCurrentTitle().textlocalNAMESPACE=mw.title.getCurrentTitle().nsTextlocalposcat=ine(frame.args[1])orerror("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")localdata={lang=lang,pos_category=poscat,categories={},heads={},translits={},genders={},inflections={}}localtracking_categories={}-- Get the head parameters-- First get the 1st parameter. The remainder is named head2=, head3= etc.localhead=args[1]orPAGENAMElocali=2whileheaddo-- catch errors in arguments where headword doesn't match page title,-- but only in the main namespace; for the moment, do only with tracking;-- FIXME, duplicates tracking down below a bit, clean that stuff uplocalhead_noaccent=m_common.remove_accents(m_links.remove_links(head))ifNAMESPACE==""andhead_noaccent~=PAGENAMEthentrack("bad-headword")--error("Headword " .. head .. " doesn't match pagename " ..-- PAGENAME)end-- The following are for bot scriptsifrfind(head," ")thentrack("space-in-headword/"..poscat)elseifrfind(head,".%-.")then-- We only look for hyphens between characters so we don't-- get tripped up by prefixes and suffixestrack("hyphen-no-space-in-headword/"..poscat)endifm_common.needs_accents(head)thenifnotargs.notrcatthentable.insert(data.categories,"Russian terms needing accents")endendifrfind(ulower(head),latin_text_class)thentrack("latin-text-in-headword")endifrfind(head,"ьо")thentrack("ьо")endtable.insert(data.heads,head)head=args["head"..i]i=i+1end-- Get transliteration(s)locali=0for_,headinipairs(data.heads)dohead=m_links.remove_links(head)localhead_noaccents=rsub(head,"\204\129","")localtr_gen=mw.ustring.toNFC(lang:transliterate(head,nil))localtr_gen_noaccents=mw.ustring.toNFC(lang:transliterate(head_noaccents,nil))i=i+1localtrifi==1thentr=args.trelsetr=args["tr"..i]endiftrthenifnotargs.notrcatthentable.insert(data.categories,"Russian terms with irregular pronunciations")endlocaltr_fixed=trtr_fixed=rsub(tr_fixed,"ɛ","e")tr_fixed=rsub(tr_fixed,"([eoéó])v([oó])$","%1g%2")tr_fixed=rsub(tr_fixed,"([eoéó])v([oó][- ])","%1g%2")tr_fixed=mw.ustring.toNFC(tr_fixed)iftr==tr_genortr==tr_gen_noaccentsthentable.insert(tracking_categories,"ru headword with tr/redundant")--elseif tr_fixed == tr_gen then-- table.insert(tracking_categories, "ru headword with tr/with manual adjustment")elseifrfind(tr,",")thentable.insert(tracking_categories,"ru headword with tr/comma")elseifhead_noaccents==PAGENAMEthenifnotargs.notrcatthentable.insert(tracking_categories,"ru headword with tr/headword is pagename")endelsetable.insert(tracking_categories,"ru headword with tr/headword not pagename")endelselocalorighead,transformed_head=m_ru_translit.apply_tr_fixes(head)iforighead~=transformed_headandnotargs.notrcatthentable.insert(data.categories,"Russian terms with irregular pronunciations")endtr=tr_genendtable.insert(data.translits,tr)endifpos_functions[poscat]thenpos_functions[poscat](args,data)endreturnm_headword.full_headword(data)..m_utilities.format_categories(tracking_categories,lang,nil)endlocalfunctionnoun_plus_or_multi(frame,multi)localargs=clone_args(frame)PAGENAME=mw.title.getCurrentTitle().textlocalposcat=ine(frame.args[1])orerror("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")localold=ine(frame.args.old)-- default value of n=, used in ru-proper noun+ where ndef=sg is setlocalndef=ine(frame.args.ndef)args.ndef=args.ndeforndeflocalm_noun=require("Module:ru-noun")ifmultithenargs=m_noun.do_generate_forms_multi(args,old)elseargs=m_noun.do_generate_forms(args,old)endlocaldata={lang=lang,pos_category=poscat,categories={},heads={},translits={},genders={},inflections={}}-- do explicit genders using g=, g2=, etc.data.genders=process_arg_chain(args,"g","g",data.genders)-- if none, do inferred or explicit genders taken from declension;-- clone because will get destructively modified by do_noun()if#data.genders==0thenifargs["g2"]orargs["g3"]orargs["g4"]thenerror("Cannot specify g2=, g3= or g4= without g=")enddata.genders=mw.clone(args.genders)endlocalsaw_note=false-- Given a list of {RU, TR} pairs, where TR may be nil, separate off the-- footnote symbols from RU and TR, link the remainder if it's not already-- linked, and remove monosyllabic accents (but not from multiword-- expressions).localfunctionprepare_entry(list,ishead)ifnotlistor#list==0thenreturn{{"-"}}endlocalnewlist={}for_,xinipairs(list)dolocalru,tr=x[1],x[2]-- separate_notes() just returns the note, but get_notes() adds-- <sup>...</sup>. We want the former for checking whether the-- note is nonempty after removing IRREGMARKER (if we use the-- latter we'll get <sup></sup> in the case of just IRREGMARKER),-- but the latter when generating the inflectional form.ifnotisheadand(rfind(ru,"[%[|%]]")ortrandrfind(tr,"[%[|%]]"))thentrack("form-with-link")endlocalruentry,runotes=m_table_tools.separate_notes(ru)localsawhyprunotes=rsub(runotes,IRREGMARKER,"")-- remove note of irregularityrunotes,sawhyp=rsubb(runotes,HYPMARKER,"")ifrunotes~=""thensaw_note=trueendrunotes=m_table_tools.superscript_notes(runotes)localtrentry,trnotesiftrthentrentry,trnotes=m_table_tools.separate_notes(tr)trnotes=rsub(trnotes,IRREGMARKER,"")-- remove note of irregularitytrnotes=m_table_tools.superscript_notes(trnotes)endifm_common.is_monosyllabic(ruentry)thenruentry=m_common.remove_accents(ruentry)iftrentrythentrentry=m_common.remove_accents(trentry)endendifsawhypthentable.insert(newlist,{ruentry..runotes..HYPMARKER,trentryandtrentry..trnotes..HYPMARKER})elseifisheadthentable.insert(newlist,{ruentry..runotes,trentryandtrentry..trnotes})elselocalruspan,trspanifruentry=="-"thenruspan="-"elseifrfind(ruentry,"[%[|%]]")then-- don't add links around a form that's already linkedruspan=ruentry..runoteselseifoldthenruspan="[["..com.remove_jo(ruentry).."|"..ruentry.."]]"..runoteselseruspan="[["..ruentry.."]]"..runotesendiftrentrythentrspan=trentry..trnotesendtable.insert(newlist,{ruspan,trspan})endendreturnnewlistendlocalfunctionremove_tr(list)localnewlist={}for_,xinipairs(list)dotable.insert(newlist,x[1])endreturnnewlistendlocalargsn=args.norargs.ndeflocalgenitives,plurals,genplsifargsn=="p"thendata.heads=prepare_entry(args.nom_pl_linked,"ishead")genitives=prepare_entry(args.gen_pl)plurals={{"-"}}genpls={{"-"}}elsedata.heads=prepare_entry(args.nom_sg_linked,"ishead")genitives=prepare_entry(args.gen_sg)plurals=argsn=="s"and{{"-"}}orprepare_entry(args.nom_pl)genpls=argsn=="s"and{{"-"}}orprepare_entry(args.gen_pl)endlocalfeminines=process_arg_chain(args,"f","f")-- do feminineslocalmasculines=process_arg_chain(args,"m","m")-- do masculineslocalirregtr=falsefor_,headinipairs(data.heads)dolocalru,tr=head[1],head[2]-- The following are for bot scriptsifrfind(ru," ")thentrack("space-in-headword/"..poscat)elseifrfind(ru,".%-.")then-- We only look for hyphens between characters so we don't-- get tripped up by prefixes and suffixestrack("hyphen-no-space-in-headword/"..poscat)endifnottrthentr=lang:transliterate(m_links.remove_links(ru))elseirregtr=trueendtable.insert(data.translits,tr)endifirregtrandnotargs.notrcatthentable.insert(data.categories,"Russian terms with irregular pronunciations")end-- Combine adjacent heads by their transliteration (which should always-- be different, as identical heads including translit have previously-- been removed)data.heads=remove_tr(data.heads)locali=1whilei<#data.headsdoifdata.heads[i]==data.heads[i+1]thendata.translits[i]=data.translits[i]..", "..data.translits[i+1]table.remove(data.heads,i+1)table.remove(data.translits,i+1)elsei=i+1endend-- Eliminate transliteration from genitives and remove duplicates-- (which may occur when there are two translits for a form)genitives=remove_tr(genitives)localgenitives_no_dups={}for_,geninipairs(genitives)dout.insert_if_not(genitives_no_dups,gen)endgenitives=genitives_no_dups-- Eliminate transliteration from plurals and remove duplicates-- (which may occur when there are two translits for a form)plurals=remove_tr(plurals)localplurals_no_dups={}for_,plinipairs(plurals)dout.insert_if_not(plurals_no_dups,pl)endplurals=plurals_no_dups-- Eliminate transliteration from genitive plurals and remove duplicates-- (which may occur when there are two translits for a form)genpls=remove_tr(genpls)localgenpls_no_dups={}for_,gplinipairs(genpls)dout.insert_if_not(genpls_no_dups,gpl)endgenpls=genpls_no_dupsdo_noun(data,argsn=="s",genitives,plurals,genpls,feminines,masculines,poscat=="proper nouns")returnm_headword.full_headword(data)..(args.notesandsaw_noteand" "..'<span class="ib-brac"><span class="qualifier-brac">(</span></span>'..'<span class="ib-content"><span class="qualifier-content">'..args.notes..'</span></span><span class="ib-brac"><span class="qualifier-brac">)</span></span>'or"")end-- External entry point; implementation of {{ru-noun+}}.functionexport.noun_plus(frame)returnnoun_plus_or_multi(frame,false)end-- External entry point; implementation of {{ru-noun-m}}.functionexport.noun_multi(frame)returnnoun_plus_or_multi(frame,true)endpos_functions["proper nouns"]=function(args,data)pos_functions["nouns"](args,data,true)endpos_functions["pronouns"]=function(args,data)pos_functions["nouns"](args,data)end-- Display additional inflection information for a nounpos_functions["nouns"]=function(args,data,proper)process_arg_chain(args,2,"g",data.genders)-- do genderslocalgenitives=process_arg_chain(args,3,"gen")-- do genitiveslocalplurals=process_arg_chain(args,4,"pl")-- do pluralslocalgenpls=process_arg_chain(args,5,"genpl")-- do genitive pluralslocalfeminines=process_arg_chain(args,"f","f")-- do feminineslocalmasculines=process_arg_chain(args,"m","m")-- do masculinesdo_noun(data,proper,genitives,plurals,genpls,feminines,masculines,proper)enddo_noun=function(data,no_plural,genitives,plurals,genpls,feminines,masculines,proper)if#data.genders==0thenifmw.title.getCurrentTitle().nsText~="Template"thenerror("Gender must be specified")elsetable.insert(data.genders,"?")endend-- Process the genderslocalsingular_genders={["m"]=true,["m-?"]=true,["m-an"]=true,["m-in"]=true,["f"]=true,["f-?"]=true,["f-an"]=true,["f-in"]=true,["n"]=true,["n-an"]=true,["n-in"]=true}localplural_genders={["p"]=true,-- This is needed because some invariant plurale tantums have no gender to speak of["?-p"]=true,["an-p"]=true,["in-p"]=true,["m-p"]=true,["m-?-p"]=true,["m-an-p"]=true,["m-in-p"]=true,["f-p"]=true,["f-?-p"]=true,["f-an-p"]=true,["f-in-p"]=true,["n-p"]=true,["n-?-p"]=true,["n-an-p"]=true,["n-in-p"]=true}localreal_genders={}fori,ginipairs(data.genders)doifg=="m"theng="m-?"elseifg=="m-p"theng="m-?-p"elseifg=="f"andplurals[1]~="-"andnotno_pluraltheng="f-?"elseifg=="f-p"theng="f-?-p"elseifg=="p"theng="?-p"endifnotsingular_genders[g]andnotplural_genders[g]andg~="?"andg~="?-in"andg~="?-an"thenerror("Unrecognized gender: "..g)enddata.genders[i]=glocalfirst_letter=g:sub(1,1)-- Categorize by genderiffirst_letter=="m"thenut.insert_if_not(real_genders,"m")table.insert(data.categories,"Russian masculine nouns")elseiffirst_letter=="f"thenut.insert_if_not(real_genders,"f")table.insert(data.categories,"Russian feminine nouns")elseiffirst_letter=="n"thenut.insert_if_not(real_genders,"n")table.insert(data.categories,"Russian neuter nouns")end-- Categorize by animacyifrfind(g,"an")thentable.insert(data.categories,"Russian animate nouns")elseifrfind(g,"in")thentable.insert(data.categories,"Russian inanimate nouns")end-- Categorize by numberifplural_genders[g]thentable.insert(data.categories,"Russian pluralia tantum")ifg=="?-p"org=="an-p"org=="in-p"thentable.insert(data.categories,"Russian pluralia tantum with incomplete gender")endendendif#real_genders>1thentable.insert(data.categories,"Russian nouns with multiple genders")endlocalfunctionadd_forms(inflection,forms)fori,forminipairs(forms)doifrfind(form,HYPMARKER)thenform=rsub(form,HYPMARKER,"")table.insert(inflection,{term=form,hypothetical=true})elsetable.insert(inflection,form)endifm_common.needs_accents(form)thentable.insert(data.categories,"Russian noun inflections needing accents")endendend-- Add the genitive formsifgenitives[1]=="-"thentable.insert(data.inflections,{label="[[Appendix:Glossary#indeclinable|indeclinable]]"})table.insert(data.categories,"Russian indeclinable nouns")elseif#genitives>0thenlocalgen_parts={label="genitive"}add_forms(gen_parts,genitives)table.insert(data.inflections,gen_parts)end-- Add the plural forms-- If the noun is a plurale tantum, then ignore the 4th parameter altogetherifgenitives[1]=="-"then-- do nothingelseifplural_genders[data.genders[1]]thentable.insert(data.inflections,{label="[[Appendix:Glossary#plurale tantum|plurale tantum]]"})elseifplurals[1]=="-"thenifnotproperthentable.insert(data.inflections,{label="[[Appendix:Glossary#uncountable|uncountable]]"})table.insert(data.categories,"Russian uncountable nouns")endelseif#plurals>0thenlocalpl_parts={label="nominative plural"}add_forms(pl_parts,plurals)--This can't work currently because the forms in plurals are already--linked with spans around them, superscripted notes, etc.--for _, form in ipairs(plurals) do-- if not rfind(form, HYPMARKER) and not mw.title.new(form).exists then-- table.insert(categories, "Russian nouns with missing plurals")-- end--endtable.insert(data.inflections,pl_parts)end-- Add the genitive plural formsifgenitives[1]=="-"orplural_genders[data.genders[1]]orplurals[1]=="-"then-- indeclinable, plurale tantum or uncountable; do nothingelseifgenpls[1]=="-"thentable.insert(data.inflections,{label="genitive plural missing"})elseif#genpls>0thenlocalgenpl_parts={label="genitive plural"}add_forms(genpl_parts,genpls)table.insert(data.inflections,genpl_parts)end-- Add the feminine formsif#feminines>0thenlocalf_parts={label="feminine"}add_forms(f_parts,feminines)table.insert(data.inflections,f_parts)end-- Add the masculine formsif#masculines>0thenlocalm_parts={label="masculine"}add_forms(m_parts,masculines)table.insert(data.inflections,m_parts)endendlocalfunctiongenerate_informal_comp(comp)ifrfind(comp,"е́?е$")thenreturnrsub(comp,"(е́?)е$","%1й")elsereturnnilendendlocalfunctiongenerate_po_variant(comp)ifrfind(comp,"е$")orrfind(comp,"е́?й$")thenreturn"[["..comp.."|(по)"..comp.."]]"elsereturncompendendlocalallowed_endings={{"ый","yj"},{"ий","ij"},{"о́й","o"..AC.."j"}}localvelar_to_translit={["к"]="k",["г"]="g",["х"]="x"}localvelar_to_palatal={["к"]="ч",["г"]="ж",["х"]="ш",["k"]="č",["g"]="ž",["x"]="š"}-- Generate the comparative(s) given the positive(s). Note that this is written-- to take in and generate comparative(s) for transliteration(s) as well as-- Russian. This isn't currently used by {{ru-adjective}} but will be used by-- a bot that generates entries for comparatives.localfunctiongenerate_comparative(heads,trs,compspec)localcomps={}ifnotrfind(compspec,"^%+")thenerror("Compspec '"..compspec.."' must begin with + in this function")endcompspec=rsub(compspec,"^%+","")fori,headinipairs(heads)dolocaltr=m_common.decompose(trs[i])localremoved_ending=falseforj,endingpairinipairs(allowed_endings)doifrfind(head,endingpair[1].."$")thenifnotrfind(tr,endingpair[2].."$")thenerror("Translit '"..tr.."' doesn't end with expected '"..endingpair[2].."', corresponding to head '"..head.."'")endifendingpair[1]=="о́й"thenifcompspec=="a"thenerror("Short stress pattern a not allowed with ending-stressed adjectives")elseifcompspec==""thencompspec="b"endendhead=rsub(head,endingpair[1].."$","")tr=rsub(tr,endingpair[2].."$","")removed_ending=truebreakendendifnotremoved_endingthenerror("Head '"..head.."' doesn't end with expected ending")endlocalcomp,comptrifrfind(head,"[кгх]$")thenstemhead,lastheadchar=rmatch(head,"^(.*)(.)$")stemtr,lasttrchar=rmatch(tr,"^(.*)(.)$")ifvelar_to_translit[lastheadchar]~=lasttrcharthenerror("Translit '"..tr.."' doesn't end with transliterated equivalent of last char '"..lastheadchar.."' of head '"..head.."'")endcomp,comptr=m_common.make_ending_stressed(stemhead,stemtr)comp=comp..velar_to_palatal[lastheadchar].."е"-- Cyrillic еcomptr=comptr..velar_to_palatal[lasttrchar].."e"-- Latin eelseifcompspec==""orcompspec=="a"thencomp=head.."ее"-- Cyrillic ееcomptr=tr.."ee"-- Latin eeelse-- end-stressed comparative, including pattern a'comp,comptr=m_common.make_unstressed_once(head,tr)comp=comp.."е́е"-- Cyrillic е́еcomptr=comptr.."e"..AC.."e"-- Latin decomposed éeendut.insert_if_not(comps,{comp,comptr})endreturncompsend-- Meant to be called from a botfunctionexport.generate_comparative(frame)localcomps=ine(frame.args[1])orerror("Must specify comparative(s) in parameter 1")localcompspec=ine(frame.args[2])or""comps=rsplit(comps,",")localheads={}localtrs={}for_,compinipairs(comps)dolocalsplitvals=rsplit(comp,"//")if#splitvals>2thenerror("HEAD or HEAD//TR expected: "..comp)endtable.insert(heads,splitvals[1])table.insert(trs,#splitvals==1andlang:transliterate(splitvals[1],nil)orsplitvals[2])endcomps=generate_comparative(heads,trs,compspec)localcombined_comps={}for_,compinipairs(comps)dotable.insert(combined_comps,comp[1].."//"..comp[2])endreturnm_common.recompose(table.concat(combined_comps,","))end-- Display additional inflection information for an adjectivepos_functions["adjectives"]=function(args,data)localcomps=process_arg_chain(args,2,"comp")-- do comparativeslocalsups=process_arg_chain(args,3,"sup")-- do superlativesif#comps>0thenlocalcomp_parts={label="comparative"}localfunctioninsert_comp(comp)ut.insert_if_not(comp_parts,generate_po_variant(comp))ifnotargs["noinf"]thenlocalinformal=generate_informal_comp(comp)ifinformalthenut.insert_if_not(comp_parts,generate_po_variant(informal))endendifm_common.needs_accents(comp)thentable.insert(data.categories,"Russian adjective inflections needing accents")endendfor_,compinipairs(comps)doifcomp=="peri"thenfor_,headinipairs(data.heads)dout.insert_if_not(comp_parts,"[[бо́лее]] "..head)endelseifrfind(comp,"^+")thenlocalautocomps=generate_comparative(data.heads,data.translits,comp)for_,autocompinipairs(autocomps)doinsert_comp(autocomp[1])endelseinsert_comp(comp)endendtable.insert(data.inflections,comp_parts)endif#sups>0thenlocalsup_parts={label="superlative"}for_,supinipairs(sups)doifsup=="peri"thenfor_,headinipairs(data.heads)dotable.insert(sup_parts,"[[са́мый]] "..head)endelsetable.insert(sup_parts,sup)ifm_common.needs_accents(sup)thentable.insert(data.categories,"Russian adjective inflections needing accents")endendendtable.insert(data.inflections,sup_parts)endend-- Display additional inflection information for an adverbpos_functions["adverbs"]=function(args,data)localcomps=process_arg_chain(args,2,"comp")-- do comparativesif#comps>0thenlocalencoded_head=""ifdata.heads[1]~=""then-- This is decoded again by [[WT:ACCEL]].encoded_head=" origin-"..data.heads[1]:gsub("%%","."):gsub(" ","_")endlocalcomp_parts={label="comparative",accel="comparative-form-of"..encoded_head}for_,compinipairs(comps)dout.insert_if_not(comp_parts,generate_po_variant(comp))ifnotargs["noinf"]thenlocalinformal=generate_informal_comp(comp)ifinformalthenut.insert_if_not(comp_parts,generate_po_variant(informal))endendifm_common.needs_accents(comp)thentable.insert(data.categories,"Russian adverb comparatives needing accents")endendtable.insert(data.inflections,comp_parts)endend-- Display additional inflection information for a verb and verbal combining formlocalfunctiondo_verb(args,data,pos)localcform=pos=="verbal combining forms"ifcformthentable.insert(data.categories,"Russian verbs")end-- Aspectlocalaspect=args[2]ormw.title.getCurrentTitle().nsText=="Template"and"?"ifaspect=="impf"thentable.insert(data.genders,"impf")table.insert(data.categories,"Russian imperfective verbs")elseifaspect=="pf"thentable.insert(data.genders,"pf")table.insert(data.categories,"Russian perfective verbs")elseifaspect=="both"thentable.insert(data.genders,"impf")table.insert(data.genders,"pf")table.insert(data.categories,"Russian imperfective verbs")table.insert(data.categories,"Russian perfective verbs")table.insert(data.categories,"Russian biaspectual verbs")elseifaspect=="?"thentable.insert(data.genders,"?")table.insert(data.categories,"Russian verbs needing aspect")elseifnotaspectthenerror("Missing Russian verb aspect, should be 'pf', 'impf', 'both' or '?'")elseerror("Invalid Russian verb aspect '"..aspect.."', should be 'pf', 'impf', 'both' or '?'")endifpos=="verbal combining forms"thentable.insert(data.categories,"Russian verbal combining forms|"..rsub(data.heads[1],"^%-",""))end-- Get the imperfective parameters-- First get the impf= parameter. The remainder is named impf2=, impf3= etc.localimperfectives={}localform=args.impflocali=2whileformdotable.insert(imperfectives,form)form=args["impf"..i]i=i+1end-- Get the perfective parameters-- First get the pf= parameter. The remainder is named pf2=, pf3= etc.localperfectives={}localform=args.pflocali=2whileformdotable.insert(perfectives,form)form=args["pf"..i]i=i+1end-- Add the imperfective formsif#imperfectives>0thenifaspect=="impf"thenerror("Can't specify imperfective counterparts for an imperfective verb")endlocalimpf_parts={label="imperfective"}fori,forminipairs(imperfectives)dotable.insert(impf_parts,form)ifm_common.needs_accents(form)thentable.insert(data.categories,"Russian verb inflections needing accents")endendtable.insert(data.inflections,impf_parts)end-- Add the perfective formsif#perfectives>0thenifaspect=="pf"thenerror("Can't specify perfective counterparts for a perfective verb")endlocalpf_parts={label="perfective"}fori,forminipairs(perfectives)dotable.insert(pf_parts,form)ifm_common.needs_accents(form)thentable.insert(data.categories,"Russian verb inflections needing accents")endendtable.insert(data.inflections,pf_parts)endendpos_functions["verbs"]=function(args,data)do_verb(args,data,"verbs")endpos_functions["verbal combining forms"]=function(args,data)do_verb(args,data,"verbal combining forms")endreturnexport-- For Vim, so we get 4-space tabs-- vim: set ts=4 sw=4 noet: