audio field cannot be empty (#111)
Browse files- german.yaml +39 -3
- huggingface/vocabulary_parser.py +6 -0
- tests/test_vocabulary_parser.py +22 -0
german.yaml
CHANGED
@@ -578,7 +578,8 @@ vocabulary:
|
|
578 |
- term: nicht gut
|
579 |
definition: not good
|
580 |
- term: schlecht
|
581 |
-
definition: bad
|
|
|
582 |
- term: scheußlich
|
583 |
definition: terrible
|
584 |
- term: Wie geht es Ihnen?
|
@@ -1936,6 +1937,9 @@ vocabulary:
|
|
1936 |
- [genitive, Autos, Autos ]
|
1937 |
- [dative, Auto, Autos ]
|
1938 |
- [accusative, Auto, Autos ]
|
|
|
|
|
|
|
1939 |
- term: der Automechaniker
|
1940 |
definition: (make) car mechanic
|
1941 |
declension:
|
@@ -4286,6 +4290,16 @@ vocabulary:
|
|
4286 |
- term: fast
|
4287 |
definition: (adv.) almost
|
4288 |
audio: https://upload.wikimedia.org/wikipedia/commons/2/26/De-fast2.ogg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4289 |
|
4290 |
|
4291 |
|
@@ -5705,6 +5719,13 @@ vocabulary:
|
|
5705 |
- term: exekutieren
|
5706 |
definition: to execute (kill)
|
5707 |
audio: https://upload.wikimedia.org/wikipedia/commons/f/f1/De-exekutieren.ogg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5708 |
- term: die Weltanschauung
|
5709 |
definition:
|
5710 |
- the worldview
|
@@ -6015,7 +6036,7 @@ vocabulary:
|
|
6015 |
- to carry out
|
6016 |
- to execute
|
6017 |
- to put into action
|
6018 |
-
audio:
|
6019 |
verbformen:
|
6020 |
video: https://youtu.be/GTaswCjpdXA
|
6021 |
conjugation: https://www.verbformen.com/conjugation/durchfu3hren.pdf
|
@@ -6054,6 +6075,20 @@ vocabulary:
|
|
6054 |
verbformen:
|
6055 |
conjugation: https://www.verbformen.com/conjugation/jagen_hat.pdf
|
6056 |
flashcards: https://www.verbformen.com/conjugation/worksheets-exercises/lernkarten/jagen_hat.pdf
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6057 |
|
6058 |
|
6059 |
|
@@ -6185,12 +6220,13 @@ vocabulary:
|
|
6185 |
- doctrine
|
6186 |
- term: erste
|
6187 |
definition: (adj.) first
|
|
|
6188 |
- term: erst
|
6189 |
definition:
|
6190 |
- (adv.) first
|
6191 |
- (adv.) only
|
6192 |
- (adv.) not until
|
6193 |
-
audio:
|
6194 |
- term: die Faust
|
6195 |
definition: the first
|
6196 |
declension:
|
|
|
578 |
- term: nicht gut
|
579 |
definition: not good
|
580 |
- term: schlecht
|
581 |
+
definition: (adj.) bad
|
582 |
+
audio: https://upload.wikimedia.org/wikipedia/commons/9/90/De-schlecht2.ogg
|
583 |
- term: scheußlich
|
584 |
definition: terrible
|
585 |
- term: Wie geht es Ihnen?
|
|
|
1937 |
- [genitive, Autos, Autos ]
|
1938 |
- [dative, Auto, Autos ]
|
1939 |
- [accusative, Auto, Autos ]
|
1940 |
+
- term: mechanisch
|
1941 |
+
definition: (adj.) mechanical
|
1942 |
+
audio: https://upload.wikimedia.org/wikipedia/commons/7/7d/De-mechanisch.ogg
|
1943 |
- term: der Automechaniker
|
1944 |
definition: (make) car mechanic
|
1945 |
declension:
|
|
|
4290 |
- term: fast
|
4291 |
definition: (adv.) almost
|
4292 |
audio: https://upload.wikimedia.org/wikipedia/commons/2/26/De-fast2.ogg
|
4293 |
+
- term: der Wecker
|
4294 |
+
definition: the alarm clock
|
4295 |
+
audio: https://upload.wikimedia.org/wikipedia/commons/4/4b/LL-Q188_%28deu%29-Sebastian_Wallroth-Wecker.wav
|
4296 |
+
declension-type: strong
|
4297 |
+
declension:
|
4298 |
+
- ["", singular, plural ]
|
4299 |
+
- [nominative, Wecker, Wecker ]
|
4300 |
+
- [genitive, Weckers, Wecker ]
|
4301 |
+
- [dative, Wecker, Weckern]
|
4302 |
+
- [accusative, Wecker, Wecker ]
|
4303 |
|
4304 |
|
4305 |
|
|
|
5719 |
- term: exekutieren
|
5720 |
definition: to execute (kill)
|
5721 |
audio: https://upload.wikimedia.org/wikipedia/commons/f/f1/De-exekutieren.ogg
|
5722 |
+
- term: töten
|
5723 |
+
definition: to kill
|
5724 |
+
audio: https://upload.wikimedia.org/wikipedia/commons/b/b0/De-t%C3%B6ten.ogg
|
5725 |
+
verbformen:
|
5726 |
+
video: https://youtu.be/oFQQkWcju04
|
5727 |
+
conjugation: https://www.verbformen.com/conjugation/to3ten.pdf
|
5728 |
+
flashcards: https://www.verbformen.com/conjugation/worksheets-exercises/lernkarten/to3ten.pdf
|
5729 |
- term: die Weltanschauung
|
5730 |
definition:
|
5731 |
- the worldview
|
|
|
6036 |
- to carry out
|
6037 |
- to execute
|
6038 |
- to put into action
|
6039 |
+
audio: https://upload.wikimedia.org/wikipedia/commons/a/ac/De-durchf%C3%BChren.ogg
|
6040 |
verbformen:
|
6041 |
video: https://youtu.be/GTaswCjpdXA
|
6042 |
conjugation: https://www.verbformen.com/conjugation/durchfu3hren.pdf
|
|
|
6075 |
verbformen:
|
6076 |
conjugation: https://www.verbformen.com/conjugation/jagen_hat.pdf
|
6077 |
flashcards: https://www.verbformen.com/conjugation/worksheets-exercises/lernkarten/jagen_hat.pdf
|
6078 |
+
- term: endlich
|
6079 |
+
definition:
|
6080 |
+
- (adv.) eventually
|
6081 |
+
- (adv.) finally
|
6082 |
+
- (adj.) finite
|
6083 |
+
- (adj.) limited
|
6084 |
+
audio: https://upload.wikimedia.org/wikipedia/commons/1/14/De-endlich.ogg
|
6085 |
+
- term: dürfen
|
6086 |
+
definition: to be allowed
|
6087 |
+
audio: https://upload.wikimedia.org/wikipedia/commons/1/17/De-d%C3%BCrfen.ogg
|
6088 |
+
verbformen:
|
6089 |
+
video: https://youtu.be/W3l8PzQlCIg
|
6090 |
+
conjugation: https://www.verbformen.com/conjugation/du3rfen.pdf
|
6091 |
+
flashcards: https://www.verbformen.com/conjugation/worksheets-exercises/lernkarten/du3rfen.pdf
|
6092 |
|
6093 |
|
6094 |
|
|
|
6220 |
- doctrine
|
6221 |
- term: erste
|
6222 |
definition: (adj.) first
|
6223 |
+
audio: https://upload.wikimedia.org/wikipedia/commons/7/72/De-erste.ogg
|
6224 |
- term: erst
|
6225 |
definition:
|
6226 |
- (adv.) first
|
6227 |
- (adv.) only
|
6228 |
- (adv.) not until
|
6229 |
+
audio: https://upload.wikimedia.org/wikipedia/commons/9/93/De-erst.ogg
|
6230 |
- term: die Faust
|
6231 |
definition: the first
|
6232 |
declension:
|
huggingface/vocabulary_parser.py
CHANGED
@@ -164,6 +164,12 @@ def get_audio(word: object) -> dict:
|
|
164 |
"""
|
165 |
if "audio" not in word:
|
166 |
return {}
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
return {"audio": word["audio"]}
|
168 |
|
169 |
|
|
|
164 |
"""
|
165 |
if "audio" not in word:
|
166 |
return {}
|
167 |
+
|
168 |
+
if word["audio"] == "" or word["audio"] is None:
|
169 |
+
raise ValueError(
|
170 |
+
"{} has an emtpy 'audio' field. Either fill it with an URL or simply remove the 'audio' field.".format(word)
|
171 |
+
)
|
172 |
+
|
173 |
return {"audio": word["audio"]}
|
174 |
|
175 |
|
tests/test_vocabulary_parser.py
CHANGED
@@ -18,6 +18,7 @@ import yaml
|
|
18 |
from huggingface.german_parser import get_declension_attributes
|
19 |
from huggingface.vocabulary_parser import GERMAN
|
20 |
from huggingface.vocabulary_parser import get_attributes
|
|
|
21 |
from huggingface.vocabulary_parser import get_definition_tokens
|
22 |
from huggingface.vocabulary_parser import get_definitions
|
23 |
from huggingface.vocabulary_parser import get_inferred_links
|
@@ -335,3 +336,24 @@ class TestVocabularyParser(unittest.TestCase):
|
|
335 |
self.assertTrue(is_structurally_similar("anschließen", "anschließend"))
|
336 |
self.assertTrue(is_structurally_similar("anschließend", "anschließen"))
|
337 |
self.assertFalse(is_structurally_similar("die Bank", "die Sahne"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
from huggingface.german_parser import get_declension_attributes
|
19 |
from huggingface.vocabulary_parser import GERMAN
|
20 |
from huggingface.vocabulary_parser import get_attributes
|
21 |
+
from huggingface.vocabulary_parser import get_audio
|
22 |
from huggingface.vocabulary_parser import get_definition_tokens
|
23 |
from huggingface.vocabulary_parser import get_definitions
|
24 |
from huggingface.vocabulary_parser import get_inferred_links
|
|
|
336 |
self.assertTrue(is_structurally_similar("anschließen", "anschließend"))
|
337 |
self.assertTrue(is_structurally_similar("anschließend", "anschließen"))
|
338 |
self.assertFalse(is_structurally_similar("die Bank", "die Sahne"))
|
339 |
+
|
340 |
+
def test_get_audio_with_missing_url(self):
|
341 |
+
word = yaml.safe_load(
|
342 |
+
"""
|
343 |
+
term: durchführen
|
344 |
+
definition:
|
345 |
+
- to perform
|
346 |
+
- to conduct
|
347 |
+
- to implement
|
348 |
+
- to carry out
|
349 |
+
- to execute
|
350 |
+
- to put into action
|
351 |
+
audio:
|
352 |
+
verbformen:
|
353 |
+
video: https://youtu.be/GTaswCjpdXA
|
354 |
+
conjugation: https://www.verbformen.com/conjugation/durchfu3hren.pdf
|
355 |
+
flashcards: https://www.verbformen.com/conjugation/worksheets-exercises/lernkarten/durchfu3hren.pdf
|
356 |
+
"""
|
357 |
+
)
|
358 |
+
with self.assertRaises(ValueError):
|
359 |
+
get_audio(word)
|