June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,24 @@
(def table
{\a 2 \b 2 \c 2 \A 2 \B 2 \C 2
\d 3 \e 3 \f 3 \D 3 \E 3 \F 3
\g 4 \h 4 \i 4 \G 4 \H 4 \I 4
\j 5 \k 5 \l 5 \J 5 \K 5 \L 5
\m 6 \n 6 \o 6 \M 6 \N 6 \O 6
\p 7 \q 7 \r 7 \s 7 \P 7 \Q 7 \R 7 \S 7
\t 8 \u 8 \v 8 \T 8 \U 8 \V 8
\w 9 \x 9 \y 9 \z 9 \W 9 \X 9 \Y 9 \Z 9})
(def words-url "http://www.puzzlers.org/pub/wordlists/unixdict.txt")
(def words (-> words-url slurp clojure.string/split-lines))
(def digits (partial map table))
(let [textable (filter #(every? table %) words) ;; words with letters only
mapping (group-by digits textable) ;; map of digits to words
textonyms (filter #(< 1 (count (val %))) mapping)] ;; textonyms only
(print
(str "There are " (count textable) " words in " \' words-url \'
" which can be represented by the digit key mapping. They require "
(count mapping) " digit combinations to represent them. "
(count textonyms) " digit combinations represent Textonyms.")))

View file

@ -1,36 +1,38 @@
/*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=='' then iFID='UNIXDICT.TXT' /*Not specified? Then use the default.*/
if iFID=='' | iFID=="," then iFID='UNIXDICT.TXT' /*Not specified? Then use the default.*/
@.=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 /*number digit combinations; wordCount.*/
ills=0; dups=0; longest=0; mostus=0 /*illegals; duplicated words; longest..*/
first=0; last=0; long=0; most=0 /*first, last, longest, most counts. */
call linein iFID, 1, 0 /*point to the first char in dictionary*/
digKey=0; wordCount=0 /*number digit combinations; wordCount.*/
ills=0; dups=0; longest=0; mostus=0 /*illegals; duplicated words; longest..*/
first=.; last=.; long=0; most=0 /*first, last, longest, most counts. */
#=0 /*number of textonyms in file (so far).*/
call linein iFID, 1, 0 /*point to the first char in dictionary*/ /* ◄■■■■■ optional.*/
do j=1 while lines(iFID)\==0 /*keep reading the file until exhausted*/
x=linein(iFID); y=x; upper x /*get a word; save a copy; uppercase it*/
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). */
do while lines(iFID)\==0 /*keep reading the file until exhausted*/
x=linein(iFID); y=x; upper x /*get a word; save a copy; uppercase it*/
if \datatype(x,'U') then do; ills=ills + 1; iterate; end /*Not legal? Skip.*/
if $.x==. then do; dups=dups + 1; iterate; end /*Duplicate? Skip.*/
$.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 list of equivalent digit key(s)*/
if _>most then do; mostus=z; most=_; end /*remember the "mostus" digit keys. */
if @.z==2 then do; #=#+1 /*bump the count of the textonyms. */
if first==0 then first=z /*the first textonym found. */
@.z=@.z + 1 /*flag that the digit key word exists. */
!.z=!.z y; _=words(!.z) /*build list of equivalent digit key(s)*/
if _>most then do; mostus=z; most=_; end /*remember the "mostus" digit keys. */
if @.z==2 then do; #=# + 1 /*bump the count of the textonyms. */
if first==. then first=z /*the first textonym found. */
last=z /* " last " " */
_=length(!.z) /*the length (# chars) of the digit key*/
if _>longest then long=z /*is this the longest textonym ? */
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.*/
digKey=digKey+1 /*bump the count of digit key words. */
end /*j*/
if @.z==1 then digKey=digKey + 1 /*bump the count of digit key words. */
end /*while*/
@whichCan...= 'which can be represented by digit key mapping.'
@Ta = 'There are '
say 'The dictionary file being used is: ' iFID
@ -38,12 +40,12 @@ say @Ta wordCount ' words in the file' @whichCan...
if ills\==0 then say @Ta ills ' word's(ills) "contained illegal characters."
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(#) " that can 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 first\==. then say ' first digit key=' !.first
if last\==. 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)"
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.*/