Download python/word_frequency.py from neopilot/PyRs2: direct link, hf CLI and curl.
- Browser
- Download file 195 Bytes
-
https://huggingface.co/datasets/neopilot/PyRs2/resolve/main/python/word_frequency.py
- Command line
-
hf download hf://datasets/neopilot/PyRs2/python/word_frequency.py
-
curl -L -o word_frequency.py https://huggingface.co/datasets/neopilot/PyRs2/resolve/main/python/word_frequency.py
195 Bytes
| from collections import Counter | |
| def word_frequency(file_path): | |
| with open(file_path, 'r') as f: | |
| words = f.read().split() | |
| return Counter(words) | |
| print(word_frequency('sample.txt')) |