Assorted Text Generation
version 4 by Emily Short
Section 2 - Numbers
To say numerical ordinal of (N - a number):
say "[N]";
if N is greater than 10 and N is less than 20
begin;
say "th";
otherwise;
let Y be the remainder after dividing N by 10;
if Y is 1
begin;
say "st";
otherwise if Y is 2;
say "nd";
otherwise if Y is 3;
say "rd";
otherwise;
say "th";
end if;
end if;
To say ordinal of (N - a number):
if N is a number listed in the Table of Ordinals
begin;
choose row with a number of N in the Table of Ordinals;
say ordinal entry;
otherwise;
if N is greater than 20
begin;
let X be N divided by 10;
now X is X times 10;
let Y be the remainder after dividing N by 10;
if Y is zero
begin;
let enumeration be indexed text;
let enumeration be "[X in words]";
replace the regular expression "(.*)y" in enumeration with "\1ie";
say "[enumeration]th";
otherwise;
say "[X in words]-[ordinal of Y]";
end if;
otherwise;
say "[N in words]th";
end if;
end if.
Table of Ordinals
| number | ordinal |
| 1 | "first" |
| 2 | "second" |
| 3 | "third" |
| 4 | "fourth" |
| 5 | "fifth" |
| 6 | "sixth" |
| 7 | "seventh" |
| 8 | "eighth" |
| 9 | "ninth" |
| 10 | "tenth" |
| 11 | "eleventh" |
| 12 | "twelfth" |
| 20 | "twentieth" |
To decide what number is (N - a number) to the nearest (A - a number):
now N is N divided by A;
now N is N times A;
decide on N.
To say (count - a number) in round numbers:
repeat through the Table of Numerical Approximation
begin;
if count is less than threshold entry
begin;
let N be indexed text;
let N be "[approximation entry]";
replace the regular expression " of" in N with "";
replace the text "no" in N with "zero";
say "[N]";
rule succeeds;
end if;
end repeat.
To say adjectival (count - a number) in round numbers:
repeat through the Table of Numerical Approximation:
if count is less than threshold entry:
say "[approximation entry]";
rule succeeds.
Table of Numerical Approximation
| threshold | approximation | |
| 1 | "no" | |
| 2 | "one" | |
| 3 | "a couple of" | |
| 4 | "several" | |
| 6 | "a few" | |
| 11 | "some" | |
| 21 | "many" | |
| 100 | "lots of" | |
| 500 | "lots and lots of" | |
| 2000 | "hundreds of" | |
| 30000 | "thousands of" |