|
|
| (не показаны 64 промежуточные версии этого же участника) |
| Строка 1: |
Строка 1: |
| local p = {}
| |
|
| |
|
| local rules = {
| |
| {"ие$", "ие", "ия"}, -- здание -> здания
| |
| {"ка$", "ка", "ки"}, -- собака -> собаки
| |
| {"ок$", "ок", "ки"}, -- носок -> носки
| |
| {"ец$", "ец", "цы"}, -- молодец -> молодцы
| |
| {"ье$", "ье", "ья"}, -- зелье -> зелья
| |
| {"е$", "е", "я"}, -- поле -> поля
| |
| {"й$", "й", "и"}, -- край -> края
| |
| {"ь$", "ь", "и"} -- лошадь -> лошади
| |
| }
| |
|
| |
| function p.main(frame)
| |
| local text = frame.args[1] or ""
| |
| local words = {}
| |
| for word in text:gmatch("%S+") do
| |
| -- Если слово заканчивается на "о" или "я", оставляем без изменений
| |
| if word:match("[оя]$") then
| |
| table.insert(words, word)
| |
| else
| |
| local pluralized = nil
| |
| for _, rule in ipairs(rules) do
| |
| if word:match(rule[1]) then
| |
| pluralized = word:gsub(rule[2].."$", rule[3])
| |
| break
| |
| end
| |
| end
| |
| if not pluralized then
| |
| pluralized = word .. "ы"
| |
| end
| |
| table.insert(words, pluralized)
| |
| end
| |
| end
| |
| return table.concat(words, " ")
| |
| end
| |
|
| |
| return p
| |