Textonyms: Difference between revisions

→‎{{header|jq}}: add longest Textonyms
m (→‎{{header|jq}}: add missing word)
(→‎{{header|jq}}: add longest Textonyms)
Line 283:
 
def explore:
# given an array (or hash), find the maximum length of the items (or values):
def max_length: [.[] | length] | max;
 
# The length of the longest textonym in the dictionary of numericString => array:
def longest:
[to_entries[] | select(.value|length > 1) | .key | length] | max;
 
# pretty-print a key-value pair:
def pp: "\(.key) maps to: \(.value|tostring)";
split("\n")
| map(select(test("^[a-zA-Z]+$"))) # select the strictly alphabetic strings
Line 293 ⟶ 301:
| .[$key] += [$line] )
| max_length as $max_length
| longest as $longest
| "There are \($nwords) words in the Textonyms/wordlist word list that can be represented by the digit-key mapping.",
"They require \(length) digit combinations to represent them.",
"\( [.[] | select(length>1) ] | length ) digit combinations represent Textonyms.",
"The numbers mapping to the most words map to \($max_length) words in the given word list:",
(to_entries[] | select((.value|length) == $max_length) | "pp \(.key) maps to: \(.value|tostring)"),
"The longest Textonyms in the word list have length \($longest):",
(to_entries[] | select((.key|length) == $longest and (.value|length > 1)) | pp)
;
 
Line 303 ⟶ 314:
{{out}}
<lang sh>$ jq -R -r -c -s -f textonyms.jq textonyms.txt
There are 13085 words in the Textonyms/wordlist word list that can be represented by the digit-key mapping.
They require 11932 digit combinations to represent them.
661 digit combinations represent Textonyms.
The numbers mapping to the most words map to 15 words in the given word list:
27 maps to: ["AP","AQ","AR","AS","Ar","As","BP","BR","BS","Br","CP","CQ","CR","Cr","Cs"]</lang>
The longest Textonyms in the word list have length 11:
26456746242 maps to: ["Anglophobia","Anglophobic"]
24636272673 maps to: ["CinemaScope","Cinemascope"]</lang>
 
=={{header|Perl}}==
2,515

edits