Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
30
Task/Textonyms/Zkl/textonyms.zkl
Normal file
30
Task/Textonyms/Zkl/textonyms.zkl
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
URL:="http://www.puzzlers.org/pub/wordlists/unixdict.txt";
|
||||
var ZC=Import("zklCurl");
|
||||
var keypad=Dictionary(
|
||||
"a",2,"b",2,"c",2, "d",3,"e",3,"f",3, "g",4,"h",4,"i",4,
|
||||
"j",5,"k",5,"l",5, "m",6,"n",6,"o",6, "p",7,"q",7,"r",7,"s",7,
|
||||
"t",8,"u",8,"v",8, "w",9,"x",9,"y",9,"z",9);
|
||||
//fcn numerate(word){ word.toLower().apply(keypad.find.fp1("")) }
|
||||
fcn numerate(word){ word.toLower().apply(keypad.get) } //-->textonym or error
|
||||
println("criticisms --> ",numerate("criticisms"));
|
||||
|
||||
words:=ZC().get(URL); //--> T(Data,bytes of header, bytes of trailer)
|
||||
words=words[0].del(0,words[1]); // remove HTTP header
|
||||
println("Read %d words from %s".fmt(words.len(1),URL));
|
||||
|
||||
wcnt:=Dictionary();
|
||||
foreach word in (words.walker(11)){ // iterate over stripped lines
|
||||
w2n:=try{ numerate(word) }catch(NotFoundError){ continue };
|
||||
wcnt.appendV(w2n,word); // -->[textonym:list of words]
|
||||
}
|
||||
|
||||
moreThan1Word:=wcnt.reduce(fcn(s,[(k,v)]){ s+=(v.len()>1) },0);
|
||||
maxWordPerNum:=(0).max(wcnt.values.apply("len"));
|
||||
|
||||
("There are %d words which can be represented by the Textonyms mapping.\n"
|
||||
"There are %d overlaps.").fmt(wcnt.len(),moreThan1Word).println();
|
||||
|
||||
println("Max collisions: %d words:".fmt(maxWordPerNum));
|
||||
foreach k,v in (wcnt.filter('wrap([(k,v)]){ v.len()==maxWordPerNum })){
|
||||
println(" %s is the textonym of: %s".fmt(k,v.concat(", ")));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue