From ff2ca124f356d6b1a2eb03e8b68f4065868a9f32 Mon Sep 17 00:00:00 2001 From: xxyzz Date: Mon, 26 Feb 2024 17:53:53 +0800 Subject: [PATCH 1/2] Fix 'str' object has no attribute 'extend' in de edition page "BU" Some pages doesn't pass the IPA data to template "Lautschrift" and the `None` was added to the `ipa` field. --- src/wiktextract/extractor/de/pronunciation.py | 2 +- tests/test_de_pronunciation.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/wiktextract/extractor/de/pronunciation.py b/src/wiktextract/extractor/de/pronunciation.py index 90b1d171..0ee05caf 100644 --- a/src/wiktextract/extractor/de/pronunciation.py +++ b/src/wiktextract/extractor/de/pronunciation.py @@ -97,7 +97,7 @@ def process_lautschrift_template( ) -> None: template_parameters = node.template_parameters - ipa = template_parameters.get(1) + ipa = template_parameters.get(1, "") lang_code = template_parameters.get("spr") if lang_code: diff --git a/tests/test_de_pronunciation.py b/tests/test_de_pronunciation.py index 995e1adb..7eeb4000 100644 --- a/tests/test_de_pronunciation.py +++ b/tests/test_de_pronunciation.py @@ -6,6 +6,7 @@ from wiktextract.extractor.de.pronunciation import ( process_hoerbeispiele, process_ipa, + process_lautschrift_template, ) from wiktextract.wxr_context import WiktextractContext @@ -178,3 +179,10 @@ def assertSoundDataMatchesExpected(self, sound_data, expected): self.assertIn(key, exp) if exp[key] is not None: self.assertEqual(data[key], exp[key]) + + def test_empty_ipa_in_lautschrift(self): + self.wxr.wtp.start_page("BU") + root = self.wxr.wtp.parse("{{Lautschrift}}") + sound_data = [Sound()] + process_lautschrift_template(self.wxr, sound_data, root.children[0]) + self.assertEqual(sound_data[0].model_dump(exclude_defaults=True), {}) From 670911e7a8f8be91d9631f04dcaa28063e8a5a86 Mon Sep 17 00:00:00 2001 From: xxyzz Date: Mon, 26 Feb 2024 18:01:51 +0800 Subject: [PATCH 2/2] Fix "argument of type 'NoneType' is not iterable" error in de page "Bauerngabel" This is a chess board table and it doesn't have `class` attribute. Since this `if` branch is not implemented, I'll omit the test for this error. --- src/wiktextract/extractor/de/page.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wiktextract/extractor/de/page.py b/src/wiktextract/extractor/de/page.py index b1fb7785..576b2264 100644 --- a/src/wiktextract/extractor/de/page.py +++ b/src/wiktextract/extractor/de/page.py @@ -224,7 +224,7 @@ def process_pos_section( elif ( isinstance(non_l4_node, WikiNode) and non_l4_node.kind == NodeKind.TABLE - and "inflection-table" in non_l4_node.attrs.get("class") + and "inflection-table" in non_l4_node.attrs.get("class", "") ): # XXX: de: Extract html form table pass