Module:accel/bg

local rfind = mw.ustring.find local rsplit = mw.text.split local rsub = mw.ustring.sub

local function generate_pronunc(target) pronunc_parts = {} table.insert(pronunc_parts, "* ") table.insert(pronunc_parts, "* ") return table.concat(pronunc_parts, "\n") end

-- Parses a participle form conveyed by inflection tags. local function parse_participle_form(form) local part = {}; part.gender = nil; part.kind = nil local is_definite_form = false local tag_set = rsplit(form, "|") for _, tag in ipairs(tag_set) do		if tag == "def" then is_definite_form = true elseif tag == "m" then part.gender = "m" elseif tag == "f" then part.gender = "f" elseif tag == "n" then part.gender = "n" elseif tag == "pres" then part.kind = "pres" elseif tag == "aor" then part.kind = "aor" elseif tag == "pass" then part.kind = "pass" elseif tag == "impf" then part.kind = "impf" elseif tag == "adv" then part.kind = "adv" end end part.is_base_form = part.kind == "adv" or		((not is_definite_form) and part.gender == "m") return part end

return { generate = function (params, entry) local form, target, pos = params.form, params.target, params.pos entry.pronunc = generate_pronunc(target) -- Special handling for relational adjectives of nouns if form == "relational adjective" then local declension_spec = "<!" if rsub(target, -2) == "ен" then declension_spec = declension_spec .. "*" -- Adjectives in -ен are usually reducible end

entry.pos_header = "Adjective" entry.etymology = "" entry.head = " " entry.def = " " entry.declension = " \n" end -- Special handling for female equivalent nouns, noun diminutives and augmentatives, -- and abstract nouns from adjectives. if pos == "noun" and (form == "f" or form == "diminutive" or form == "augmentative" or form == "abstract noun") then entry.etymology = "" entry.declension = " " if form == "f" then entry.head = "" else entry.head = " " end end -- Ensure participles and participle forms show under the correct POS header, -- and use the correct Bulgarian headword templates. if pos == "verb" and rfind(form, "|part$") then local part = parse_participle_form(form) entry.pos_header = "Participle" if part.is_base_form then if part.kind == "adv" or part.kind == "pass" or part.kind == "pres" then entry.head = "" else -- Sometimes the past active aorist and past active imperfect participle -- have the same form. If we provide the participle kind to the headword template, -- Module:accel won't be able to merge the two inflections, so we have to -- do it manually when the non-lemma entry page is being created. entry.head = " " end else -- For inflected participle forms, we just specify the gender (if in the singular). local gender = "" if part.gender then gender = "|g=" .. part.gender end entry.head = "" end end -- Use appropriate headword and declension templates for verbal nouns. -- For now, only the base form of verbal nouns is handled. if pos == "verb" and form == "indef|s|vnoun" then local origin = params.origin entry.pos_header = "Noun" entry.head = "" entry.def = "" entry.declension = " " entry.etymology = "From ." end end }