parquet-converter
commited on
Commit
•
e7ac29f
1
Parent(s):
ceba5f9
Update parquet files
Browse files- .gitattributes +3 -0
- .github/workflows/ci-cd.yaml +0 -90
- .gitignore +0 -8
- LICENSE +0 -201
- Languages/Akkadian/0000.parquet +0 -0
- Languages/AncientGreek/0000.parquet +3 -0
- Languages/German/0000.parquet +3 -0
- Languages/Korean/0000.parquet +0 -0
- Languages/Latin/0000.parquet +3 -0
- Languages/OldPersian/0000.parquet +0 -0
- README.md +0 -100
- extract.py +0 -26
- requirements.txt +0 -1
- tests/__init__.py +0 -0
- tests/wiktionary/__init__.py +0 -0
- tests/wiktionary/wiktextract/__init__.py +0 -0
- tests/wiktionary/wiktextract/test_german.py +0 -26
- tests/wiktionary/wiktextract/test_parse.py +0 -78
- wiktionary/__init__.py +0 -0
- wiktionary/wiktextract/__init__.py +0 -0
- wiktionary/wiktextract/extract.py +0 -90
- wiktionary/wiktextract/german.py +0 -127
- wiktionary/wiktextract/parse.py +0 -33
.gitattributes
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
Languages/German/0000.parquet filter=lfs diff=lfs merge=lfs -text
|
2 |
+
Languages/Latin/0000.parquet filter=lfs diff=lfs merge=lfs -text
|
3 |
+
Languages/AncientGreek/0000.parquet filter=lfs diff=lfs merge=lfs -text
|
.github/workflows/ci-cd.yaml
DELETED
@@ -1,90 +0,0 @@
|
|
1 |
-
# Copyright Jiaqi Liu
|
2 |
-
#
|
3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
-
# you may not use this file except in compliance with the License.
|
5 |
-
# You may obtain a copy of the License at
|
6 |
-
#
|
7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
-
#
|
9 |
-
# Unless required by applicable law or agreed to in writing, software
|
10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
-
# See the License for the specific language governing permissions and
|
13 |
-
# limitations under the License.
|
14 |
-
---
|
15 |
-
name: CI/CD
|
16 |
-
|
17 |
-
"on":
|
18 |
-
pull_request:
|
19 |
-
push:
|
20 |
-
branches:
|
21 |
-
- master
|
22 |
-
|
23 |
-
env:
|
24 |
-
PYTHON_VERSION: "3.10"
|
25 |
-
|
26 |
-
jobs:
|
27 |
-
cancel-previous:
|
28 |
-
name: Cancel Previous Runs In Order to Allocate Action Resources Immediately for Current Run
|
29 |
-
if: github.ref != 'refs/heads/master'
|
30 |
-
runs-on: ubuntu-latest
|
31 |
-
steps:
|
32 |
-
- name: Cancel previous
|
33 |
-
uses: styfle/cancel-workflow-action@0.10.1
|
34 |
-
with:
|
35 |
-
access_token: ${{ github.token }}
|
36 |
-
|
37 |
-
# yaml-lint:
|
38 |
-
# name: YAML Style Check
|
39 |
-
# runs-on: ubuntu-latest
|
40 |
-
# steps:
|
41 |
-
# - uses: actions/checkout@v3
|
42 |
-
# - uses: actionshub/yamllint@main
|
43 |
-
#
|
44 |
-
# linkChecker:
|
45 |
-
# name: Link Check
|
46 |
-
# runs-on: ubuntu-latest
|
47 |
-
# steps:
|
48 |
-
# - uses: actions/checkout@v3
|
49 |
-
# - name: Link Checker
|
50 |
-
# uses: lycheeverse/lychee-action@v1.9.0
|
51 |
-
# with:
|
52 |
-
# fail: true
|
53 |
-
|
54 |
-
sync-to-huggingface-space:
|
55 |
-
#needs: [yaml-lint, linkChecker]
|
56 |
-
runs-on: ubuntu-latest
|
57 |
-
steps:
|
58 |
-
- uses: actions/checkout@v3
|
59 |
-
with:
|
60 |
-
fetch-depth: 0
|
61 |
-
lfs: true
|
62 |
-
- name: Set up Python ${{ env.PYTHON_VERSION }}
|
63 |
-
uses: actions/setup-python@v4
|
64 |
-
with:
|
65 |
-
python-version: ${{ env.PYTHON_VERSION }}
|
66 |
-
- name: Download raw wiktionary data
|
67 |
-
run: wget https://kaikki.org/dictionary/raw-wiktextract-data.jsonl
|
68 |
-
- name: Install dependencies
|
69 |
-
run: pip3 install -r requirements.txt
|
70 |
-
- name: Process raw-wiktextract-data.jsonl
|
71 |
-
run: |
|
72 |
-
python3 ./extract.py -i raw-wiktextract-data.jsonl
|
73 |
-
rm raw-wiktextract-data.jsonl
|
74 |
-
- name: Push to hub
|
75 |
-
if: github.ref == 'refs/heads/master'
|
76 |
-
run: |
|
77 |
-
git config --global user.name "QubitPi"
|
78 |
-
git config --global user.email "jack20220723@gmail.com"
|
79 |
-
|
80 |
-
git lfs install
|
81 |
-
git lfs track "*-wiktextract-data.jsonl"
|
82 |
-
git lfs track "word-definition-graph-data.jsonl"
|
83 |
-
|
84 |
-
git add *-wiktextract-data.jsonl
|
85 |
-
git add word-definition-graph-data.jsonl
|
86 |
-
|
87 |
-
git commit -m "Extract raw-wiktextract-data.jsonl into per-language wiktextract-data.jsonl and generate graph data"
|
88 |
-
git push https://QubitPi:$HF_TOKEN@huggingface.co/datasets/QubitPi/wiktionary-data master:main -f
|
89 |
-
env:
|
90 |
-
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.gitignore
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
.idea/
|
2 |
-
.DS_Store
|
3 |
-
.venv
|
4 |
-
raw-wiktextract-data.jsonl
|
5 |
-
load.log
|
6 |
-
data/
|
7 |
-
__pycache__
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LICENSE
DELETED
@@ -1,201 +0,0 @@
|
|
1 |
-
Apache License
|
2 |
-
Version 2.0, January 2004
|
3 |
-
http://www.apache.org/licenses/
|
4 |
-
|
5 |
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6 |
-
|
7 |
-
1. Definitions.
|
8 |
-
|
9 |
-
"License" shall mean the terms and conditions for use, reproduction,
|
10 |
-
and distribution as defined by Sections 1 through 9 of this document.
|
11 |
-
|
12 |
-
"Licensor" shall mean the copyright owner or entity authorized by
|
13 |
-
the copyright owner that is granting the License.
|
14 |
-
|
15 |
-
"Legal Entity" shall mean the union of the acting entity and all
|
16 |
-
other entities that control, are controlled by, or are under common
|
17 |
-
control with that entity. For the purposes of this definition,
|
18 |
-
"control" means (i) the power, direct or indirect, to cause the
|
19 |
-
direction or management of such entity, whether by contract or
|
20 |
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21 |
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
22 |
-
|
23 |
-
"You" (or "Your") shall mean an individual or Legal Entity
|
24 |
-
exercising permissions granted by this License.
|
25 |
-
|
26 |
-
"Source" form shall mean the preferred form for making modifications,
|
27 |
-
including but not limited to software source code, documentation
|
28 |
-
source, and configuration files.
|
29 |
-
|
30 |
-
"Object" form shall mean any form resulting from mechanical
|
31 |
-
transformation or translation of a Source form, including but
|
32 |
-
not limited to compiled object code, generated documentation,
|
33 |
-
and conversions to other media types.
|
34 |
-
|
35 |
-
"Work" shall mean the work of authorship, whether in Source or
|
36 |
-
Object form, made available under the License, as indicated by a
|
37 |
-
copyright notice that is included in or attached to the work
|
38 |
-
(an example is provided in the Appendix below).
|
39 |
-
|
40 |
-
"Derivative Works" shall mean any work, whether in Source or Object
|
41 |
-
form, that is based on (or derived from) the Work and for which the
|
42 |
-
editorial revisions, annotations, elaborations, or other modifications
|
43 |
-
represent, as a whole, an original work of authorship. For the purposes
|
44 |
-
of this License, Derivative Works shall not include works that remain
|
45 |
-
separable from, or merely link (or bind by name) to the interfaces of,
|
46 |
-
the Work and Derivative Works thereof.
|
47 |
-
|
48 |
-
"Contribution" shall mean any work of authorship, including
|
49 |
-
the original version of the Work and any modifications or additions
|
50 |
-
to that Work or Derivative Works thereof, that is intentionally
|
51 |
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
52 |
-
or by an individual or Legal Entity authorized to submit on behalf of
|
53 |
-
the copyright owner. For the purposes of this definition, "submitted"
|
54 |
-
means any form of electronic, verbal, or written communication sent
|
55 |
-
to the Licensor or its representatives, including but not limited to
|
56 |
-
communication on electronic mailing lists, source code control systems,
|
57 |
-
and issue tracking systems that are managed by, or on behalf of, the
|
58 |
-
Licensor for the purpose of discussing and improving the Work, but
|
59 |
-
excluding communication that is conspicuously marked or otherwise
|
60 |
-
designated in writing by the copyright owner as "Not a Contribution."
|
61 |
-
|
62 |
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63 |
-
on behalf of whom a Contribution has been received by Licensor and
|
64 |
-
subsequently incorporated within the Work.
|
65 |
-
|
66 |
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
67 |
-
this License, each Contributor hereby grants to You a perpetual,
|
68 |
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69 |
-
copyright license to reproduce, prepare Derivative Works of,
|
70 |
-
publicly display, publicly perform, sublicense, and distribute the
|
71 |
-
Work and such Derivative Works in Source or Object form.
|
72 |
-
|
73 |
-
3. Grant of Patent License. Subject to the terms and conditions of
|
74 |
-
this License, each Contributor hereby grants to You a perpetual,
|
75 |
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76 |
-
(except as stated in this section) patent license to make, have made,
|
77 |
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78 |
-
where such license applies only to those patent claims licensable
|
79 |
-
by such Contributor that are necessarily infringed by their
|
80 |
-
Contribution(s) alone or by combination of their Contribution(s)
|
81 |
-
with the Work to which such Contribution(s) was submitted. If You
|
82 |
-
institute patent litigation against any entity (including a
|
83 |
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84 |
-
or a Contribution incorporated within the Work constitutes direct
|
85 |
-
or contributory patent infringement, then any patent licenses
|
86 |
-
granted to You under this License for that Work shall terminate
|
87 |
-
as of the date such litigation is filed.
|
88 |
-
|
89 |
-
4. Redistribution. You may reproduce and distribute copies of the
|
90 |
-
Work or Derivative Works thereof in any medium, with or without
|
91 |
-
modifications, and in Source or Object form, provided that You
|
92 |
-
meet the following conditions:
|
93 |
-
|
94 |
-
(a) You must give any other recipients of the Work or
|
95 |
-
Derivative Works a copy of this License; and
|
96 |
-
|
97 |
-
(b) You must cause any modified files to carry prominent notices
|
98 |
-
stating that You changed the files; and
|
99 |
-
|
100 |
-
(c) You must retain, in the Source form of any Derivative Works
|
101 |
-
that You distribute, all copyright, patent, trademark, and
|
102 |
-
attribution notices from the Source form of the Work,
|
103 |
-
excluding those notices that do not pertain to any part of
|
104 |
-
the Derivative Works; and
|
105 |
-
|
106 |
-
(d) If the Work includes a "NOTICE" text file as part of its
|
107 |
-
distribution, then any Derivative Works that You distribute must
|
108 |
-
include a readable copy of the attribution notices contained
|
109 |
-
within such NOTICE file, excluding those notices that do not
|
110 |
-
pertain to any part of the Derivative Works, in at least one
|
111 |
-
of the following places: within a NOTICE text file distributed
|
112 |
-
as part of the Derivative Works; within the Source form or
|
113 |
-
documentation, if provided along with the Derivative Works; or,
|
114 |
-
within a display generated by the Derivative Works, if and
|
115 |
-
wherever such third-party notices normally appear. The contents
|
116 |
-
of the NOTICE file are for informational purposes only and
|
117 |
-
do not modify the License. You may add Your own attribution
|
118 |
-
notices within Derivative Works that You distribute, alongside
|
119 |
-
or as an addendum to the NOTICE text from the Work, provided
|
120 |
-
that such additional attribution notices cannot be construed
|
121 |
-
as modifying the License.
|
122 |
-
|
123 |
-
You may add Your own copyright statement to Your modifications and
|
124 |
-
may provide additional or different license terms and conditions
|
125 |
-
for use, reproduction, or distribution of Your modifications, or
|
126 |
-
for any such Derivative Works as a whole, provided Your use,
|
127 |
-
reproduction, and distribution of the Work otherwise complies with
|
128 |
-
the conditions stated in this License.
|
129 |
-
|
130 |
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131 |
-
any Contribution intentionally submitted for inclusion in the Work
|
132 |
-
by You to the Licensor shall be under the terms and conditions of
|
133 |
-
this License, without any additional terms or conditions.
|
134 |
-
Notwithstanding the above, nothing herein shall supersede or modify
|
135 |
-
the terms of any separate license agreement you may have executed
|
136 |
-
with Licensor regarding such Contributions.
|
137 |
-
|
138 |
-
6. Trademarks. This License does not grant permission to use the trade
|
139 |
-
names, trademarks, service marks, or product names of the Licensor,
|
140 |
-
except as required for reasonable and customary use in describing the
|
141 |
-
origin of the Work and reproducing the content of the NOTICE file.
|
142 |
-
|
143 |
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
144 |
-
agreed to in writing, Licensor provides the Work (and each
|
145 |
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146 |
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147 |
-
implied, including, without limitation, any warranties or conditions
|
148 |
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149 |
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150 |
-
appropriateness of using or redistributing the Work and assume any
|
151 |
-
risks associated with Your exercise of permissions under this License.
|
152 |
-
|
153 |
-
8. Limitation of Liability. In no event and under no legal theory,
|
154 |
-
whether in tort (including negligence), contract, or otherwise,
|
155 |
-
unless required by applicable law (such as deliberate and grossly
|
156 |
-
negligent acts) or agreed to in writing, shall any Contributor be
|
157 |
-
liable to You for damages, including any direct, indirect, special,
|
158 |
-
incidental, or consequential damages of any character arising as a
|
159 |
-
result of this License or out of the use or inability to use the
|
160 |
-
Work (including but not limited to damages for loss of goodwill,
|
161 |
-
work stoppage, computer failure or malfunction, or any and all
|
162 |
-
other commercial damages or losses), even if such Contributor
|
163 |
-
has been advised of the possibility of such damages.
|
164 |
-
|
165 |
-
9. Accepting Warranty or Additional Liability. While redistributing
|
166 |
-
the Work or Derivative Works thereof, You may choose to offer,
|
167 |
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
168 |
-
or other liability obligations and/or rights consistent with this
|
169 |
-
License. However, in accepting such obligations, You may act only
|
170 |
-
on Your own behalf and on Your sole responsibility, not on behalf
|
171 |
-
of any other Contributor, and only if You agree to indemnify,
|
172 |
-
defend, and hold each Contributor harmless for any liability
|
173 |
-
incurred by, or claims asserted against, such Contributor by reason
|
174 |
-
of your accepting any such warranty or additional liability.
|
175 |
-
|
176 |
-
END OF TERMS AND CONDITIONS
|
177 |
-
|
178 |
-
APPENDIX: How to apply the Apache License to your work.
|
179 |
-
|
180 |
-
To apply the Apache License to your work, attach the following
|
181 |
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
182 |
-
replaced with your own identifying information. (Don't include
|
183 |
-
the brackets!) The text should be enclosed in the appropriate
|
184 |
-
comment syntax for the file format. We also recommend that a
|
185 |
-
file or class name and description of purpose be included on the
|
186 |
-
same "printed page" as the copyright notice for easier
|
187 |
-
identification within third-party archives.
|
188 |
-
|
189 |
-
Copyright 2024 Jiaqi Liu
|
190 |
-
|
191 |
-
Licensed under the Apache License, Version 2.0 (the "License");
|
192 |
-
you may not use this file except in compliance with the License.
|
193 |
-
You may obtain a copy of the License at
|
194 |
-
|
195 |
-
http://www.apache.org/licenses/LICENSE-2.0
|
196 |
-
|
197 |
-
Unless required by applicable law or agreed to in writing, software
|
198 |
-
distributed under the License is distributed on an "AS IS" BASIS,
|
199 |
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200 |
-
See the License for the specific language governing permissions and
|
201 |
-
limitations under the License.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Languages/Akkadian/0000.parquet
ADDED
Binary file (64.4 kB). View file
|
|
Languages/AncientGreek/0000.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:773764402935de320a540cbf433cafdf2da30588edc9121f37fcd056d7333cff
|
3 |
+
size 2377245
|
Languages/German/0000.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0a9ccc97ec9c67ebfd73d23a6e9f97be6b34622f2589f8d98c1c71fa59a10394
|
3 |
+
size 42839005
|
Languages/Korean/0000.parquet
ADDED
Binary file (13.6 kB). View file
|
|
Languages/Latin/0000.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fc8c66035183378e29a70b80b4589a7000a99399f576356f0b858aa2b7f35421
|
3 |
+
size 29455763
|
Languages/OldPersian/0000.parquet
ADDED
Binary file (39 kB). View file
|
|
README.md
DELETED
@@ -1,100 +0,0 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
pretty_name: English Wiktionary Data in JSONL
|
4 |
-
language:
|
5 |
-
- en
|
6 |
-
- de
|
7 |
-
- grc
|
8 |
-
- la
|
9 |
-
configs:
|
10 |
-
- config_name: Languages
|
11 |
-
data_files:
|
12 |
-
- split: German
|
13 |
-
path: german-wiktextract-data.jsonl
|
14 |
-
- split: Latin
|
15 |
-
path: latin-wiktextract-data.jsonl
|
16 |
-
- split: AncientGreek
|
17 |
-
path: ancient-greek-wiktextract-data.jsonl
|
18 |
-
- split: GraphData
|
19 |
-
path: word-definition-graph-data.jsonl
|
20 |
-
tags:
|
21 |
-
- Wiktionary
|
22 |
-
- German
|
23 |
-
- Ancient Greek
|
24 |
-
- Latin
|
25 |
-
- Vocabulary
|
26 |
-
size_categories:
|
27 |
-
- 1M<n<10M
|
28 |
-
---
|
29 |
-
|
30 |
-
Wiktionary Data on Hugging Face Datasets
|
31 |
-
========================================
|
32 |
-
|
33 |
-
![Python Version Badge]
|
34 |
-
[![GitHub workflow status badge][GitHub workflow status badge]][GitHub workflow status URL]
|
35 |
-
[![Hugging Face sync status badge]][Hugging Face sync status URL]
|
36 |
-
[![Hugging Face dataset badge]][Hugging Face dataset URL]
|
37 |
-
[![Apache License Badge]][Apache License, Version 2.0]
|
38 |
-
|
39 |
-
[wiktionary-data]() is a sub-data extraction of the [English Wiktionary](https://en.wiktionary.org) that currently
|
40 |
-
supports the following languages:
|
41 |
-
|
42 |
-
- German
|
43 |
-
- Latin
|
44 |
-
- Ancient Greek
|
45 |
-
- Old Persian
|
46 |
-
|
47 |
-
[wiktionary-data]() was originally a sub-module of [wilhelm-graphdb](https://github.com/QubitPi/wilhelm-graphdb). While
|
48 |
-
the dataset it's getting bigger, I noticed a wave of more exciting potentials this dataset can bring about that
|
49 |
-
stretches beyond the scope of the containing project. Therefore I decided to promote it to a dedicated module; and here
|
50 |
-
comes this repo.
|
51 |
-
|
52 |
-
The Wiktionary language data is available on 🤗 [Hugging Face Datasets][Hugging Face dataset URL].
|
53 |
-
|
54 |
-
```python
|
55 |
-
from datasets import load_dataset
|
56 |
-
dataset = load_dataset("QubitPi/wiktionary-data", split="German")
|
57 |
-
```
|
58 |
-
|
59 |
-
The available splits are
|
60 |
-
|
61 |
-
- `German`
|
62 |
-
- `Latin`
|
63 |
-
- `AncientGreek`
|
64 |
-
- `OldPersian`
|
65 |
-
|
66 |
-
In addition, a separate split for graph data is offered:
|
67 |
-
|
68 |
-
- `GraphData`
|
69 |
-
|
70 |
-
This split contains all the languages and puts everything in a giant graph
|
71 |
-
|
72 |
-
Development
|
73 |
-
-----------
|
74 |
-
|
75 |
-
Although [the original Wiktionary dump](https://dumps.wikimedia.org/) is available, parsing it from scratch involves
|
76 |
-
rather complicated process. We would probably do it in the future. At present, however, we would simply take the awesome
|
77 |
-
works by [tatuylonen](https://github.com/tatuylonen/wiktextract) which has already processed it and presented it in
|
78 |
-
[in JSON format](https://kaikki.org/dictionary/rawdata.html). wiktionary-data takes the
|
79 |
-
__raw Wiktextract data (JSONL, one object per line)__ option.
|
80 |
-
|
81 |
-
License
|
82 |
-
-------
|
83 |
-
|
84 |
-
The use and distribution terms for [wiktionary-data]() are covered by the [Apache License, Version 2.0].
|
85 |
-
|
86 |
-
[Apache License Badge]: https://img.shields.io/badge/Apache%202.0-F25910.svg?style=for-the-badge&logo=Apache&logoColor=white
|
87 |
-
[Apache License, Version 2.0]: https://www.apache.org/licenses/LICENSE-2.0
|
88 |
-
|
89 |
-
[Docker login command]: https://docker.qubitpi.org//reference/cli/docker/login/#options
|
90 |
-
|
91 |
-
[GitHub workflow status badge]: https://img.shields.io/github/actions/workflow/status/QubitPi/wiktionary-data/ci-cd.yaml?branch=master&style=for-the-badge&logo=github&logoColor=white&label=CI/CD
|
92 |
-
[GitHub workflow status URL]: https://github.com/QubitPi/wiktionary-data/actions/workflows/ci-cd.yaml
|
93 |
-
|
94 |
-
[Hugging Face dataset badge]: https://img.shields.io/badge/Hugging%20Face%20Dataset-wilhelm--graphdb-FFD21E?style=for-the-badge&logo=huggingface&logoColor=white
|
95 |
-
[Hugging Face dataset URL]: https://huggingface.co/datasets/QubitPi/wiktionary-data
|
96 |
-
|
97 |
-
[Hugging Face sync status badge]: https://img.shields.io/github/actions/workflow/status/QubitPi/wiktionary-data/ci-cd.yaml?branch=master&style=for-the-badge&logo=github&logoColor=white&label=Hugging%20Face%20Sync%20Up
|
98 |
-
[Hugging Face sync status URL]: https://github.com/QubitPi/wiktionary-data/actions/workflows/ci-cd.yaml
|
99 |
-
|
100 |
-
[Python Version Badge]: https://img.shields.io/badge/Python-3.10-FFD845?labelColor=498ABC&style=for-the-badge&logo=python&logoColor=white
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extract.py
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
# Copyright Jiaqi Liu
|
2 |
-
#
|
3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
-
# you may not use this file except in compliance with the License.
|
5 |
-
# You may obtain a copy of the License at
|
6 |
-
#
|
7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
-
#
|
9 |
-
# Unless required by applicable law or agreed to in writing, software
|
10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
-
# See the License for the specific language governing permissions and
|
13 |
-
# limitations under the License.
|
14 |
-
from wiktionary.wiktextract.extract import extract_data
|
15 |
-
from wiktionary.wiktextract.extract import extract_graph
|
16 |
-
|
17 |
-
|
18 |
-
if __name__ == "__main__":
|
19 |
-
import argparse
|
20 |
-
|
21 |
-
parser = argparse.ArgumentParser(description='Post-process Wiktextract data')
|
22 |
-
parser.add_argument('-i', '--input', help='Raw data file, i.e. the path to raw-wiktextract-data.jsonl', required=True)
|
23 |
-
args = vars(parser.parse_args())
|
24 |
-
|
25 |
-
extract_data(args["input"])
|
26 |
-
extract_graph(args["input"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
wilhelm_python_sdk
|
|
|
|
tests/__init__.py
DELETED
File without changes
|
tests/wiktionary/__init__.py
DELETED
File without changes
|
tests/wiktionary/wiktextract/__init__.py
DELETED
File without changes
|
tests/wiktionary/wiktextract/test_german.py
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
# Copyright Jiaqi Liu
|
2 |
-
#
|
3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
-
# you may not use this file except in compliance with the License.
|
5 |
-
# You may obtain a copy of the License at
|
6 |
-
#
|
7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
-
#
|
9 |
-
# Unless required by applicable law or agreed to in writing, software
|
10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
-
# See the License for the specific language governing permissions and
|
13 |
-
# limitations under the License.
|
14 |
-
|
15 |
-
import unittest
|
16 |
-
|
17 |
-
from wiktionary.wiktextract.parse import get_definitions
|
18 |
-
|
19 |
-
|
20 |
-
class TestGermanParse(unittest.TestCase):
|
21 |
-
|
22 |
-
def test_get_definitions(self):
|
23 |
-
self.assertEqual(
|
24 |
-
[],
|
25 |
-
get_definitions({"senses": []}),
|
26 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/wiktionary/wiktextract/test_parse.py
DELETED
@@ -1,78 +0,0 @@
|
|
1 |
-
# Copyright Jiaqi Liu
|
2 |
-
#
|
3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
-
# you may not use this file except in compliance with the License.
|
5 |
-
# You may obtain a copy of the License at
|
6 |
-
#
|
7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
-
#
|
9 |
-
# Unless required by applicable law or agreed to in writing, software
|
10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
-
# See the License for the specific language governing permissions and
|
13 |
-
# limitations under the License.
|
14 |
-
|
15 |
-
import unittest
|
16 |
-
|
17 |
-
from wiktionary.wiktextract.parse import get_audios
|
18 |
-
from wiktionary.wiktextract.parse import get_definitions
|
19 |
-
|
20 |
-
|
21 |
-
class TestParse(unittest.TestCase):
|
22 |
-
|
23 |
-
def test_get_definitions(self):
|
24 |
-
self.assertEqual(
|
25 |
-
[],
|
26 |
-
get_definitions({"senses": []}),
|
27 |
-
)
|
28 |
-
|
29 |
-
def test_get_definitions_empty(self):
|
30 |
-
self.assertEqual(
|
31 |
-
["Volapük"],
|
32 |
-
get_definitions({
|
33 |
-
"senses": [
|
34 |
-
{
|
35 |
-
"glosses": [
|
36 |
-
"Volapük"
|
37 |
-
]
|
38 |
-
}
|
39 |
-
]
|
40 |
-
}),
|
41 |
-
)
|
42 |
-
|
43 |
-
self.assertEqual(
|
44 |
-
["Volapük"],
|
45 |
-
get_definitions({
|
46 |
-
"senses": [
|
47 |
-
{
|
48 |
-
"raw_glosses": [
|
49 |
-
"Volapük"
|
50 |
-
]
|
51 |
-
}
|
52 |
-
]
|
53 |
-
}),
|
54 |
-
)
|
55 |
-
|
56 |
-
|
57 |
-
def test_get_audios(self):
|
58 |
-
self.assertEqual(
|
59 |
-
[{
|
60 |
-
"ogg_url": "https://upload.wikimedia.org/wikipedia/commons/a/a8/De-Volap%C3%BCk.ogg",
|
61 |
-
"mp3_url": "https://upload.wikimedia.org/wikipedia/commons/transcoded/a/a8/De-Volap%C3%BCk.ogg/De-Volap%C3%BCk.ogg.mp3"
|
62 |
-
}],
|
63 |
-
get_audios({
|
64 |
-
"sounds": [
|
65 |
-
{
|
66 |
-
"ipa": "/ˌvoːlaˈpyːk/"
|
67 |
-
},
|
68 |
-
{
|
69 |
-
"ipa": "/ˌvɔla-/"
|
70 |
-
},
|
71 |
-
{
|
72 |
-
"audio": "De-Volapük.ogg",
|
73 |
-
"ogg_url": "https://upload.wikimedia.org/wikipedia/commons/a/a8/De-Volap%C3%BCk.ogg",
|
74 |
-
"mp3_url": "https://upload.wikimedia.org/wikipedia/commons/transcoded/a/a8/De-Volap%C3%BCk.ogg/De-Volap%C3%BCk.ogg.mp3"
|
75 |
-
}
|
76 |
-
]
|
77 |
-
})
|
78 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wiktionary/__init__.py
DELETED
File without changes
|
wiktionary/wiktextract/__init__.py
DELETED
File without changes
|
wiktionary/wiktextract/extract.py
DELETED
@@ -1,90 +0,0 @@
|
|
1 |
-
# Copyright Jiaqi Liu
|
2 |
-
#
|
3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
-
# you may not use this file except in compliance with the License.
|
5 |
-
# You may obtain a copy of the License at
|
6 |
-
#
|
7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
-
#
|
9 |
-
# Unless required by applicable law or agreed to in writing, software
|
10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
-
# See the License for the specific language governing permissions and
|
13 |
-
# limitations under the License.
|
14 |
-
|
15 |
-
from wiktionary.wiktextract.german import get_gender_modifier
|
16 |
-
from wiktionary.wiktextract.german import get_german_inflection
|
17 |
-
|
18 |
-
|
19 |
-
def extract_data(wiktextract_data_path: str):
|
20 |
-
"""
|
21 |
-
Extract data from raw-wiktextract-data.jsonl useful for wilhelmlang.com.
|
22 |
-
|
23 |
-
There will be 3 languages extracted, each of which in a dedicated .jsonl file:
|
24 |
-
|
25 |
-
1. German
|
26 |
-
2. Latin
|
27 |
-
3. Ancient Greek
|
28 |
-
|
29 |
-
Each line of the JSONL file has the following fields:
|
30 |
-
|
31 |
-
- term: the word of the language
|
32 |
-
- pos: the Part of Speech of this word
|
33 |
-
- definitions: an array of definitions, each element of the array is a string
|
34 |
-
|
35 |
-
:param wiktextract_data_path: the path of the wiktextract jsonl file. Can be downloaded from https://kaikki.org/dictionary/rawdata.html
|
36 |
-
"""
|
37 |
-
import json
|
38 |
-
from wiktionary.wiktextract.parse import get_audios
|
39 |
-
from wiktionary.wiktextract.parse import get_definitions
|
40 |
-
|
41 |
-
with (open(wiktextract_data_path) as data,
|
42 |
-
open("german-wiktextract-data.jsonl", "w") as german,
|
43 |
-
open("latin-wiktextract-data.jsonl", "w") as latin,
|
44 |
-
open("ancient-greek-wiktextract-data.jsonl", "w") as ancient_greek
|
45 |
-
):
|
46 |
-
for line in data:
|
47 |
-
vocabulary = json.loads(line)
|
48 |
-
if "lang" in vocabulary:
|
49 |
-
term = vocabulary["word"]
|
50 |
-
pos = vocabulary["pos"] if "pos" in vocabulary else "Unknown"
|
51 |
-
definitions = get_definitions(vocabulary)
|
52 |
-
audios = get_audios(vocabulary)
|
53 |
-
|
54 |
-
if vocabulary["lang"] == "German":
|
55 |
-
term = get_gender_modifier(vocabulary) + term
|
56 |
-
german.write(
|
57 |
-
json.dumps({
|
58 |
-
"term": term,
|
59 |
-
"part of speech": pos,
|
60 |
-
"definitions": definitions,
|
61 |
-
"audios": audios,
|
62 |
-
"inflection": get_german_inflection(vocabulary)
|
63 |
-
})
|
64 |
-
)
|
65 |
-
german.write("\n")
|
66 |
-
if vocabulary["lang"] == "Latin":
|
67 |
-
latin.write(json.dumps({"term": term, "part of speech": pos, "definitions": definitions, "audios": audios}))
|
68 |
-
latin.write("\n")
|
69 |
-
if vocabulary["lang"] == "Ancient Greek":
|
70 |
-
ancient_greek.write(json.dumps({"term": term, "part of speech": pos, "definitions": definitions, "audios": audios}))
|
71 |
-
ancient_greek.write("\n")
|
72 |
-
|
73 |
-
def extract_graph(wiktextract_data_path: str):
|
74 |
-
import json
|
75 |
-
from wiktionary.wiktextract.parse import get_definitions
|
76 |
-
|
77 |
-
with (open(wiktextract_data_path) as data, open("word-definition-graph-data.jsonl", "w") as graph):
|
78 |
-
for line in data:
|
79 |
-
vocabulary = json.loads(line)
|
80 |
-
if "lang" in vocabulary:
|
81 |
-
term = vocabulary["word"]
|
82 |
-
if vocabulary["lang"] == "German":
|
83 |
-
term = get_gender_modifier(vocabulary) + term
|
84 |
-
|
85 |
-
source_node = {"term": term, "language": vocabulary["lang"]}
|
86 |
-
|
87 |
-
definitions = get_definitions(vocabulary)
|
88 |
-
for definition in definitions:
|
89 |
-
graph.write(json.dumps({"source": source_node, "target": definition, "label": "definition"}))
|
90 |
-
graph.write("\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wiktionary/wiktextract/german.py
DELETED
@@ -1,127 +0,0 @@
|
|
1 |
-
# Copyright Jiaqi Liu
|
2 |
-
#
|
3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
-
# you may not use this file except in compliance with the License.
|
5 |
-
# You may obtain a copy of the License at
|
6 |
-
#
|
7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
-
#
|
9 |
-
# Unless required by applicable law or agreed to in writing, software
|
10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
-
# See the License for the specific language governing permissions and
|
13 |
-
# limitations under the License.
|
14 |
-
|
15 |
-
from wiktionary.wiktextract.parse import get_part_of_speech
|
16 |
-
|
17 |
-
GERMAN_CASES = ["nominative", "genitive", "dative", "accusative"]
|
18 |
-
|
19 |
-
def get_gender_modifier(vocabulary) -> str:
|
20 |
-
if get_part_of_speech(vocabulary) == "noun" and "categories" in vocabulary:
|
21 |
-
if "German masculine nouns" in vocabulary["categories"]:
|
22 |
-
return "der "
|
23 |
-
if "German feminine nouns" in vocabulary["categories"]:
|
24 |
-
return "die "
|
25 |
-
if "German neuter nouns" in vocabulary["categories"]:
|
26 |
-
return "das "
|
27 |
-
return ""
|
28 |
-
|
29 |
-
|
30 |
-
def get_german_inflection(vocabulary) -> dict:
|
31 |
-
inflections = {"declension": None, "conjugation": None}
|
32 |
-
if get_part_of_speech(vocabulary) == "noun":
|
33 |
-
inflections["declension"] = get_german_noun_declensions(vocabulary)
|
34 |
-
if get_part_of_speech(vocabulary) == "adj":
|
35 |
-
inflections["declension"] = get_german_adj_declensions(vocabulary)
|
36 |
-
return inflections
|
37 |
-
|
38 |
-
|
39 |
-
def get_german_adj_declensions(vocabulary) -> dict:
|
40 |
-
"""
|
41 |
-
There will be 3 x 3 list of maps for an adj. declensions with the first 3 corresponding to
|
42 |
-
`adj. degree <https://en.wikipedia.org/wiki/Adjective#Comparison_(degrees)>`_:
|
43 |
-
|
44 |
-
1. 3 for regular (positive) form
|
45 |
-
2. 3 for comparative form
|
46 |
-
3. 3 for mixed form
|
47 |
-
|
48 |
-
and the second 3 corresponding to the declension type of
|
49 |
-
|
50 |
-
1. strong declension
|
51 |
-
2. weak declension
|
52 |
-
3. mixed declension
|
53 |
-
|
54 |
-
Each list contains 4 maps. Each of the 4 maps is two-key indexed with the 1st index being the number & gender:
|
55 |
-
|
56 |
-
- "masculine"
|
57 |
-
- "feminine"
|
58 |
-
- "neuter"
|
59 |
-
- "plural
|
60 |
-
|
61 |
-
and the 2nd index being the case:
|
62 |
-
|
63 |
-
- "nominative"
|
64 |
-
- "genitive"
|
65 |
-
- "dative"
|
66 |
-
- "accusative"
|
67 |
-
|
68 |
-
An example data source can be found at https://en.wiktionary.org/wiki/mobil#Declension_2
|
69 |
-
|
70 |
-
:param vocabulary: a wiktextract JSONL line corresponding to an adjective (pos = "adj")
|
71 |
-
|
72 |
-
:return: a map with 3 entries, each for corresponds to a adj. degree with 3 corresponding sub-maps, totaling the 9
|
73 |
-
maps mentioned above. If the `vocabulary` does not have a `forms` field, where all declension info reside, this
|
74 |
-
function returns an empty map
|
75 |
-
"""
|
76 |
-
if "forms" not in vocabulary:
|
77 |
-
return {}
|
78 |
-
|
79 |
-
forms = [form for form in vocabulary["forms"] if "source" in form and form["source"] == "declension"]
|
80 |
-
|
81 |
-
numbergenders = ["masculine", "feminine", "neuter", "plural"]
|
82 |
-
|
83 |
-
conjugations = {
|
84 |
-
"positive": {"strong": [], "weak": [], "mixed": []},
|
85 |
-
"comparative": {"strong": [], "weak": [], "mixed": []},
|
86 |
-
"superlative": {"strong": [], "weak": [], "mixed": []},
|
87 |
-
}
|
88 |
-
|
89 |
-
for degree in conjugations.keys():
|
90 |
-
for declension_type in ["strong", "weak", "mixed"]:
|
91 |
-
for numbergender in numbergenders:
|
92 |
-
dec_by_case = {}
|
93 |
-
for case in GERMAN_CASES:
|
94 |
-
for declension in forms:
|
95 |
-
tags = declension["tags"]
|
96 |
-
if (degree in tags or degree == "positive") and declension_type in tags:
|
97 |
-
if numbergender in tags and case in tags:
|
98 |
-
if declension["form"]:
|
99 |
-
dec_by_case[case] = declension["form"]
|
100 |
-
if len(dec_by_case) > 0:
|
101 |
-
conjugations[degree][declension_type].append(dec_by_case)
|
102 |
-
|
103 |
-
return conjugations
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
def get_german_noun_declensions(vocabulary):
|
108 |
-
if "forms" not in vocabulary:
|
109 |
-
return {}
|
110 |
-
|
111 |
-
forms = [form for form in vocabulary["forms"] if "source" in form and form["source"] == "declension"]
|
112 |
-
|
113 |
-
numbers = ["singular", "plural"]
|
114 |
-
|
115 |
-
declensions = {}
|
116 |
-
for number in numbers:
|
117 |
-
dec_by_case = {}
|
118 |
-
for case in GERMAN_CASES:
|
119 |
-
for declension in forms:
|
120 |
-
tags = declension["tags"]
|
121 |
-
if number in tags and case in tags:
|
122 |
-
if declension["form"]:
|
123 |
-
dec_by_case[case] = declension["form"]
|
124 |
-
if len(dec_by_case) > 0:
|
125 |
-
declensions[number] = dec_by_case
|
126 |
-
|
127 |
-
return declensions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wiktionary/wiktextract/parse.py
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
# Copyright Jiaqi Liu
|
2 |
-
#
|
3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
-
# you may not use this file except in compliance with the License.
|
5 |
-
# You may obtain a copy of the License at
|
6 |
-
#
|
7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
-
#
|
9 |
-
# Unless required by applicable law or agreed to in writing, software
|
10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
-
# See the License for the specific language governing permissions and
|
13 |
-
# limitations under the License.
|
14 |
-
|
15 |
-
def get_part_of_speech(vocabulary) -> str:
|
16 |
-
return vocabulary["pos"] if "pos" in vocabulary else "Unknown"
|
17 |
-
|
18 |
-
def get_definitions(vocabulary) -> list:
|
19 |
-
return [sense["glosses"][0] if "glosses" in sense else sense["raw_glosses"][0] for sense in vocabulary["senses"] if "glosses" in sense or "raw_glosses" in sense]
|
20 |
-
|
21 |
-
|
22 |
-
def get_audios(vocabulary) -> list:
|
23 |
-
audios = []
|
24 |
-
if "sounds" in vocabulary:
|
25 |
-
for sound in vocabulary["sounds"]:
|
26 |
-
audio = {}
|
27 |
-
if "ogg_url" in sound and sound["ogg_url"] is not None:
|
28 |
-
audio["ogg_url"] = sound["ogg_url"]
|
29 |
-
if "mp3_url" in sound and sound["mp3_url"] is not None:
|
30 |
-
audio["mp3_url"] = sound["mp3_url"]
|
31 |
-
if len(audio) > 0:
|
32 |
-
audios.append(audio)
|
33 |
-
return audios
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|