Anonymous user
Textonyms: Difference between revisions
m
→{{header|REXX}}: added/changed comments and whitespace, used a template for the OUTPUTs..
(Added a Clojure example) |
m (→{{header|REXX}}: added/changed comments and whitespace, used a template for the OUTPUTs..) |
||
Line 1,801:
<lang rexx>/*REXX program counts and displays the number of textonyms that are in a dictionary file*/
parse arg iFID . /*obtain optional fileID from the C.L. */
if iFID=='' | iFID=="," then iFID='UNIXDICT.TXT'
@.=0 /*the placeholder of digit combinations*/
!.=; $.= /*sparse array of textonyms; words. */
alphabet= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' /*the supported alphabet to be used. */
digitKey= 22233344455566677778889999 /*translated alphabet to digit keys. */
digKey=0; wordCount=0
ills=0; dups=0; longest=0; mostus=0
first=
call linein iFID, 1, 0 /*point to the first char in dictionary*/▼
#=0 /*number of textonyms in file (so far).*/
▲call linein iFID, 1, 0 /*point to the first char in dictionary*/ /* ◄■■■■■ optional.*/
do
x=linein(iFID); y=x;
if \datatype(x,'U') then do; ills=ills + 1; iterate; end
if $.x
$.x=.
wordCount=wordCount +
z=translate(x, digitKey, alphabet) /*build a translated digit key word. */
@.z=@.z +
!.z=!.z y; _=words(!.z)
if
if first==0 then first=z /*the first textonym found. */▼
if @.z
last=z /* " last " " */
_=length(!.z) /*the length (# chars) of the digit key*/
Line 1,829 ⟶ 1,831:
longest=max(_, longest) /*now, use this length as a target/goal*/
end /* [↑] discretionary (extra credit). */
▲ if @.z\==1 then iterate /*Does it already exist? Then Skip it.*/
end
@whichCan...= 'which can be represented by digit key mapping.'
@Ta = 'There are '
Line 1,839 ⟶ 1,841:
if dups\==0 then say @Ta dups " duplicate word"s(dups) 'in the dictionary detected.'
say 'The textonyms require ' digKey " combination"s(digKey) 'to represent them.'
say @Ta # ' digit combination's(#)
say
if first\==
if last\==
if long\==0 then say ' longest digit key=' !.long
if most\==0 then say ' numerous digit key=' !.mostus ' ('most "words)"
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
s: if arg(1)==1 then return ''; return "s" /*a simple pluralizer.*/</lang>
<pre>
The dictionary file being used is: UNIXDICT.TXT
Line 1,861 ⟶ 1,863:
numerous digit key= amy any bmw bow box boy cow cox coy (9 words)
</pre>
<pre>
The dictionary file being used is: textonyms.txt
|