denckring-de-frequency 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.
- denckring_de_frequency-0.1.0/.gitignore +39 -0
- denckring_de_frequency-0.1.0/LICENSE +202 -0
- denckring_de_frequency-0.1.0/LICENSE-LEIPZIG +17 -0
- denckring_de_frequency-0.1.0/NOTICE +27 -0
- denckring_de_frequency-0.1.0/PKG-INFO +56 -0
- denckring_de_frequency-0.1.0/README.md +39 -0
- denckring_de_frequency-0.1.0/pyproject.toml +39 -0
- denckring_de_frequency-0.1.0/scripts/build_frequency.py +158 -0
- denckring_de_frequency-0.1.0/src/denckring_de_frequency/__init__.py +105 -0
- denckring_de_frequency-0.1.0/src/denckring_de_frequency/data/.gitkeep +0 -0
- denckring_de_frequency-0.1.0/src/denckring_de_frequency/data/graded_words.txt.gz +0 -0
- denckring_de_frequency-0.1.0/src/denckring_de_frequency/data/metadata.json +9 -0
- denckring_de_frequency-0.1.0/src/denckring_de_frequency/py.typed +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
.venv/
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.pyc
|
|
4
|
+
.pytest_cache/
|
|
5
|
+
.mypy_cache/
|
|
6
|
+
.ruff_cache/
|
|
7
|
+
.hypothesis/
|
|
8
|
+
dist/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
dist/
|
|
11
|
+
|
|
12
|
+
# Generated docs and site build
|
|
13
|
+
docs/gallery/
|
|
14
|
+
docs/index.md
|
|
15
|
+
docs/contributing.md
|
|
16
|
+
docs/changelog.md
|
|
17
|
+
site/
|
|
18
|
+
|
|
19
|
+
# The explorer keeps its own environment
|
|
20
|
+
apps/explorer/.venv/
|
|
21
|
+
|
|
22
|
+
# Local secrets and paths for the explorer
|
|
23
|
+
apps/explorer/.env
|
|
24
|
+
|
|
25
|
+
# Claude Code session state, including worktrees
|
|
26
|
+
.claude/
|
|
27
|
+
|
|
28
|
+
# Subagent-driven-development scratch workspace (ledgers, briefs, review packages).
|
|
29
|
+
.superpowers/
|
|
30
|
+
|
|
31
|
+
# Node modules for the explorer's browser reproductions (apps/explorer/tests/browser).
|
|
32
|
+
# The manifest and lockfile beside them ARE tracked, so `npm ci --prefix apps/explorer`
|
|
33
|
+
# reinstalls exactly what those scripts were verified against; the 19MB tree is not.
|
|
34
|
+
apps/explorer/node_modules/
|
|
35
|
+
|
|
36
|
+
# pytest-cov writes this on every --cov run; the report is CI's, not the repo's.
|
|
37
|
+
.coverage
|
|
38
|
+
.coverage.*
|
|
39
|
+
htmlcov/
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
https://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
The frequency data in this distribution is derived from the Leipzig Corpora
|
|
2
|
+
Collection (corpus deu_news_2023_1M), © Universität Leipzig / Sächsische
|
|
3
|
+
Akademie der Wissenschaften / InfAI, made available under the Creative Commons
|
|
4
|
+
Attribution 4.0 International licence (CC BY 4.0).
|
|
5
|
+
|
|
6
|
+
https://corpora.uni-leipzig.de/
|
|
7
|
+
|
|
8
|
+
Only a derived table is redistributed here: each word is paired with a band
|
|
9
|
+
from 10 to 60 giving its frequency rank. No sentence, source list or
|
|
10
|
+
co-occurrence table from the corpus is included, and the corpus archive itself
|
|
11
|
+
is downloaded at build time and never vendored.
|
|
12
|
+
|
|
13
|
+
Cite the collection as its authors ask:
|
|
14
|
+
|
|
15
|
+
D. Goldhahn, T. Eckart, U. Quasthoff. Building Large Monolingual
|
|
16
|
+
Dictionaries at the Leipzig Corpora Collection: From 100 to 200 Languages.
|
|
17
|
+
Proceedings of LREC 2012.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
denckring-de-frequency
|
|
2
|
+
Copyright 2026 senzelden
|
|
3
|
+
|
|
4
|
+
This product includes software developed as part of the denckring project,
|
|
5
|
+
licensed under the Apache License, Version 2.0.
|
|
6
|
+
|
|
7
|
+
It also includes a derived frequency table built from the Leipzig Corpora
|
|
8
|
+
Collection, licensed under a Creative Commons Attribution licence. See
|
|
9
|
+
LICENSE-LEIPZIG for attribution.
|
|
10
|
+
|
|
11
|
+
ON THE LICENCE VERSION
|
|
12
|
+
----------------------
|
|
13
|
+
Creative Commons Attribution 4.0, established from the Leipzig project's own
|
|
14
|
+
page: its terms of usage say only
|
|
15
|
+
|
|
16
|
+
The text corpora offered for download are made available under the
|
|
17
|
+
Creative Commons licence CC BY.
|
|
18
|
+
|
|
19
|
+
with no version in the prose, and the corpus archive documents no licence at all
|
|
20
|
+
— its meta.txt is eight lines of build statistics and its only other non-data
|
|
21
|
+
member is a MySQL schema dump. The version is carried by the link on "CC BY",
|
|
22
|
+
which points at the 4.0 deed.
|
|
23
|
+
|
|
24
|
+
Recorded because secondary sources disagree — the project's older printed
|
|
25
|
+
frequency dictionaries are described as CC BY 3.0 — and because a licence
|
|
26
|
+
version in package metadata is a claim about somebody else's rights, which is
|
|
27
|
+
worth sourcing rather than inferring.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: denckring-de-frequency
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: German frequency bands for denckring, from the Leipzig Corpora Collection
|
|
5
|
+
Author-email: Dennis Senzel <dennis.senzel@posteo.com>
|
|
6
|
+
License-Expression: Apache-2.0 AND CC-BY-4.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
License-File: LICENSE-LEIPZIG
|
|
9
|
+
License-File: NOTICE
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Natural Language :: German
|
|
12
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
13
|
+
Classifier: Typing :: Typed
|
|
14
|
+
Requires-Python: >=3.11
|
|
15
|
+
Requires-Dist: denckring-de-data==0.1.0
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# denckring-de-frequency
|
|
19
|
+
|
|
20
|
+
German frequency bands for [denckring](https://github.com/senzelden/denckring),
|
|
21
|
+
from the [Leipzig Corpora Collection](https://corpora.uni-leipzig.de/).
|
|
22
|
+
|
|
23
|
+
```console
|
|
24
|
+
pip install denckring[de-frequency]
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
It supplies one capability, `lexicon.graded_words`: a table pairing each word
|
|
28
|
+
with a band from 10 to 60, where **larger means less common**. `anagram` needs
|
|
29
|
+
it to rank the covers it finds — a search that cannot tell a common word from a
|
|
30
|
+
rare one returns its answers in no useful order — and without this distribution
|
|
31
|
+
German `anagram` can check but not generate.
|
|
32
|
+
|
|
33
|
+
It registers no entry point. `denckring-de-data` owns the `de` language and its
|
|
34
|
+
`pack()` factory composes this distribution in when it is importable, because
|
|
35
|
+
`denckring` refuses two packs claiming one language (ADR 0013, ADR 0030).
|
|
36
|
+
|
|
37
|
+
## Why a separate distribution
|
|
38
|
+
|
|
39
|
+
German data now arrives under three licences: `denckring-de-data` is CC0
|
|
40
|
+
Wikidata, `denckring-de-wiktionary` is CC BY-SA Wiktionary, and this is CC BY
|
|
41
|
+
Leipzig. ADR 0013 quarantines a data licence in its own distribution, and CC BY
|
|
42
|
+
cannot join the CC0 package — CC0 waives rights where CC BY requires
|
|
43
|
+
attribution, so merging them would make that package's declaration false.
|
|
44
|
+
|
|
45
|
+
It is deliberately independent of `denckring-de-wiktionary`, so German `anagram`
|
|
46
|
+
does not pull in 6.5 MB of pronunciations it never reads.
|
|
47
|
+
|
|
48
|
+
## Rebuilding the table
|
|
49
|
+
|
|
50
|
+
```console
|
|
51
|
+
uv run python packages/denckring-de-frequency/scripts/build_frequency.py
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Downloads the corpus once into `~/.cache/denckring-dumps` and writes
|
|
55
|
+
`graded_words.txt.gz`. See ADR 0038 for the case rule the build turns on, and
|
|
56
|
+
for the two costs it accepts.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# denckring-de-frequency
|
|
2
|
+
|
|
3
|
+
German frequency bands for [denckring](https://github.com/senzelden/denckring),
|
|
4
|
+
from the [Leipzig Corpora Collection](https://corpora.uni-leipzig.de/).
|
|
5
|
+
|
|
6
|
+
```console
|
|
7
|
+
pip install denckring[de-frequency]
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
It supplies one capability, `lexicon.graded_words`: a table pairing each word
|
|
11
|
+
with a band from 10 to 60, where **larger means less common**. `anagram` needs
|
|
12
|
+
it to rank the covers it finds — a search that cannot tell a common word from a
|
|
13
|
+
rare one returns its answers in no useful order — and without this distribution
|
|
14
|
+
German `anagram` can check but not generate.
|
|
15
|
+
|
|
16
|
+
It registers no entry point. `denckring-de-data` owns the `de` language and its
|
|
17
|
+
`pack()` factory composes this distribution in when it is importable, because
|
|
18
|
+
`denckring` refuses two packs claiming one language (ADR 0013, ADR 0030).
|
|
19
|
+
|
|
20
|
+
## Why a separate distribution
|
|
21
|
+
|
|
22
|
+
German data now arrives under three licences: `denckring-de-data` is CC0
|
|
23
|
+
Wikidata, `denckring-de-wiktionary` is CC BY-SA Wiktionary, and this is CC BY
|
|
24
|
+
Leipzig. ADR 0013 quarantines a data licence in its own distribution, and CC BY
|
|
25
|
+
cannot join the CC0 package — CC0 waives rights where CC BY requires
|
|
26
|
+
attribution, so merging them would make that package's declaration false.
|
|
27
|
+
|
|
28
|
+
It is deliberately independent of `denckring-de-wiktionary`, so German `anagram`
|
|
29
|
+
does not pull in 6.5 MB of pronunciations it never reads.
|
|
30
|
+
|
|
31
|
+
## Rebuilding the table
|
|
32
|
+
|
|
33
|
+
```console
|
|
34
|
+
uv run python packages/denckring-de-frequency/scripts/build_frequency.py
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Downloads the corpus once into `~/.cache/denckring-dumps` and writes
|
|
38
|
+
`graded_words.txt.gz`. See ADR 0038 for the case rule the build turns on, and
|
|
39
|
+
for the two costs it accepts.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "denckring-de-frequency"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "German frequency bands for denckring, from the Leipzig Corpora Collection"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.11"
|
|
7
|
+
# The version is not in the terms' prose — they say only "the Creative Commons
|
|
8
|
+
# licence CC BY" — nor anywhere in the corpus archive, whose meta.txt is eight
|
|
9
|
+
# lines of build statistics. It is in the link: the page's "CC BY" points at the
|
|
10
|
+
# 4.0 deed, which is the project's own statement rather than a secondary one.
|
|
11
|
+
# Worth recording because secondary sources disagree, and because a licence
|
|
12
|
+
# version in package metadata is a claim about somebody else's rights.
|
|
13
|
+
license = "Apache-2.0 AND CC-BY-4.0"
|
|
14
|
+
license-files = ["LICENSE", "NOTICE", "LICENSE-LEIPZIG"]
|
|
15
|
+
authors = [{ name = "Dennis Senzel", email = "dennis.senzel@posteo.com" }]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Intended Audience :: Science/Research",
|
|
18
|
+
"Natural Language :: German",
|
|
19
|
+
"Topic :: Text Processing :: Linguistic",
|
|
20
|
+
"Typing :: Typed",
|
|
21
|
+
]
|
|
22
|
+
# Version-locked, for the reason denckring-en-data records. `denckring-de-data`
|
|
23
|
+
# rather than `denckring`, because the build's case rule needs `nouns()` and the
|
|
24
|
+
# pack below subclasses `GermanDataPack` — the same direction the Wiktionary
|
|
25
|
+
# distribution's dependency runs.
|
|
26
|
+
dependencies = ["denckring-de-data==0.1.0"]
|
|
27
|
+
|
|
28
|
+
# No [project.entry-points."denckring.lang"] section, and its absence is the
|
|
29
|
+
# design — the same absence `denckring-de-wiktionary` documents.
|
|
30
|
+
# `denckring/lang/__init__.py` refuses two entry points claiming one language,
|
|
31
|
+
# so `de` stays with `denckring-de-data`, whose `pack()` factory composes this
|
|
32
|
+
# distribution in when it is importable (ADR 0013, ADR 0030, ADR 0038).
|
|
33
|
+
|
|
34
|
+
[build-system]
|
|
35
|
+
requires = ["hatchling"]
|
|
36
|
+
build-backend = "hatchling.build"
|
|
37
|
+
|
|
38
|
+
[tool.hatch.build.targets.wheel]
|
|
39
|
+
packages = ["src/denckring_de_frequency"]
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"""Build German frequency bands from a Leipzig Corpora Collection corpus.
|
|
2
|
+
|
|
3
|
+
Run by hand, not by any gate. It downloads 219 MB and writes one artefact:
|
|
4
|
+
|
|
5
|
+
uv run python packages/denckring-de-frequency/scripts/build_frequency.py
|
|
6
|
+
|
|
7
|
+
The source is the Leipzig Corpora Collection's `deu_news_2023_1M`, whose
|
|
8
|
+
`*-words.txt` is `id <tab> word <tab> frequency`. Only that one member is read;
|
|
9
|
+
the sentences, the source list and the two co-occurrence tables are never opened
|
|
10
|
+
and never redistributed. See ADR 0038, and `LICENSE-LEIPZIG` for attribution.
|
|
11
|
+
|
|
12
|
+
Leipzig's terms forbid automated *queries* against their web service. This is
|
|
13
|
+
the published download they offer instead, taken once and cached.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import gzip
|
|
19
|
+
import json
|
|
20
|
+
import tarfile
|
|
21
|
+
import urllib.request
|
|
22
|
+
from datetime import date
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
|
|
25
|
+
CORPUS = "deu_news_2023_1M"
|
|
26
|
+
URL = f"https://downloads.wortschatz-leipzig.de/corpora/{CORPUS}.tar.gz"
|
|
27
|
+
|
|
28
|
+
#: Where the German Wiktionary chapter already caches its dump.
|
|
29
|
+
CACHE = Path.home() / ".cache" / "denckring-dumps"
|
|
30
|
+
|
|
31
|
+
#: Six bands, larger meaning *less* common — SCOWL's direction, which
|
|
32
|
+
#: `LanguagePack.graded_words` documents and `anagram` sorts ascending by. The
|
|
33
|
+
#: ceiling is 60 because `anagram`'s `max_size` is capped there. Identical to
|
|
34
|
+
#: `denckring-fr-data`'s, deliberately: this is the third distribution to write
|
|
35
|
+
#: the same split, and re-deriving it would be a third chance to invert it.
|
|
36
|
+
BANDS = (10, 20, 30, 40, 50, 60)
|
|
37
|
+
|
|
38
|
+
#: `cd`, `kg` and `PS` are unit symbols and abbreviations rather than words worth
|
|
39
|
+
#: ranking. The same floor `calculator_word` chose, for the same reason.
|
|
40
|
+
MIN_LENGTH = 3
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def bands(rows: list[tuple[str, int]], known: set[str], nouns_lower: set[str]) -> dict[str, int]:
|
|
44
|
+
"""Frequency rows to a word-to-band table, applying the case rule.
|
|
45
|
+
|
|
46
|
+
**ADR 0038 D3, and the decision this whole chapter turns on.** German
|
|
47
|
+
capitalises common nouns, so a noun's German tokens are capitalised and its
|
|
48
|
+
lowercase tokens belong to another language. Leipzig keeps that distinction.
|
|
49
|
+
This project's own German word lists have thrown it away — `known_words()`
|
|
50
|
+
is 0 capitalised of 668,580 — and only `nouns()` keeps it, so the noun list
|
|
51
|
+
is the case oracle:
|
|
52
|
+
|
|
53
|
+
- a form whose lowercase is a known noun counts **only when capitalised**;
|
|
54
|
+
- every other form counts only when lowercase.
|
|
55
|
+
|
|
56
|
+
Lowercase `power`, `list` and `tower` in a German corpus are English tokens
|
|
57
|
+
and are dropped; their capitalised German counterparts are kept with the
|
|
58
|
+
frequency they actually have.
|
|
59
|
+
|
|
60
|
+
Without this the chapter reverts to the failure it exists to fix. The
|
|
61
|
+
rejected OpenSubtitles source had lowercased everything, merging `Tag` with
|
|
62
|
+
`tag`; a later draft here then lowercased the Leipzig keys *before*
|
|
63
|
+
intersecting and reproduced the same defect from the other end —
|
|
64
|
+
`Wortspiel -> list power` came straight back at 1M scale, where lowercase
|
|
65
|
+
English `list` does occur in German news.
|
|
66
|
+
|
|
67
|
+
`rows` may repeat a form; the largest count wins, since a corpus can split
|
|
68
|
+
one word across rows the tokeniser did not unify.
|
|
69
|
+
"""
|
|
70
|
+
best: dict[str, int] = {}
|
|
71
|
+
for form, count in rows:
|
|
72
|
+
if not form.isalpha() or len(form) < MIN_LENGTH:
|
|
73
|
+
continue
|
|
74
|
+
low = form.lower()
|
|
75
|
+
if low not in known:
|
|
76
|
+
continue
|
|
77
|
+
if (low in nouns_lower) != form[:1].isupper():
|
|
78
|
+
continue
|
|
79
|
+
best[low] = max(best.get(low, 0), count)
|
|
80
|
+
|
|
81
|
+
ranked = sorted(best, key=lambda word: (-best[word], word))
|
|
82
|
+
return {
|
|
83
|
+
word: BANDS[min(index * len(BANDS) // max(len(ranked), 1), len(BANDS) - 1)]
|
|
84
|
+
for index, word in enumerate(ranked)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def fetch(cache: Path = CACHE) -> Path:
|
|
89
|
+
"""The corpus archive, downloaded once and kept."""
|
|
90
|
+
cache.mkdir(parents=True, exist_ok=True)
|
|
91
|
+
archive = cache / f"{CORPUS}.tar.gz"
|
|
92
|
+
if not archive.exists():
|
|
93
|
+
urllib.request.urlretrieve(URL, archive)
|
|
94
|
+
return archive
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def rows_from(archive: Path) -> list[tuple[str, int]]:
|
|
98
|
+
"""The `(form, count)` pairs from the archive's one words file.
|
|
99
|
+
|
|
100
|
+
Read straight out of the tar rather than unpacking: the archive also holds a
|
|
101
|
+
million sentences, a source list and two co-occurrence tables that this build
|
|
102
|
+
never wants and that would cost about a gigabyte on disk to ignore.
|
|
103
|
+
"""
|
|
104
|
+
wanted = f"{CORPUS}/{CORPUS}-words.txt"
|
|
105
|
+
with tarfile.open(archive) as bundle:
|
|
106
|
+
member = bundle.extractfile(wanted)
|
|
107
|
+
if member is None:
|
|
108
|
+
raise SystemExit(f"{wanted} is not in {archive}")
|
|
109
|
+
rows: list[tuple[str, int]] = []
|
|
110
|
+
for line in member.read().decode("utf-8").splitlines():
|
|
111
|
+
parts = line.split("\t")
|
|
112
|
+
if len(parts) == 3 and parts[2].isdigit():
|
|
113
|
+
rows.append((parts[1], int(parts[2])))
|
|
114
|
+
return rows
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def main() -> None:
|
|
118
|
+
from denckring_de_data import GermanDataPack, known_words
|
|
119
|
+
|
|
120
|
+
archive = fetch()
|
|
121
|
+
rows = rows_from(archive)
|
|
122
|
+
table = bands(
|
|
123
|
+
rows,
|
|
124
|
+
{word.lower() for word in known_words()},
|
|
125
|
+
{noun.lower() for noun in GermanDataPack().nouns()},
|
|
126
|
+
)
|
|
127
|
+
data = Path(__file__).parent.parent / "src" / "denckring_de_frequency" / "data"
|
|
128
|
+
out = data / "graded_words.txt.gz"
|
|
129
|
+
with gzip.open(out, "wt", encoding="utf-8") as handle:
|
|
130
|
+
for word in sorted(table):
|
|
131
|
+
handle.write(f"{word}\t{table[word]}\n")
|
|
132
|
+
# `rows_read` is not in the German lexical package's metadata and is here on
|
|
133
|
+
# purpose: the ratio of rows in to words out is what the case rule changes,
|
|
134
|
+
# so a rebuild that quietly lost the rule shows up as the same corpus
|
|
135
|
+
# suddenly yielding far more words.
|
|
136
|
+
(data / "metadata.json").write_text(
|
|
137
|
+
json.dumps(
|
|
138
|
+
{
|
|
139
|
+
"counts": {"graded_words.txt.gz": len(table)},
|
|
140
|
+
"generated": date.today().isoformat(),
|
|
141
|
+
"rows_read": len(rows),
|
|
142
|
+
"corpus": CORPUS,
|
|
143
|
+
"source": (
|
|
144
|
+
"Leipzig Corpora Collection, CC BY - see LICENSE-LEIPZIG, "
|
|
145
|
+
"NOTICE on the licence version, and scripts/build_frequency.py"
|
|
146
|
+
),
|
|
147
|
+
},
|
|
148
|
+
indent=2,
|
|
149
|
+
sort_keys=True,
|
|
150
|
+
)
|
|
151
|
+
+ "\n",
|
|
152
|
+
encoding="utf-8",
|
|
153
|
+
)
|
|
154
|
+
print(f"{len(rows)} rows in, {len(table)} graded words, {out.stat().st_size:,} bytes")
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
if __name__ == "__main__":
|
|
158
|
+
main()
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"""German frequency bands, from the Leipzig Corpora Collection.
|
|
2
|
+
|
|
3
|
+
The sixth distribution, and the third carrying German data — under a third
|
|
4
|
+
licence. `denckring-de-data` is CC0 Wikidata, `denckring-de-wiktionary` is
|
|
5
|
+
CC BY-SA Wiktionary, and this is CC BY Leipzig. ADR 0013 quarantines a data
|
|
6
|
+
licence in its own distribution, and CC BY cannot join the CC0 package: CC0
|
|
7
|
+
waives rights where CC BY requires attribution, so merging them would make that
|
|
8
|
+
package's own declaration false.
|
|
9
|
+
|
|
10
|
+
Registers no entry point. See the pyproject for why, and ADR 0038 for the case
|
|
11
|
+
rule the build turns on.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import gzip
|
|
17
|
+
from collections.abc import Mapping
|
|
18
|
+
from functools import lru_cache
|
|
19
|
+
from importlib.resources import files
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
from types import MappingProxyType
|
|
22
|
+
from typing import ClassVar
|
|
23
|
+
|
|
24
|
+
from denckring_de_data import GermanDataPack
|
|
25
|
+
|
|
26
|
+
from denckring.lang.base import GRADED_WORDS
|
|
27
|
+
|
|
28
|
+
GRADED_WORDS_PATH = Path(str(files("denckring_de_frequency") / "data" / "graded_words.txt.gz"))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@lru_cache(maxsize=1)
|
|
32
|
+
def graded_words() -> Mapping[str, int]:
|
|
33
|
+
"""Word to frequency band, where **larger means less common**.
|
|
34
|
+
|
|
35
|
+
SCOWL's direction, which `LanguagePack.graded_words` documents and `anagram`
|
|
36
|
+
sorts ascending by. Not re-derived here: this is the third distribution to
|
|
37
|
+
write the same six bands, and re-deriving them would be a third chance to
|
|
38
|
+
get the direction backwards.
|
|
39
|
+
|
|
40
|
+
Keys are lowercase, which is the capability's de-facto convention — English's
|
|
41
|
+
77,078 and French's 125,343 carry 0 capitals between them, and `anagram`
|
|
42
|
+
matches its covers against these keys, so a capitalised key would silently
|
|
43
|
+
match nothing. German is the first language for which that loses
|
|
44
|
+
information, since a noun's capital is part of its spelling; ADR 0038 records
|
|
45
|
+
the cost rather than quietly changing a capability's contract.
|
|
46
|
+
"""
|
|
47
|
+
table: dict[str, int] = {}
|
|
48
|
+
with gzip.open(GRADED_WORDS_PATH, mode="rt", encoding="utf-8") as handle:
|
|
49
|
+
for line in handle:
|
|
50
|
+
word, _, band = line.rstrip("\n").partition("\t")
|
|
51
|
+
if band:
|
|
52
|
+
table[word] = int(band)
|
|
53
|
+
return table
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class GermanFrequencyPack(GermanDataPack):
|
|
57
|
+
"""German with a lexicon and frequency bands behind it."""
|
|
58
|
+
|
|
59
|
+
capabilities: ClassVar[frozenset[str]] = GermanDataPack.capabilities | {GRADED_WORDS}
|
|
60
|
+
|
|
61
|
+
def graded_words(self) -> Mapping[str, int]:
|
|
62
|
+
"""A read-only view over the cached table, for the reason English gives:
|
|
63
|
+
the module function is `lru_cache`d and shared, so handing the dict out
|
|
64
|
+
would let one caller's mutation corrupt it for all the others."""
|
|
65
|
+
return MappingProxyType(graded_words())
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
try:
|
|
69
|
+
from denckring_de_wiktionary import GermanWiktionaryPack
|
|
70
|
+
except ImportError: # pragma: no cover - depends on what is installed
|
|
71
|
+
#: Without the Wiktionary distribution there is no richer pack to combine
|
|
72
|
+
#: with, and the factory in `denckring-de-data` never reaches for this name.
|
|
73
|
+
#: Bound anyway so the module's exports do not depend on an install.
|
|
74
|
+
GermanWiktionaryFrequencyPack = GermanFrequencyPack
|
|
75
|
+
else:
|
|
76
|
+
|
|
77
|
+
class GermanWiktionaryFrequencyPack(GermanWiktionaryPack): # type: ignore[no-redef]
|
|
78
|
+
"""Everything German has: lexicon, pronunciations, and frequency.
|
|
79
|
+
|
|
80
|
+
Declared here rather than in `denckring-de-wiktionary`, because that
|
|
81
|
+
distribution must not learn about this one. Either is installable
|
|
82
|
+
without the other, and a hard dependency in that direction would make
|
|
83
|
+
one of those installs impossible. This package imports it optionally
|
|
84
|
+
instead — the same shape `denckring-de-data`'s own factory uses, and for
|
|
85
|
+
the same reason (ADR 0013, ADR 0030).
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
capabilities: ClassVar[frozenset[str]] = GermanWiktionaryPack.capabilities | {GRADED_WORDS}
|
|
89
|
+
|
|
90
|
+
def graded_words(self) -> Mapping[str, int]:
|
|
91
|
+
return MappingProxyType(graded_words())
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
#: Kept in step with `pyproject.toml` by hand, the way the four sibling data
|
|
95
|
+
#: distributions do. This one shipped without it (ADR 0038) and was the second
|
|
96
|
+
#: thing about the sixth distribution to be half-integrated — the release plan
|
|
97
|
+
#: had also counted five distributions, not six.
|
|
98
|
+
__version__ = "0.1.0"
|
|
99
|
+
|
|
100
|
+
__all__ = [
|
|
101
|
+
"GRADED_WORDS_PATH",
|
|
102
|
+
"GermanFrequencyPack",
|
|
103
|
+
"GermanWiktionaryFrequencyPack",
|
|
104
|
+
"graded_words",
|
|
105
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"corpus": "deu_news_2023_1M",
|
|
3
|
+
"counts": {
|
|
4
|
+
"graded_words.txt.gz": 101296
|
|
5
|
+
},
|
|
6
|
+
"generated": "2026-09-04",
|
|
7
|
+
"rows_read": 759696,
|
|
8
|
+
"source": "Leipzig Corpora Collection, CC BY - see LICENSE-LEIPZIG, NOTICE on the licence version, and scripts/build_frequency.py"
|
|
9
|
+
}
|
|
File without changes
|