Anonymous user
Textonyms: Difference between revisions
m
→{{header|REXX}}: added/changed comments and whitespace, changed indentations, split some output lines into two, used better phrasing.
m (added whitespace before the TOC, added a ;Task and ;Extra credit (bold) headers.) |
m (→{{header|REXX}}: added/changed comments and whitespace, changed indentations, split some output lines into two, used better phrasing.) |
||
Line 1,314:
This REXX version checks for and displays the count of the number of (illegal) words not representable by the ''key digits''.
<br>It also detects and displays the count of duplicate words.
<lang rexx>/*REXX program counts and displays the number of textonyms that are in a
parse arg iFID . /*
if 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
digKey=0; wordCount=0 /*
ills=0; dups=0; longest=0; mostus=0 /*illegals;
first=0; last=0; long=0; most=0 /*
call linein iFID, 1, 0 /*point to the first char in
#=0 /*number of textonyms in
/* [↑] ───in case file is open.*/▼
do j=1 while lines(iFID)\==0 /*keep reading
x=linein(iFID); y=x; upper x /*get a word; save
if \datatype(x,'U') then do; ills=ills+1; iterate; end /*is it illegal? */
if $.x\=='' then do; dups=dups+1; iterate; end /*is it duplicate?*/
else $.x=. /*indicate that it's a righteous word. */
wordCount=wordCount+1 /*bump the word count (for the file). */
z=translate(x, digitKey, alphabet) /*build a translated digit key word. */
@.z=@.z+1 /*flag that the digit key word exists. */
!.z=!.z y; _=words(!.z) /*build
if _>most then do;
if @.z==2 then do;
if first==0 then first=z
last=z
_=length(!.z)
if _>longest then long=z
longest=max(_, longest)
end /* [↑] discretionary
if @.z\==1 then iterate /*Does it already exist? Then Skip it.*/
digKey=digKey+1 /*bump the count of digit key words. */
end /*j*/
@
say 'The dictionary file being used is: ' iFID
if ills\==0 then say ills 'word's(ills) "contained illegal characters."▼
say @Ta wordCount ' words in the file' @whichCan...
if dups\==0 then say dups "duplicate word"s(dups) 'detected.'▼
▲if ills\==0 then say @Ta ills ' word's(ills) "contained illegal characters."
say 'They require' digKey "combination"s(digKey) 'to represent them.'▼
▲if dups\==0 then say @Ta dups " duplicate word"s(dups) 'in the dictionary detected.'
say # 'digit combination's(#) "represent Textonyms."▼
▲say @Ta # ' digit combination's(#) " that can represent Textonyms."
say
if first\==0 then say ' first digit key=' !.first
if last\==0 then say ' last digit key=' !.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
'''output''' when using the default input file:
<pre>
The dictionary file being used is: UNIXDICT.TXT
There are 126 words contained illegal characters.
They require 22903 combinations to represent them.▼
There are 1473 digit combinations that can represent Textonyms.
first digit key= aaa aba abc cab
Line 1,375 ⟶ 1,378:
'''output''' when using the input file: <tt> textonyms.txt </tt>
<pre>
The dictionary file being used is: textonyms.txt
There are 95 duplicate words
first digit key= AA AB AC BA BB BC CA CB
|