This module contains data on various types of numbers in Italian.
local export = {numbers = {}}
local m_numutils = require("Module:number list/utils")
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
numbers = {
cardinal = "zero",
ordinal = "zeresimo",
ordinal_abbr = "0º",
adverbial = "]",
multiplier = "nullo",
collective = "nessuno",
wplink = "0 (numero)",
}
numbers = {
cardinal = {"uno", "un"},
ordinal = "primo",
ordinal_abbr = "1º",
adverbial = "] ]",
multiplier = "singolo",
distributive = "singolarmente",
wplink = "1 (numero)",
}
numbers = {
cardinal = "due",
ordinal = "secondo",
ordinal_abbr = "2º",
adverbial = "] ]",
multiplier = {"doppio", "duplice"},
distributive = "doppiamente",
collective = {"entrambi", "] ]"},
fractional = "mezzo",
wplink = "2 (numero)",
}
-- From 3 to 10, we automatically generate the ordinal abbreviation, adverbial, collective, fractional and wplink entries.
numbers = {
cardinal = "tre",
ordinal = "terzo",
multiplier = {"triplo", "triplice"},
}
numbers = {
cardinal = "quattro",
ordinal = "quarto",
multiplier = "quadruplo",
}
numbers = {
cardinal = "cinque",
ordinal = "quinto",
multiplier = "quintuplo",
}
numbers = {
cardinal = "sei",
ordinal = "sesto",
multiplier = "sestuplo",
}
numbers = {
cardinal = "sette",
ordinal = "settimo",
multiplier = "settuplo",
}
numbers = {
cardinal = "otto",
ordinal = "ottavo",
multiplier = "ottuplo",
}
numbers = {
cardinal = "nove",
ordinal = "nono",
multiplier = "nonuplo",
}
numbers = {
cardinal = "dieci",
ordinal = "decimo",
multiplier = "decuplo",
}
for i = 3, 10 do
local cardinal = numbers.cardinal
numbers.ordinal_abbr = i .. "º"
numbers.adverbial = ("] ]"):format(cardinal)
numbers.collective = ("] ]"):format(cardinal)
numbers.fractional = numbers.ordinal
numbers.wplink = ("%s (numero)"):format(i)
end
local function add_ordinal_suffix(term)
if type(term) == "table" then
local ordinals = {}
for _, item in ipairs(term) do
table.insert(ordinals, add_ordinal_suffix(item))
end
return ordinals
end
if rfind(term, "tre$") or rfind(term, "sei$") then
return term .. "esimo"
elseif rfind(term, "tré$") then
return rsub(term, "tré$", "treesimo")
elseif rfind(term, "dieci$") then
return rsub(term, "dieci$", "decimo")
elseif rfind(term, "mila$") then
return rsub(term, "mila$", "millesimo")
else
return rsub(term, "$", "") .. "esimo"
end
end
local function make_number(num, cardinal, ordinal, wplink)
local numstr = m_numutils.format_fixed(num)
numbers = {
cardinal = cardinal,
ordinal = ordinal or add_ordinal_suffix(cardinal),
ordinal_abbr = #numstr < 10 and m_numutils.add_thousands_separator(numstr, ".") .. "º" or nil,
wplink = wplink or type(num) == "number" and num <= 2000 and num .. " (numero)" or nil,
}
end
-- Generate 11 through 19.
for i, teen in ipairs { "undici", "dodici", "tredici", "quattordici", "quindici", "sedici",
"diciassette", "diciotto", "diciannove", } do
make_number(i + 10, teen)
end
-- Generate 20 through 99.
for i, tens_cardinal in ipairs {
"venti", "trenta", "quaranta", "cinquanta", "sessanta",
"settanta", "ottanta", "novanta",
} do
local tens = (i + 1) * 10
make_number(tens, tens_cardinal)
for ones = 1, 9 do
local suffix = ones == 3 and "tré" or numbers.cardinal
if type(suffix) == "table" then
suffix = suffix -- {"uno", "un"}
end
local cardinal =
(suffix:find "^" and tens_cardinal:gsub("%f$", "")
or tens_cardinal)
.. suffix
make_number(tens + ones, cardinal)
end
end
-- Generate 100 through 108.
for i, hundred_item in ipairs {
"cento",
{"centouno", "centuno"},
"centodue",
{"centotré", "centotre"},
"centoquattro",
"centocinque",
"centosei",
"centosette",
{"centootto", "centotto"},
} do
make_number(i + 99, hundred_item)
end
-- Generate 109 through 119.
for i = 109, 119 do
local base = i - 100
local cardinal = "cento" .. numbers.cardinal
make_number(i, cardinal)
end
-- Generate 120 through 190 by 10.
for i = 120, 190, 10 do
local base = i - 100
local cardinal = i == 180 and "centottanta" or "cento" .. numbers.cardinal
make_number(i, cardinal)
end
-- Generate 200 through 900 by 100.
for i = 200, 900, 100 do
local base = i / 100
local cardinal = numbers.cardinal .. "cento"
make_number(i, cardinal)
end
-- Include 210 because of the irregular ordinal (duecentodecimo).
make_number(210, "duecentodieci")
make_number(1000, "mille")
make_number(1001, "milleuno")
-- Generate 2000 through 9000 by 1000.
for i = 2000, 9000, 1000 do
local base = i / 1000
local cardinal = numbers.cardinal .. "mila"
make_number(i, cardinal)
end
make_number(10000, "diecimila", {"decimillesimo", "diecimillesimo"})
make_number(100000, "centomila")
make_number(1000000, {"] ]<link:milione>", "unmilione"}, "milionesimo", "milione")
make_number(2000000, {"] ]", "duemilioni"}, "duemilionesimo")
make_number(power_of(7), {"] ]", "diecimilioni"}, {"decimilionesimo", "diecimilionesimo"})
make_number(power_of(8), {"] ]", "centomilioni"}, "centomilionesimo")
make_number(power_of(9), {"] ]<link:miliardo>", "unmiliardo"}, "miliardesimo", "miliardo")
make_number(power_of(9, 2), {"] ]", "duemiliardi"}, "duemiliardesimo")
make_number(power_of(10), {"] ]", "diecimiliardi"}, {"decimiliardesimo", "diecimiliardesimo"})
make_number(power_of(11), {"] ]", "centomiliardi"}, "centomiliardesimo")
make_number(power_of(12), {"] ]<link:bilione>", "unbilione"}, "bilionesimo", "bilione")
make_number(power_of(13), {"] ]", "diecibilioni"}, {"decibilionesimo", "diecibilionesimo"})
make_number(power_of(14), {"] ]", "centobilioni"}, "centobilionesimo")
make_number(power_of(15), {"] ]<link:biliardo>", "unbiliardo"}, "biliardesimo", "biliardo (numero)")
make_number(power_of(18), {"] ]<link:trilione>", "untrilione"}, "trilionesimo", "trilione")
make_number(power_of(21), {"] ]<link:triliardo>", "untriliardo"}, "triliardesimo", "triliardo")
make_number(power_of(24), {"] ]<link:quadrilione>", "unquadrilione"}, "quadrilionesimo", "quadrilione")
make_number(power_of(27), {"] ]<link:quadriliardo>", "unquadriliardo"}, "quadriliardesimo", "quadriliardo")
make_number(power_of(30), {"] ]<link:quintilione>", "unquintilione"}, "quintilionesimo", "quintilione")
make_number(power_of(33), {"] ]<link:quintiliardo>", "unquintiliardo"}, "quintiliardesimo") -- no 'quintiliardo' article yet
return export