From 26f13edd39a865256550ede459ffb05ad36d469f Mon Sep 17 00:00:00 2001 From: Saeed Rasooli Date: Tue, 17 Dec 2024 19:56:19 +0330 Subject: [PATCH] wiktextract: move Categories to the bottom of entry --- pyglossary/plugins/wiktextract.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pyglossary/plugins/wiktextract.py b/pyglossary/plugins/wiktextract.py index 6e06519bd..50f0eccef 100644 --- a/pyglossary/plugins/wiktextract.py +++ b/pyglossary/plugins/wiktextract.py @@ -217,7 +217,9 @@ def br() -> Element: with hf.element("font", color=self._gram_color): hf.write(pos) - self.writeSenseList(hf_, data.get("senses")) # type: ignore + senses = data.get("senses") or [] + + self.writeSenseList(hf_, senses) # type: ignore self.writeSynonyms(hf_, data.get("synonyms")) # type: ignore @@ -232,6 +234,13 @@ def br() -> Element: with hf.element("div"): hf.write(f"Etymology: {etymology}") + categories = [] + for sense in senses: + senseCats = sense.get("categories") + if senseCats: + categories += senseCats + self.writeSenseCategories(hf_, categories) + defi = f.getvalue().decode("utf-8") # defi = defi.replace("\xa0", " ") # do we need to do this? file = self._file @@ -645,8 +654,6 @@ def writeSense( if glosses: self.makeList(hf, glosses, self.writeSenseGloss) - self.writeSenseCategories(hf, sense.get("categories")) - self.writeTopics(hf, sense.get("topics")) self.writeSenseFormOfList(hf, sense.get("form_of"))