helpish 0.2.0__tar.gz → 0.3.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.2.0 → helpish-0.3.0}/PKG-INFO +1 -1
- {helpish-0.2.0 → helpish-0.3.0}/pyproject.toml +1 -1
- helpish-0.3.0/src/helpish/__init__.py +7 -0
- helpish-0.2.0/src/helpish/__init__.py → helpish-0.3.0/src/helpish/app.py +3 -21
- helpish-0.3.0/src/helpish/words.py +20 -0
- {helpish-0.2.0 → helpish-0.3.0}/README.md +0 -0
- {helpish-0.2.0 → helpish-0.3.0}/src/helpish/words_alpha.txt +0 -0
|
@@ -1,29 +1,14 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Textual app that lists English words by length."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from collections import defaultdict
|
|
6
|
-
from importlib.resources import files
|
|
7
|
-
from pathlib import Path
|
|
8
|
-
|
|
9
5
|
from textual import on
|
|
10
6
|
from textual.app import App, ComposeResult
|
|
11
7
|
from textual.containers import Horizontal, VerticalScroll
|
|
12
8
|
from textual.widgets import Footer, Header, Input, Label, Static
|
|
13
9
|
from wordfreq import zipf_frequency
|
|
14
10
|
|
|
15
|
-
|
|
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
|
|
11
|
+
from helpish.words import WORDS_FILE, load_words_by_length
|
|
27
12
|
|
|
28
13
|
|
|
29
14
|
class WordLengthApp(App[None]):
|
|
@@ -129,8 +114,5 @@ class WordLengthApp(App[None]):
|
|
|
129
114
|
|
|
130
115
|
|
|
131
116
|
def main() -> None:
|
|
117
|
+
"""Run the app."""
|
|
132
118
|
WordLengthApp().run()
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if __name__ == "__main__":
|
|
136
|
-
main()
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Load and bucket the bundled English word list."""
|
|
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
|
+
WORDS_FILE = Path(str(files("helpish") / "words_alpha.txt"))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def load_words_by_length(path: Path) -> dict[int, list[str]]:
|
|
13
|
+
"""Read the word list once and bucket every word by its length."""
|
|
14
|
+
buckets: dict[int, list[str]] = defaultdict(list)
|
|
15
|
+
with path.open(encoding="utf-8") as handle:
|
|
16
|
+
for line in handle:
|
|
17
|
+
word = line.strip()
|
|
18
|
+
if word:
|
|
19
|
+
buckets[len(word)].append(word)
|
|
20
|
+
return buckets
|
|
File without changes
|
|
File without changes
|