helpish 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- helpish-0.1.0/PKG-INFO +42 -0
- helpish-0.1.0/README.md +33 -0
- helpish-0.1.0/pyproject.toml +20 -0
- helpish-0.1.0/src/helpish/__init__.py +136 -0
- helpish-0.1.0/src/helpish/words_alpha.txt +370105 -0
helpish-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: helpish
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: List English words by length — handy for writing Pilish.
|
|
5
|
+
Requires-Dist: textual>=8.2.8
|
|
6
|
+
Requires-Dist: wordfreq>=3.1.1
|
|
7
|
+
Requires-Python: >=3.12
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
|
|
10
|
+
# helpish
|
|
11
|
+
|
|
12
|
+
A terminal app that lists every English word of a given length — handy for writing [Pilish](https://en.wikipedia.org/wiki/Pilish), where each word's length encodes a digit of π.
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
Run it without installing using [uvx](https://docs.astral.sh/uv/):
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
uvx helpish
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or install from PyPI and run the `helpish` command:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install helpish
|
|
28
|
+
helpish
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Run it directly from a checkout with uv:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
uv run helpish
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- Enter a number to see all words of that length.
|
|
38
|
+
- Use the **Contains** field to filter by substring.
|
|
39
|
+
- Results are sorted by frequency (most common first).
|
|
40
|
+
- Press `Ctrl+C` to quit.
|
|
41
|
+
|
|
42
|
+
Words come from `words_alpha.txt`, a comprehensive list that includes inflected forms (plurals, conjugations, comparatives), not just dictionary head-words.
|
helpish-0.1.0/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# helpish
|
|
2
|
+
|
|
3
|
+
A terminal app that lists every English word of a given length — handy for writing [Pilish](https://en.wikipedia.org/wiki/Pilish), where each word's length encodes a digit of π.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
Run it without installing using [uvx](https://docs.astral.sh/uv/):
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
uvx helpish
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Or install from PyPI and run the `helpish` command:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install helpish
|
|
19
|
+
helpish
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Run it directly from a checkout with uv:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
uv run helpish
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- Enter a number to see all words of that length.
|
|
29
|
+
- Use the **Contains** field to filter by substring.
|
|
30
|
+
- Results are sorted by frequency (most common first).
|
|
31
|
+
- Press `Ctrl+C` to quit.
|
|
32
|
+
|
|
33
|
+
Words come from `words_alpha.txt`, a comprehensive list that includes inflected forms (plurals, conjugations, comparatives), not just dictionary head-words.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "helpish"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "List English words by length — handy for writing Pilish."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.12"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"textual>=8.2.8",
|
|
9
|
+
"wordfreq>=3.1.1",
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
[project.scripts]
|
|
13
|
+
helpish = "helpish:main"
|
|
14
|
+
|
|
15
|
+
[build-system]
|
|
16
|
+
requires = ["uv_build>=0.8.0,<0.9.0"]
|
|
17
|
+
build-backend = "uv_build"
|
|
18
|
+
|
|
19
|
+
[tool.uv.build-backend]
|
|
20
|
+
module-name = "helpish"
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"""helpish: list English words by length, handy for writing Pilish."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections import defaultdict
|
|
6
|
+
from importlib.resources import files
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from textual import on
|
|
10
|
+
from textual.app import App, ComposeResult
|
|
11
|
+
from textual.containers import Horizontal, VerticalScroll
|
|
12
|
+
from textual.widgets import Footer, Header, Input, Label, Static
|
|
13
|
+
from wordfreq import zipf_frequency
|
|
14
|
+
|
|
15
|
+
WORDS_FILE = Path(str(files("helpish") / "words_alpha.txt"))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def load_words_by_length(path: Path) -> dict[int, list[str]]:
|
|
19
|
+
"""Read the word list once and bucket every word by its length."""
|
|
20
|
+
buckets: dict[int, list[str]] = defaultdict(list)
|
|
21
|
+
with path.open(encoding="utf-8") as handle:
|
|
22
|
+
for line in handle:
|
|
23
|
+
word = line.strip()
|
|
24
|
+
if word:
|
|
25
|
+
buckets[len(word)].append(word)
|
|
26
|
+
return buckets
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class WordLengthApp(App[None]):
|
|
30
|
+
"""Type a number, see every English word of that length."""
|
|
31
|
+
|
|
32
|
+
CSS = """
|
|
33
|
+
#controls {
|
|
34
|
+
height: auto;
|
|
35
|
+
padding: 1 2;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
#length-input {
|
|
39
|
+
width: 20;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
#summary {
|
|
43
|
+
padding: 1 2;
|
|
44
|
+
color: $text-muted;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
#results {
|
|
48
|
+
padding: 0 2;
|
|
49
|
+
}
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
TITLE = "English Words by Length"
|
|
53
|
+
BINDINGS = [("ctrl+c", "quit", "Quit")]
|
|
54
|
+
|
|
55
|
+
def __init__(self) -> None:
|
|
56
|
+
super().__init__()
|
|
57
|
+
self.words_by_length: dict[int, list[str]] = {}
|
|
58
|
+
|
|
59
|
+
def compose(self) -> ComposeResult:
|
|
60
|
+
yield Header()
|
|
61
|
+
with Horizontal(id="controls"):
|
|
62
|
+
yield Label("Word length: ")
|
|
63
|
+
yield Input(
|
|
64
|
+
placeholder="enter a number",
|
|
65
|
+
id="length-input",
|
|
66
|
+
type="integer",
|
|
67
|
+
restrict=r"\d*",
|
|
68
|
+
)
|
|
69
|
+
yield Label(" Contains: ")
|
|
70
|
+
yield Input(
|
|
71
|
+
placeholder="substring filter",
|
|
72
|
+
id="filter-input",
|
|
73
|
+
)
|
|
74
|
+
yield Static("", id="summary")
|
|
75
|
+
yield VerticalScroll(Static("", id="results"))
|
|
76
|
+
yield Footer()
|
|
77
|
+
|
|
78
|
+
def on_mount(self) -> None:
|
|
79
|
+
if not WORDS_FILE.exists():
|
|
80
|
+
self.query_one("#summary", Static).update(
|
|
81
|
+
f"[red]Word list not found:[/] {WORDS_FILE}"
|
|
82
|
+
)
|
|
83
|
+
return
|
|
84
|
+
self.words_by_length = load_words_by_length(WORDS_FILE)
|
|
85
|
+
total = sum(len(w) for w in self.words_by_length.values())
|
|
86
|
+
longest = max(self.words_by_length) if self.words_by_length else 0
|
|
87
|
+
self.query_one("#summary", Static).update(
|
|
88
|
+
f"Loaded {total:,} words (lengths 1–{longest}). "
|
|
89
|
+
"Enter a number above."
|
|
90
|
+
)
|
|
91
|
+
self.query_one("#length-input", Input).focus()
|
|
92
|
+
|
|
93
|
+
@on(Input.Changed, "#length-input")
|
|
94
|
+
@on(Input.Changed, "#filter-input")
|
|
95
|
+
def show_words(self) -> None:
|
|
96
|
+
summary = self.query_one("#summary", Static)
|
|
97
|
+
results = self.query_one("#results", Static)
|
|
98
|
+
|
|
99
|
+
value = self.query_one("#length-input", Input).value.strip()
|
|
100
|
+
needle = self.query_one("#filter-input", Input).value.strip().lower()
|
|
101
|
+
if not value:
|
|
102
|
+
summary.update("Enter a number above.")
|
|
103
|
+
results.update("")
|
|
104
|
+
return
|
|
105
|
+
|
|
106
|
+
length = int(value)
|
|
107
|
+
words = self.words_by_length.get(length, [])
|
|
108
|
+
if needle:
|
|
109
|
+
words = [word for word in words if needle in word]
|
|
110
|
+
if not words:
|
|
111
|
+
if needle:
|
|
112
|
+
summary.update(
|
|
113
|
+
f"No words of length {length} containing '{needle}'."
|
|
114
|
+
)
|
|
115
|
+
else:
|
|
116
|
+
summary.update(f"No words of length {length}.")
|
|
117
|
+
results.update("")
|
|
118
|
+
return
|
|
119
|
+
|
|
120
|
+
ordered = sorted(
|
|
121
|
+
words, key=lambda word: zipf_frequency(word, "en"), reverse=True
|
|
122
|
+
)
|
|
123
|
+
suffix = f" containing '{needle}'" if needle else ""
|
|
124
|
+
summary.update(
|
|
125
|
+
f"[b]{len(ordered):,}[/] words of length {length}{suffix} "
|
|
126
|
+
"(most frequent first):"
|
|
127
|
+
)
|
|
128
|
+
results.update(" ".join(ordered))
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def main() -> None:
|
|
132
|
+
WordLengthApp().run()
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
if __name__ == "__main__":
|
|
136
|
+
main()
|