মডিউল:NumberSpell
অবয়ব
এই মডিউলের জন্য মডিউল:NumberSpell/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে
-- This module converts a number into its written Bengali form.
-- For example, "2" becomes "দুই", and "79" becomes "ঊনাশি".
local getArgs = require('Module:Arguments').getArgs
local p = {}
local max = 100 -- The maximum number that can be parsed.
local numbers = {
[0] = 'শূন্য',
[1] = 'এক',
[2] = 'দুই',
[3] = 'তিন',
[4] = 'চার',
[5] = 'পাঁচ',
[6] = 'ছয়',
[7] = 'সাত',
[8] = 'আট',
[9] = 'নয়',
[10] = 'দশ',
[11] = 'এগারো',
[12] = 'বারো',
[13] = 'তেরো',
[14] = 'চৌদ্দ',
[15] = 'পনেরো',
[16] = 'ষোল',
[17] = 'সতেরো',
[18] = 'আঠারো',
[19] = 'ঊনিশ',
[20] = 'বিশ',
[21] = 'একুশ',
[22] = 'বাইশ',
[23] = 'তেইশ',
[24] = 'চব্বিশ',
[25] = 'পঁচিশ',
[26] = 'ছাব্বিশ',
[27] = 'সাতাশ',
[28] = 'আটাশ',
[29] = 'ঊনত্রিশ',
[30] = 'ত্রিশ',
[31] = 'একত্রিশ',
[32] = 'বত্রিশ',
[33] = 'তেত্রিশ',
[34] = 'চৌত্রিশ',
[35] = 'পঁয়ত্রিশ',
[36] = 'ছত্রিশ',
[37] = 'সাঁইত্রিশ',
[38] = 'আটত্রিশ',
[39] = 'ঊনচল্লিশ',
[40] = 'চল্লিশ',
[41] = 'একচল্লিশ',
[42] = 'বিয়াল্লিশ',
[43] = 'তেতাল্লিশ',
[44] = 'চুয়াল্লিশ',
[45] = 'পঁয়তাল্লিশ',
[46] = 'ছেচল্লিশ',
[47] = 'সাতচল্লিশ',
[48] = 'আটচল্লিশ',
[49] = 'ঊনপঞ্চাশ',
[50] = 'পঞ্চাশ',
[51] = 'একান্ন',
[52] = 'বায়ান্ন',
[53] = 'তিপ্পান্ন',
[54] = 'চুয়ান্ন',
[55] = 'পঞ্চান্ন',
[56] = 'ছাপ্পান্ন',
[57] = 'সাতান্ন',
[58] = 'আটান্ন',
[59] = 'ঊনষাট',
[60] = 'ষাট',
[61] = 'একষট্টি',
[62] = 'বাষট্টি',
[63] = 'তেষট্টি',
[64] = 'চৌষট্টি',
[65] = 'পঁয়ষট্টি',
[66] = 'ছেষট্টি',
[67] = 'সাতষট্টি',
[68] = 'আটষট্টি',
[69] = 'ঊনসত্তর',
[70] = 'সত্তর',
[71] = 'একাত্তর',
[72] = 'বাহাত্তর',
[73] = 'তিয়াত্তর',
[74] = 'চুয়াত্তর',
[75] = 'পঁচাত্তর',
[76] = 'ছিয়াত্তর',
[77] = 'সাতাত্তর',
[78] = 'আটাত্তর',
[79] = 'ঊনাশি',
[80] = 'আশি',
[81] = 'একাশি',
[82] = 'বিরাশি',
[83] = 'তিরাশি',
[84] = 'চুরাশি',
[85] = 'পঁচাশি',
[86] = 'ছিয়াশি',
[87] = 'সাতাশি',
[88] = 'আটাশি',
[89] = 'ঊননব্বই',
[90] = 'নব্বই',
[91] = 'একানব্বই',
[92] = 'বিরানব্বই',
[93] = 'তিরানব্বই',
[94] = 'চুরানব্বই',
[95] = 'পঁচানব্বই',
[96] = 'ছিয়ানব্বই',
[97] = 'সাতানব্বই',
[98] = 'আটানব্বই',
[99] = 'নিরানব্বই',
[100] = 'একশত'
}
function p.main(frame)
local args = getArgs(frame)
local num = tonumber(args[1])
local success, result = pcall(p._main, num)
if success then
return result
else
return string.format('<strong class="error">Error: %s</strong>', result) -- "result" is the error message.
end
return p._main(num)
end
function p._main(num)
if type(num) ~= 'number' or math.floor(num) ~= num or num < 0 or num > max then
error('input must be an integer between 0 and ' .. tostring(max), 2)
end
-- Check for numbers from 0 to 9.
local onesVal = numbers[num]
if onesVal then
return onesVal
end
error('No format rule found for input ' .. tostring(num))
end
return p