Download fixtures/pattern_lab/src/tokens.py from tailot/codex-python: direct link, hf CLI and curl.
- Browser
- Download file 583 Bytes
-
https://huggingface.co/datasets/tailot/codex-python/resolve/main/fixtures/pattern_lab/src/tokens.py
- Command line
-
hf download hf://datasets/tailot/codex-python/fixtures/pattern_lab/src/tokens.py
-
curl -L -o tokens.py https://huggingface.co/datasets/tailot/codex-python/resolve/main/fixtures/pattern_lab/src/tokens.py
583 Bytes
| """Counting words and lines in plain text notes. | |
| The module is deliberately untyped at the edges: some of its parameters carry a | |
| literal default and no annotation, which is the shape the annotation pattern of this | |
| bundle is allowed to touch. | |
| """ | |
| def count_words(text="", unit="word"): | |
| parts = text.split() | |
| if unit == "word": | |
| return len(parts) | |
| if unit == "line": | |
| return len(text.splitlines()) | |
| return 0 | |
| def count_lines(text: str = "") -> int: | |
| return len(text.splitlines()) | |
| def summarize(text, unit="word"): | |
| return count_words(text, unit) | |