Anonymous user
Textonyms: Difference between revisions
→{{header|REXX}}: added/changed comments and whitespace, added commas to numbers being displayed, aligned numbers, changed wording for the output text(s),
(Add Factor) |
(→{{header|REXX}}: added/changed comments and whitespace, added commas to numbers being displayed, aligned numbers, changed wording for the output text(s),) |
||
Line 2,032:
parse arg iFID . /*obtain optional fileID from the C.L. */
if iFID=='' | iFID=="," then iFID='UNIXDICT.TXT' /*Not specified? Then use the default.*/
@.=
!.=;
alphabet= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' /*the supported alphabet to be used. */
digitKey= 22233344455566677778889999 /*translated alphabet to digit keys. */
digKey= 0;
ills= 0 ; dups= 0; longest= 0; mostus=
first=. ; last= .; long= 0;
do
y= x; upper x
if \datatype(x, 'U') then do; ills=ills + 1; iterate; end
if $.x==. then do; dups=dups + 1; iterate; end
$.x=
z= translate(x, digitKey, alphabet)
@.z= @.z + 1
!.z= !.z y;
if _>most then do; mostus=z; most=_; end /*remember the "mostus" digit keys. */
if @.z==2 then do; #= # + 1
if first==. then first=z /*the first textonym found. */
last=
_= length(!.z)
if _>longest then long=
longest= max(_, longest)
end /* [↑] discretionary (extra credit). */
if @.z==1 then digKey= digKey + 1
end /*while*/
L= length(commas(max(#word,ills,dups,digKey,#))) /*find length of max # being displayed.*/
say 'The dictionary file being used is: '
if ills
if dups
say; if first\==. then say ' first digit key=' !.first
if
if
if
▲exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
commas: parse arg _; do jc=length(_)-3 to 1 by -3; _=insert(',', _, jc); end; return _
s: if arg(1)==1 then return ''; return "s" /*a simple pluralizer.*/</lang>▼
tell: arg ##; say 'There are ' right(commas(##), L)' ' arg(2).; return /*commatize #*/
{{out|output|text= when using the default input file:}}
<pre>
The dictionary file being used is: UNIXDICT.TXT
There are
There are 126 words
There are
first digit key= aaa aba abc cab
Line 2,093 ⟶ 2,095:
numerous digit key= amy any bmw bow box boy cow cox coy (9 words)
</pre>
{{out|output|text= when using the input file: <tt> textonyms.txt </tt>}}
<pre>
The dictionary file being used is:
There are
There are 95 duplicate words detected in the dictionary
There are 650 digit combinations
first digit key= AA AB AC BA BB BC CA CB
|