RosettaCodeData/Task/Word-frequency/Jq/word-frequency-1.jq
2023-07-01 13:44:08 -04:00

11 lines
285 B
Text

< 135-0.txt jq -nR --argjson n 10 '
def bow(stream):
reduce stream as $word ({}; .[($word|tostring)] += 1);
bow(inputs | gsub("[^-a-zA-Z]"; " ") | splits(" *") | ascii_downcase | select(test("^[a-z][-a-z]*$")))
| to_entries
| sort_by(.value)
| .[- $n :]
| reverse
| from_entries
'