Module:Declension: Difference between revisions
From The Goon Show Depository
(addition to last edit) |
m (1 revision imported) |
(No difference)
|
Latest revision as of 16:34, 23 October 2022
local p = {}
p.langlist = {
ar = {
adjective = {
singular = {{'', 'ة'}},
default = {{''}}
},
},
de = {
adjective = {
singular = {
n = {'er', 'e', 'es'},
d = {'em', 'er', 'em'},
},
plural = {
n = {'e'},
d = {'en'},
},
default = {{'es'}}
},
},
es = {
adjective = {
singular = {{'o', 'a'}},
plural = {{'os', 'as'}}
},
},
fr = {
adjective = {
singular = {{'', 'e'}},
plural = {{'s', 'es'}}
},
},
gl = {
adjective = {
singular = {{'o', 'a'}},
plural = {{'os', 'as'}}
},
},
it = {
adjective = {
singular = {{'o', 'a'}},
plural = {{'i', 'e'}}
},
},
nds = {
adjective = {
-- endings seem to be definite, but should probably be indefinite?
singular={
n = {'en', 'e', 'e'},
d = {'en', 'e', 'en'},
},
plural={
n = {'en'},
d = {'en'},
},
default = {{'en'}}
}
},
pl = { -- Polish
adjective = { -- Declension of regular adjectives / Deklinacja Przymiotnikow regularnych
singular = { -- Number: singular / Liczba pojedyncza
n = {'y', 'a', 'e'}, -- nominative: masculine, feminine, neuter / mianownik , rodzaj: męski, żenski, nijaki (np. zielonY chlopiec, zielonA dziewczynka, zielonE dziecko)
l = {'ym', 'ej', 'ym'} -- locative : masculine, feminine, neuter / miejscownik, rodzaj: męski, żenski, nijaki (np. na zielonYM chlopiecu, na zielonEJ dziewczynce, na zielonym dziecku)
},
plural = { -- Number: plural / Liczba mnoga
n = {'i', 'e', 'e'}, -- nominative: masculine, feminine, neuter / mianownik , rodzaj: męski, żenski, nijaki (np. zielonI chlopiecy, zielonE dziewczynki, zielonE dzieci)
l = {'ych'} -- locative : masculine, feminine, neuter / miejscownik, rodzaj: męski, żenski, nijaki (np. na zielonI chlopiecy, na zielonYCH dziewczynkach, na zielonYCH dzieciach)
}
},
},
pt = {
adjective = {
singular = {{'o', 'a'}},
plural={{'os', 'as'}}
}
},
ro = {
adjective = {
singular = {{'t', 'tă', 't'}},
plural = {{'ți', 'te', 'te'}}
},
},
ru = {
adjective = {
singular = {
{'ый', 'ая', 'ое'},
d = {'ому', 'ой', 'ому'},
p = {'ом', 'ой', 'ом'},
a = {'ый', 'ую', 'ое'},
},
plural = {
{'ые'},
d={'ым'},
p={'ых'},
a={'ые'},
},
default = {{'.'}}
},
},
scn = {
adjective = {
singular = {{'u', 'a'}},
plural = {{'i'}}
},
},
}
function p.selectAdjectiveForm(form, grammar)
-- form is a table
form.singular = form.singular or form.s
form.plural = form.plural or form.p
form.s = form.singular
form.p = form.plural
if grammar.gender and not grammar.number then
-- where grammatical info is known, but number not set explicitly
-- set it to singular
grammar.number = 's'
end
local defaultfeatures = {number='s', case='n'}
for _,feature in ipairs({'number', 'case', 'gender'}) do
form = form[grammar[feature]] or form.default or form[1] or form[defaultfeatures[feature]]
end
-- form is a string
return form
end
function p.makeregular(lang, word, wordtype, number, gender, case)
if wordtype == 'adj' then
wordtype = 'adjective'
end
if number == 'p' then
number = 'plural'
end
if number == 'sing' or number == 's' or not number then
number = 'singular'
end
if not case then
case = 'n'
end
-- clip endings
if lang == 'pl' then
if wordtype == 'adjective' then -- clip "y" at the end
if mw.ustring.sub(word, mw.ustring.len(word), mw.ustring.len(word)) == 'y' -- use string libraries ?
then word = mw.ustring.sub(word, 1, mw.ustring.len(word)-1)
end
end
end
word = word .. p.selectAdjectiveForm(p.langlist[lang][wordtype], {number=number, case=case, gender=gender})
return word
end
return p