Module:number list/data/hy

local export = {numbers = {}}

export.additional_number_types = { {key = "group_collective", after = "collective"}, {key = "collective_prefix", after = "group_collective"}, {key = "metric_collective_prefix", after = "collective_prefix"}, {key = "metric_fractional_prefix", after = "fractional"}, } local m_numutils = require("Module:number list/utils") local map = m_numutils.map local power_of = m_numutils.power_of

local numbers = export.numbers

local rfind = mw.ustring.find local rsubn = mw.ustring.gsub

-- version of rsubn that discards all but the first return value local function rsub(term, foo, bar) local retval = rsubn(term, foo, bar) return retval end

local function add_ordinal_suffix(term) if rfind(term, "ը$") then return rsub(string.gsub(term, "%s+", ""), "ը$", "ներորդ") else return string.gsub(term, "%s+", "") .. "երորդ" end end

local function add_multiplier_suffix(term) if rfind(term, "ը$") then return rsub(string.gsub(term, "%s+", ""), "ը$", "նակի") else return string.gsub(term, "%s+", "") .. "ակի" end end

local function add_distributive_suffix(term) if rfind(term, "ը$") then return rsub(string.gsub(term, "%s+", ""), "ը$", "նական") else return string.gsub(term, "%s+", "") .. "ական" end end

local function add_group_suffix(term) if rfind(term, "ուն$") then return rsub(term, "ուն$", "նյակ") else return term .. "յակ" end end

local function make_number(num, cardinal, coll, prefix, mprefix, fprefix, wplink) local numstr = m_numutils.format_fixed(num) local with_thousands = #numstr < 10 and m_numutils.add_thousands_separator(numstr, " ") or nil numbers[num] = { cardinal = cardinal, ordinal = map(function (card) return add_ordinal_suffix(card) end, cardinal), multiplier = map(function (card) return add_multiplier_suffix(card) end, cardinal), distributive = map(function (card) return add_distributive_suffix(card) end, cardinal), group_collective = coll, collective_prefix = prefix, metric_collective_prefix = mprefix, metric_fractional_prefix = fprefix, wplink = type(num) == "number" and num < 1000000 and num .. " (թիվ)" or nil, } end

export.numbers[0] = { cardinal = "զրո", ordinal = "զրոերորդ" }

numbers[1] = { cardinal = "մեկ", ordinal = "առաջին", fractional = "ամբողջ", distributive = "մեկական", collective_prefix = "մի-", wplink = "1 (թիվ)", }

numbers[2] = { cardinal = "երկու", ordinal = "երկրորդ", distributive = "երկուական", multiplier = "կրկնակի", adverbial = "երկիցս", group_collective = {"երկյակ", "զույգ"}, collective_prefix = "երկ-", fractional = "կես", wplink = "2 (թիվ)", } numbers[3] = { cardinal = "երեք", ordinal = "երրորդ", distributive = "երեքական", multiplier = "եռակի", adverbial = "երիցս", group_collective = "եռյակ", collective_prefix = "եռ-", wplink = "3 (թիվ)", } numbers[4] = { cardinal = "չորս", ordinal = "չորրորդ", distributive = "չորսական", multiplier = "քառակի", group_collective = "քառյակ", collective_prefix = "քառ-", fractional = "քառորդ", wplink = "4 (թիվ)", } numbers[5] = { cardinal = "հինգ", ordinal = "հինգերորդ", distributive = {"հնգական", "հինգական"}, multiplier = "հնգակի", collective_prefix = "հնգ-", group_collective = "հնգյակ", wplink = "5 (թիվ)", }

make_number(6, "վեց", "վեցյակ", "վեց-") make_number(7, "յոթ", {"յոթնյակ", "յոթյակ"}, "յոթն-") make_number(8, "ութ", {"ութնյակ", "ությակ"}, "ութ-") make_number(9, "ինը", "իննյակ", "ինն-") make_number(10, "տասը", "տասնյակ", "տասն-", "դեկա-", "դեցի-")

for i, ten_multiple in ipairs { "քսան", "երեսուն", "քառասուն", "հիսուն", } do	make_number((i + 1) * 10, ten_multiple, map(function (card) return add_group_suffix(card) end, ten_multiple)) end

for i, ten_multiple in ipairs {"վաթսուն", "յոթանասուն", "ութսուն", "իննսուն", } do	make_number((i + 5) * 10, ten_multiple) end

for tens = 10, 90, 10 do	for ones = 1, 9 do		local num = tens + ones local tens_cardinal = tostring(numbers[tens].cardinal) local ones_cardinal = tostring(numbers[ones].cardinal) tens_cardinal = rsub(tens_cardinal, "%ը$", "ն") local cardinal = tens_cardinal .. ones_cardinal if num == 12 then make_number(num, cardinal, {"երկվեցյակ", "երկոտասնյակ"}) else make_number(num, cardinal) end end end

make_number(100, "հարյուր", "հարյուրյակ", nil, "հեկտո-", "սանտի-")

for i = 200, 900, 100 do	local base = i / 100 local base_cardinal = tostring(numbers[base].cardinal) make_number(i, base_cardinal .. " հարյուր") end

make_number(1000, "հազար", "հազարյակ", nil, "կիլո-", "միլի-")

local function make_big_number(power, cardinal, mprefix, fprefix) local num = power_of(power) local numstr = m_numutils.format_fixed(num) local with_thousands = #numstr < 10 and m_numutils.add_thousands_separator(numstr, " ") or nil numbers[num] = { cardinal = cardinal, ordinal = map(function (card) return add_ordinal_suffix(card) end, cardinal), metric_collective_prefix = mprefix, metric_fractional_prefix = fprefix, } end

make_big_number(6, "միլիոն", "մեգա-", "միկրո-") make_big_number(9, {"հազար միլիոն", "միլիարդ", "բիլիոն"}, "գիգա-", "նանո-") make_big_number(12, {"երկիլիոն", "տրիլիոն"}, "տերա-", "պիկո-") make_big_number(15, {"հազար երկիլիոն", "կվադրիլիոն"}, "պետա-", "ֆեմտո-") make_big_number(18, {"եռիլիոն", "կվինտիլիոն"}, "էկսա-", "ատտո-") make_big_number(21, {"հազար եռիլիոն", "սեքստիլիոն"}, "զետտա-", "զեպտո-") make_big_number(24, {"քառիլիոն", "սեպտիլիոն"}, "յոտտա-", "յոկտո-") make_big_number(27, {"հազար քառիլիոն", "օկտիլիոն"}, "ռոննա-", "ռոնտո-") make_big_number(30, {"հնգիլիոն", "նոնիլիոն"}, "կվետտա-", "կվեկտո-")

return export