https://en.wikipedia.org/w/index.php?action=history&feed=atom&title=Module%3ANumberSpell Module:NumberSpell - Revision history 2025-05-30T11:58:09Z Revision history for this page on the wiki MediaWiki 1.45.0-wmf.3 https://en.wikipedia.org/w/index.php?title=Module:NumberSpell&diff=592785612&oldid=prev Mr. Stradivarius: Protected Module:NumberSpell: High-risk Lua module: used in Module:TimeAgo ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite)) 2014-01-28T12:43:00Z <p>Protected Module:NumberSpell: <a href="/wiki/Wikipedia:Lua/Modules" title="Wikipedia:Lua/Modules">High-risk Lua module</a>: used in <a href="/w/index.php?title=Module:TimeAgo&amp;action=edit&amp;redlink=1" class="new" title="Module:TimeAgo (page does not exist)">Module:TimeAgo</a> ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite))</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <tr class="diff-title" lang="en"> <td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Previous revision</td> <td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 12:43, 28 January 2014</td> </tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div> </td></tr></table> Mr. Stradivarius https://en.wikipedia.org/w/index.php?title=Module:NumberSpell&diff=590556735&oldid=prev Mr. Stradivarius: Mr. Stradivarius moved page Module:NumberWrite to Module:NumberSpell without leaving a redirect: snappier name 2014-01-13T19:58:19Z <p>Mr. Stradivarius moved page <a href="/w/index.php?title=Module:NumberWrite&amp;action=edit&amp;redlink=1" class="new" title="Module:NumberWrite (page does not exist)">Module:NumberWrite</a> to <a href="/wiki/Module:NumberSpell" title="Module:NumberSpell">Module:NumberSpell</a> without leaving a redirect: snappier name</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <tr class="diff-title" lang="en"> <td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Previous revision</td> <td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 19:58, 13 January 2014</td> </tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div> </td></tr></table> Mr. Stradivarius https://en.wikipedia.org/w/index.php?title=Module:NumberSpell&diff=590551550&oldid=prev Mr. Stradivarius: add 100, because why not? 2014-01-13T19:23:16Z <p>add 100, because why not?</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="en"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Previous revision</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 19:23, 13 January 2014</td> </tr><tr> <td colspan="2" class="diff-lineno">Line 6:</td> <td colspan="2" class="diff-lineno">Line 6:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>local p = {}</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>local p = {}</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>local max = <del style="font-weight: bold; text-decoration: none;">99</del> -- The maximum number that can be parsed.</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>local max = <ins style="font-weight: bold; text-decoration: none;">100</ins> -- The maximum number that can be parsed.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>local ones = {</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>local ones = {</div></td> </tr> <tr> <td colspan="2" class="diff-lineno">Line 35:</td> <td colspan="2" class="diff-lineno">Line 35:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> [70] = 'seventy',</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> [70] = 'seventy',</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> [80] = 'eighty',</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> [80] = 'eighty',</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> [90] = 'ninety'</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> [90] = 'ninety'<ins style="font-weight: bold; text-decoration: none;">,</ins></div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> [100] = 'one hundred'</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>}</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>}</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> </table> Mr. Stradivarius https://en.wikipedia.org/w/index.php?title=Module:NumberSpell&diff=590549377&oldid=prev Mr. Stradivarius: create a module that converts numbers into their written English form - can cope with numbers from 0 to 99 2014-01-13T19:09:00Z <p>create a module that converts numbers into their written English form - can cope with numbers from 0 to 99</p> <p><b>New page</b></p><div>-- This module converts a number into its written English form.<br /> -- For example, &quot;2&quot; becomes &quot;two&quot;, and &quot;79&quot; becomes &quot;seventy-nine&quot;.<br /> <br /> local getArgs = require(&#039;Module:Arguments&#039;).getArgs<br /> <br /> local p = {}<br /> <br /> local max = 99 -- The maximum number that can be parsed.<br /> <br /> local ones = {<br /> [0] = &#039;zero&#039;,<br /> [1] = &#039;one&#039;,<br /> [2] = &#039;two&#039;,<br /> [3] = &#039;three&#039;,<br /> [4] = &#039;four&#039;,<br /> [5] = &#039;five&#039;,<br /> [6] = &#039;six&#039;,<br /> [7] = &#039;seven&#039;,<br /> [8] = &#039;eight&#039;,<br /> [9] = &#039;nine&#039;<br /> }<br /> <br /> local specials = {<br /> [10] = &#039;ten&#039;,<br /> [11] = &#039;eleven&#039;,<br /> [12] = &#039;twelve&#039;,<br /> [13] = &#039;thirteen&#039;,<br /> [15] = &#039;fifteen&#039;,<br /> [18] = &#039;eighteen&#039;,<br /> [20] = &#039;twenty&#039;,<br /> [30] = &#039;thirty&#039;,<br /> [40] = &#039;forty&#039;,<br /> [50] = &#039;fifty&#039;,<br /> [60] = &#039;sixty&#039;,<br /> [70] = &#039;seventy&#039;,<br /> [80] = &#039;eighty&#039;,<br /> [90] = &#039;ninety&#039;<br /> }<br /> <br /> local formatRules = {<br /> {num = 90, rule = &#039;ninety-%s&#039;},<br /> {num = 80, rule = &#039;eighty-%s&#039;},<br /> {num = 70, rule = &#039;seventy-%s&#039;},<br /> {num = 60, rule = &#039;sixty-%s&#039;},<br /> {num = 50, rule = &#039;fifty-%s&#039;},<br /> {num = 40, rule = &#039;forty-%s&#039;},<br /> {num = 30, rule = &#039;thirty-%s&#039;},<br /> {num = 20, rule = &#039;twenty-%s&#039;},<br /> {num = 10, rule = &#039;%steen&#039;}<br /> }<br /> <br /> function p.main(frame)<br /> local args = getArgs(frame)<br /> local num = tonumber(args[1])<br /> local success, result = pcall(p._main, num)<br /> if success then<br /> return result<br /> else<br /> return string.format(&#039;&lt;strong class=&quot;error&quot;&gt;Error: %s&lt;/strong&gt;&#039;, result) -- &quot;result&quot; is the error message.<br /> end<br /> return p._main(num)<br /> end<br /> <br /> function p._main(num)<br /> if type(num) ~= &#039;number&#039; or math.floor(num) ~= num or num &lt; 0 or num &gt; max then<br /> error(&#039;input must be an integer between 0 and &#039; .. tostring(max), 2)<br /> end<br /> -- Check for numbers from 0 to 9.<br /> local onesVal = ones[num]<br /> if onesVal then<br /> return onesVal<br /> end<br /> -- Check for special numbers.<br /> local specialVal = specials[num]<br /> if specialVal then<br /> return specialVal<br /> end<br /> -- Construct the number from its format rule.<br /> onesVal = ones[num % 10]<br /> if not onesVal then<br /> error(&#039;Unexpected error parsing input &#039; .. tostring(num))<br /> end<br /> for i, t in ipairs(formatRules) do<br /> if num &gt;= t.num then<br /> return string.format(t.rule, onesVal)<br /> end<br /> end<br /> error(&#039;No format rule found for input &#039; .. tostring(num))<br /> end<br /> <br /> return p</div> Mr. Stradivarius