Module:Head
This is the documentation for Module:Head, the headword-line renderer for the Yezur wiki's Dictionary. It is not called directly: Template:Head invokes it with {{#invoke:Head|head|code|pos|head=…|class=…}}, placed directly beneath a part-of-speech heading in an entry. The language name and the leading asterisk carried by reconstructed languages are read from the registry in Module:Languages, which also backs {{l}}, {{m}} and {{d}}, so all four agree on how a language is named and written.
Parameters
| Parameter | Purpose |
|---|---|
1 |
The language's registry code, such as YAQ-HE or YBS-PJ. Case is normalised to upper case before lookup. A code absent from the registry stands in for the language name in the category names, in upper case, and carries no asterisk.
|
2 |
The part of speech, normalised to lower case: noun, verb, adjective, verb form and so on. It supplies the category names and is not itself displayed.
|
head |
The headword form. Defaults to the page name without its namespace prefix when omitted, which is the usual case; it is given explicitly where the page name and the citation form differ. |
class |
An inflection class from the table below. A class the language and part of speech do not define is ignored, and the headword renders as though none had been given. |
Surrounding whitespace is trimmed from all four. The remaining parameters of Template:Head — gloss, register, etym_type, etym_source and notes — never reach the module. They feed the Lexemes Cargo row, which the template files itself.
Output
The module returns the headword in bold, preceded by * when the registry marks the language as reconstructed, then the note for a recognised inflection class, then the categories. A noun class shows its gender abbreviation and, where the class has one, an italic declension label; a verb class shows its conjugation label alone. So {{head|YAQ-HE|noun|class=F|head=αβισι}} gives αβισι f, and {{head|YAQ-HE|verb|class=IS}} gives the page name in bold followed by (IS-class).
Inflection classes
Classes are defined in the module, by registry code and then by part of speech. Only the languages below have them; for every other language class has no effect.
| Language | Part of speech | class |
Shown after the headword | Class category |
|---|---|---|---|---|
Middle Airananwe (YAR-AI) |
noun | M1 |
m (first-declension) | Middle Airananwe first-declension masculine nouns |
M2 |
m (second-declension) | Middle Airananwe second-declension masculine nouns | ||
F1 |
f (first-declension) | Middle Airananwe first-declension feminine nouns | ||
F2 |
f (second-declension) | Middle Airananwe second-declension feminine nouns | ||
Gaillean (YAQ-GA) |
noun | M1 |
m (first-declension) | Gaillean first-declension masculine nouns |
M2 |
m (second-declension) | Gaillean second-declension masculine nouns | ||
MX |
m (irregular) | Gaillean irregular masculine nouns | ||
F |
f | Gaillean feminine nouns | ||
FX |
f (irregular) | Gaillean irregular feminine nouns | ||
N1 |
n (first-declension) | Gaillean first-declension neuter nouns | ||
N2 |
n (second-declension) | Gaillean second-declension neuter nouns | ||
NX |
n (irregular) | Gaillean irregular neuter nouns | ||
Ancient Hertic (YAQ-HE) |
noun | M1 |
m (first-declension) | Ancient Hertic first-declension masculine nouns |
M2 |
m (second-declension) | Ancient Hertic second-declension masculine nouns | ||
F |
f | Ancient Hertic feminine nouns | ||
N1 |
n (first-declension) | Ancient Hertic first-declension neuter nouns | ||
N2 |
n (second-declension) | Ancient Hertic second-declension neuter nouns | ||
Ancient Hertic (YAQ-HE) |
verb | IS |
(IS-class) | Ancient Hertic IS-class verbs |
OO |
(OO-class) | Ancient Hertic OO-class verbs |
Categories
Nothing is categorised when the language code is empty; the module then returns the bold headword alone.
With a code and a part of speech, the page is filed under <Language> <part of speech, pluralised> — Pjany adjectives, Ancient Hertic nouns. Plurals are formed in English: a final y not preceded by a vowel becomes ies, an ending in s, x, z, ch or sh takes es, and everything else takes s; part of speech is special-cased to parts of speech.
A second category records lemma status, and is filed whether or not a part of speech is given. A part of speech whose name contains a space followed by form, such as verb form, files the page under <Language> non-lemma forms; anything else, an omitted part of speech included, files it under <Language> lemmas. A recognised inflection class adds the class category from the table above, alongside the plain part-of-speech category rather than instead of it.
-- Module:Head — the dictionary headword line. Backs {{head}}.
-- Renders the bold headword (a leading * for reconstructed languages) and
-- auto-categorizes the page (Category:<Language> <pos>s + Category:<Language>
-- lemmas). With an inflection class (|class=), it also shows the gender/class
-- inline and files the Latin-style class category. The Lexemes Cargo row is
-- filed by Template:Head itself.
local Languages = require('Module:Languages')
local p = {}
-- English plural of a part-of-speech name (categories are "<Lang> nouns" etc.).
local IRREGULAR = { ["part of speech"] = "parts of speech" }
local function plural(pos)
if IRREGULAR[pos] then return IRREGULAR[pos] end
if pos:sub(-1) == "y" and not pos:find("[aeiou]y$") then
return pos:sub(1, -2) .. "ies"
end
if pos:find("[sxz]$") or pos:find("[cs]h$") then return pos .. "es" end
return pos .. "s"
end
-- Per-language inflection classes. Keyed by registry code, then part of speech.
-- Nouns carry a gender (abbrev g + full gender word) and an optional declension
-- label; verbs carry a conjugation label. `label` feeds both the inline note
-- and the Latin-style category (e.g. "Ancient Hertic first-declension masculine
-- nouns", "Ancient Hertic IS-class verbs").
local CLASSES = {
["YAQ-HE"] = {
noun = {
M1 = { g = "m", gender = "masculine", label = "first-declension" },
M2 = { g = "m", gender = "masculine", label = "second-declension" },
F = { g = "f", gender = "feminine" },
N1 = { g = "n", gender = "neuter", label = "first-declension" },
N2 = { g = "n", gender = "neuter", label = "second-declension" },
},
verb = {
IS = { label = "IS-class" },
OO = { label = "OO-class" },
},
},
}
-- {{#invoke:Head|head | code | pos | head = form | class = M1 }}
function p.head(frame)
local a = frame.args
local code = mw.text.trim(a[1] or ""):upper()
local pos = mw.text.trim(a[2] or ""):lower()
local l = Languages._get(code)
local name = (l and l.name) or code
local star = (l and l.recon) and "*" or ""
local form = mw.text.trim(a.head or "")
if form == "" then form = mw.title.getCurrentTitle().text end
-- inflection class (optional)
local class = mw.text.trim(a.class or "")
local info
if class ~= "" and CLASSES[code] and CLASSES[code][pos] then
info = CLASSES[code][pos][class]
end
local out = "'''" .. star .. form .. "'''"
if info then
if info.g then -- noun: gender abbrev + optional label
out = out .. " " .. info.g
if info.label then out = out .. " (''" .. info.label .. "'')" end
elseif info.label then -- verb: conjugation label
out = out .. " (''" .. info.label .. "'')"
end
end
if name ~= "" then
if info then -- Latin-style class category
local mid = info.gender and ((info.label and (info.label .. " ") or "") .. info.gender)
or info.label
out = out .. "[[Category:" .. name .. " " .. mid .. " " .. plural(pos) .. "]]"
end
if pos ~= "" then
out = out .. "[[Category:" .. name .. " " .. plural(pos) .. "]]"
end
if pos:find(" form", 1, true) then
out = out .. "[[Category:" .. name .. " non-lemma forms]]"
else
out = out .. "[[Category:" .. name .. " lemmas]]"
end
end
return out
end
return p