Download data/software-top_words-5/solution.py from stoiclion/agent-workbench: direct link, hf CLI and curl.
- Browser
- Download file 275 Bytes
-
https://huggingface.co/datasets/stoiclion/agent-workbench/resolve/main/data/software-top_words-5/solution.py
- Command line
-
hf download hf://datasets/stoiclion/agent-workbench/data/software-top_words-5/solution.py
-
curl -L -o solution.py https://huggingface.co/datasets/stoiclion/agent-workbench/resolve/main/data/software-top_words-5/solution.py
275 Bytes
| def top_words(text, k): | |
| """The k most frequent lowercase words; ties broken alphabetically. Words are runs of letters.""" | |
| import re | |
| from collections import Counter | |
| counts = Counter(re.findall(r"[a-z]+", text)) | |
| return [w for w, _ in counts.most_common(k)] | |