มอดูล:number list/data/gl
- The following documentation is generated by Module:documentation. [edit]
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox
This module contains data on various types of numbers in กาลิเซีย.
(edit)
local export = {numbers = {}}
local m_numutils = require("Module:number list/utils")
local m_table = require("Module:table")
local map = m_numutils.map
local append = m_numutils.append
local power_of = m_numutils.power_of
local numbers = export.numbers
-- Construct a number given the cardinal(s), ordinal(s), optional local Wikipedia link, and optional fractional.
-- We also add the ordinal abbreviation automatically. If the fractional isn't specified, it defaults to the ordinal
-- if >= 2 and <= 10, otherwise it is constructed from the cardinal by concatenating 'avo' to the cardinal (for the
-- standard norm) or adding 'avos' as a separate word to the cardinal (for the reintegrationist norm). If the value of
-- `fractional` is true, include the ordinal along with the 'avo(s)' variant. All values passed in can be single items
-- or lists.
local function make_number(num, cardinal, ordinal, wplink, fractional)
local numstr = m_numutils.format_fixed(num)
local thousands_numstr = #numstr < 10 and m_numutils.add_thousands_separator(numstr, " ") or nil
numbers[num] = {
cardinal = cardinal,
ordinal = ordinal,
ordinal_abbr = thousands_numstr and thousands_numstr .. "º" or nil,
fractional = fractional,
wplink = wplink,
}
end
local standard_ones_cardinal = {
{"un<tag:masculine>", "unha<tag:feminine>"},
{"dous<tag:masculine>", "dúas<tag:feminine>"},
"tres",
"catro",
"cinco",
"seis",
"sete",
"oito",
"nove",
"dez",
}
local reintegrationist_ones_cardinal = {
{"um<tag:masculine>", "umha<tag:feminine>", "uma<tag:feminine>"},
{"dous<tag:masculine>", "duas<tag:feminine>"},
"três",
"quatro",
"cinco",
"seis",
"sete",
"oito",
"nove",
"dez",
}
local standard_ones_ordinal = {
"primeiro",
"segundo",
"terceiro",
"cuarto",
"quinto",
"sexto",
"sétimo",
"oitavo",
"noveno",
"décimo",
}
local reintegrationist_ones_ordinal = {
"primeiro",
"segundo",
"terceiro",
"quarto",
"quinto",
"sexto",
"sétimo",
"oitavo",
"nono",
"décimo",
}
local standard_ones_multiplier = {
{},
{"dobre<q:noun>", "duplo<q:adjective>"},
"triplo",
"cuádruplo",
"quíntuplo",
"séxtuplo",
"séptuplo",
"óctuplo",
"nónuplo",
"décuplo",
}
local reintegrationist_ones_multiplier = {
{},
{"dobro<q:noun>", "duplo<q:adjective>"},
"triplo",
"quádruplo",
"quíntuplo",
"sêxtuplo",
"séptuplo",
"óctuplo",
"nónuplo",
"décuplo",
}
local standard_tens_cardinal = {
"vinte",
"trinta",
"corenta",
"cincuenta",
"sesenta",
"setenta",
"oitenta",
"noventa",
}
local reintegrationist_tens_cardinal = {
"vinte",
"trinta",
"quarenta",
{"cinqüenta", "cinquenta"},
"sessenta",
"setenta",
"oitenta",
"noventa",
}
local standard_tens_ordinal = {
"vixésimo",
"trixésimo",
"cuadraxésimo",
"quincuaxésimo",
"sesaxésimo",
"septuaxésimo",
"octoxésimo",
"nonaxésimo",
}
local reintegrationist_tens_ordinal = {
"vigésimo",
"trigésimo",
"quadragésimo",
{"qüinquagésimo", "quinquagésimo"},
"sexagésimo",
"septuagésimo",
"octogésimo",
"nonagésimo",
}
local standard_teens_cardinal = {
"once",
"doce",
"trece",
"catorce",
"quince",
"dezaseis",
"dezasete",
"dezaoito",
"dezanove",
}
local reintegrationist_teens_cardinal = {
"onze",
"doze",
"treze",
"catorze",
"quinze",
"dezasseis",
"dezassete",
"dezoito",
"dezanove",
}
local standard_hundreds_cardinal = {
{"cen<q:alone or followed by a noun or higher numeral>", "cento<q:followed by a lower numeral>"},
"douscentos",
"trescentos",
"catrocentos",
{"cincocentos", "quiñentos"},
"seiscentos",
"setecentos",
"oitocentos",
"novecentos",
}
local reintegrationist_hundreds_cardinal = {
{"cem<q:alone or followed by a noun or higher numeral>", "cento<q:followed by a lower numeral>"},
"duzentos",
"trezentos",
"quatrocentos",
"quinhentos",
"seiscentos",
"setecentos",
"oitocentos",
"novecentos",
}
local standard_hundreds_ordinal = {
"centésimo",
"ducentésimo",
"tricentésimo",
"cuadrixentésimo",
"quinxentésimo",
"sexcentésimo",
"septinxentésimo",
"octinxentésimo",
"noninxentésimo",
}
local reintegrationist_hundreds_ordinal = {
"centésimo",
"ducentésimo",
"trecentésimo",
"quadrigentésimo",
{"qüingentésimo", "quingentésimo"},
{"sexcentésimo", "seiscentésimo"},
"septingentésimo",
"octingentésimo",
"nongentésimo",
}
-- Combine tens values in `tens` with ones values in `ones`, either of which may be a single string or a list.
-- The `ones` values may have tags added for masculine/feminine so we map over them in the outer loop, so we get all
-- masculine followed by all feminine.
local function combine_tens_ones(tens, ones, sep)
return map(function(one)
return map(function(ten)
return ten .. sep .. one
end, tens)
end, ones)
end
-- Append the standard and reintegrationist forms for a given number. If a form occurs in both, it should occur
-- once in the output with no tag, otherwise it should be tagged according to the norm.
local function combine_standard_reinteg(standard, reinteg)
if type(standard) ~= "table" then
standard = {standard}
end
if type(reinteg) ~= "table" then
reinteg = {reinteg}
end
local retval = {}
local occurs_in_both = {}
for _, st in ipairs(standard) do
if m_table.contains(reinteg, st) then
occurs_in_both[st] = true
table.insert(retval, st)
else
table.insert(retval, st .. "<tag:standard>")
end
end
for _, re in ipairs(reinteg) do
if not occurs_in_both[re] then
table.insert(retval, re .. "<tag:reintegrationist>")
end
end
if #retval == 1 then
return retval[1]
else
return retval
end
end
numbers[0] = {
cardinal = {"cero<tag:standard>", "zero<tag:reintegrationist>"},
wplink = "cero",
}
-- Do one through ten
for ones = 1, 10 do
local num = ones
local cardinal = combine_standard_reinteg(standard_ones_cardinal[ones], reintegrationist_ones_cardinal[ones])
local ordinal = combine_standard_reinteg(standard_ones_ordinal[ones], reintegrationist_ones_ordinal[ones])
local fractional
if num == 2 then
fractional = {"medio<q:adjective><tag:standard>", "meio<q:adjective><tag:reintegrationist>", "metade<q:noun>"}
elseif num == 3 then
fractional = {"terzo<tag:standard>", "terço<tag:reintegrationist>"}
else
-- autogenerated from ordinal
end
local wplink
if num == 1 then
wplink = "un"
elseif num == 2 then
wplink = "dous"
else
-- Galician Wikipedia has entries 0 through 10; that's basically it.
wplink = standard_ones_cardinal[ones]
end
make_number(num, cardinal, ordinal, wplink, fractional)
numbers[num].multiplier =
combine_standard_reinteg(standard_ones_multiplier[ones], reintegrationist_ones_multiplier[ones])
end
local function make_fractional(standard_cardinal, reintegrationist_cardinal)
local function remove_feminines(items)
return map(function(item)
if item:find("<tag:feminine>") then
return {}
else
return item:gsub("<tag:masculine>", "")
end
end,
items, "include modifiers")
end
local standard_form = map(function(card)
return card .. "avo<tag:standard>"
end, remove_feminines(standard_cardinal))
local reinteg_form = map(function(card)
if not card:find("%[") then
card = ("[[%s]]"):format(card)
end
return ("%s [[avo]]s<tag:reintegrationist>"):format(card)
end, remove_feminines(reintegrationist_cardinal))
return append(standard_form, reinteg_form)
end
-- Do 11 through 19
for ones = 1, 9 do
local num = 10 + ones
local cardinal = combine_standard_reinteg(standard_teens_cardinal[ones], reintegrationist_teens_cardinal[ones])
local single_word_ordinal
if num == 11 then
single_word_ordinal = "undécimo"
elseif num == 12 then
single_word_ordinal = "duodécimo"
end
local standard_multi_word_ordinal = map(function(ord) return "décimo " .. ord end, standard_ones_ordinal[ones])
local reinteg_multi_word_ordinal = map(function(ord) return "décimo " .. ord end, reintegrationist_ones_ordinal[ones])
local ordinal = combine_standard_reinteg(standard_multi_word_ordinal, reinteg_multi_word_ordinal)
if single_word_ordinal then
ordinal = append(single_word_ordinal, ordinal)
end
make_number(num, cardinal, ordinal, nil,
make_fractional(standard_teens_cardinal[ones], reintegrationist_teens_cardinal[ones]))
end
-- Do 20 through 99
for tens_index = 1, 8 do
local tens = (tens_index + 1) * 10
local tens_cardinal = combine_standard_reinteg(standard_tens_cardinal[tens_index],
reintegrationist_tens_cardinal[tens_index])
local tens_ordinal = combine_standard_reinteg(standard_tens_ordinal[tens_index],
reintegrationist_tens_ordinal[tens_index])
make_number(tens, tens_cardinal, tens_ordinal, nil, make_fractional(standard_tens_cardinal[tens_index],
reintegrationist_tens_cardinal[tens_index]))
for ones_index = 1, 9 do
local ones = ones_index
local num = tens + ones
local standard_cardinal =
combine_tens_ones(standard_tens_cardinal[tens_index], standard_ones_cardinal[ones_index], " e ")
local reintegrationist_cardinal =
combine_tens_ones(reintegrationist_tens_cardinal[tens_index], reintegrationist_ones_cardinal[ones_index],
" e ")
local cardinal = combine_standard_reinteg(standard_cardinal, reintegrationist_cardinal)
local standard_ordinal =
combine_tens_ones(standard_tens_ordinal[tens_index], standard_ones_ordinal[ones_index], " ")
local reintegrationist_ordinal =
combine_tens_ones(reintegrationist_tens_ordinal[tens_index], reintegrationist_ones_ordinal[ones_index],
" ")
local ordinal = combine_standard_reinteg(standard_ordinal, reintegrationist_ordinal)
make_number(num, cardinal, ordinal, nil, make_fractional(standard_cardinal, reintegrationist_cardinal))
end
end
-- Do 100 through 900
for ones = 1, 9 do
local num = 100 * ones
local cardinal =
combine_standard_reinteg(standard_hundreds_cardinal[ones], reintegrationist_hundreds_cardinal[ones])
local ordinal = combine_standard_reinteg(standard_hundreds_ordinal[ones], reintegrationist_hundreds_ordinal[ones])
make_number(num, cardinal, ordinal, nil, ordinal)
end
make_number(1000, "mil", "milésimo", nil, "milésimo")
return export