From 63373d9c70891f7ddec7baa7992fc05c01962612 Mon Sep 17 00:00:00 2001 From: xxyzz Date: Mon, 23 Dec 2024 09:22:00 +0800 Subject: [PATCH 1/2] [zh] fix TypeError: unhashable type: 'list' exception MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in page "提比里斯", wikitext: "{{trans-see|喬治亞/格魯吉亞首都|第比利 斯#翻譯{{!}}第比利斯}}" --- src/wiktextract/extractor/zh/section_titles.py | 5 +---- src/wiktextract/extractor/zh/translation.py | 6 +++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/wiktextract/extractor/zh/section_titles.py b/src/wiktextract/extractor/zh/section_titles.py index 653e877b..2f4ff23b 100644 --- a/src/wiktextract/extractor/zh/section_titles.py +++ b/src/wiktextract/extractor/zh/section_titles.py @@ -2,10 +2,7 @@ POS_TITLES: dict[str, POSSubtitleData] = { "不及物动词": {"pos": "verb", "tags": ["intransitive"]}, - "不及物動詞": { - "pos": "verb", - "tags": ["intransitive"] - }, + "不及物動詞": {"pos": "verb", "tags": ["intransitive"]}, "不定代词": {"pos": "pron"}, "不定冠詞": {"pos": "article"}, "不定冠词": {"pos": "article"}, diff --git a/src/wiktextract/extractor/zh/translation.py b/src/wiktextract/extractor/zh/translation.py index 1029febb..710b16ca 100644 --- a/src/wiktextract/extractor/zh/translation.py +++ b/src/wiktextract/extractor/zh/translation.py @@ -158,7 +158,11 @@ def translation_subpage( target_section = None if template_node.template_name == "see translation subpage": target_section = template_node.template_parameters.get(1) - page_title = template_node.template_parameters.get(2, wxr.wtp.title) + page_title = clean_node( + wxr, None, template_node.template_parameters.get(2, wxr.wtp.title) + ) + if "#" in page_title: + page_title = page_title[:page_title.index("#")] translation_subpage_title = page_title if page_title == wxr.wtp.title: From 60957469ee8293c4f33f4396a100c6973a1cf831 Mon Sep 17 00:00:00 2001 From: xxyzz Date: Mon, 23 Dec 2024 10:22:25 +0800 Subject: [PATCH 2/2] [zh] ignore "rfdef" no gloss template this template has Lua error and is used to indicate the word lacks definition --- src/wiktextract/extractor/zh/gloss.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wiktextract/extractor/zh/gloss.py b/src/wiktextract/extractor/zh/gloss.py index a4167cae..95b53f6d 100644 --- a/src/wiktextract/extractor/zh/gloss.py +++ b/src/wiktextract/extractor/zh/gloss.py @@ -27,6 +27,8 @@ def extract_gloss( gloss_data = parent_gloss_data.model_copy(deep=True) for node in list_item_node.children: if isinstance(node, TemplateNode): + if node.template_name == "rfdef": + continue raw_tag = clean_node(wxr, gloss_data, node) if node.template_name in LABEL_TEMPLATES: raw_tags.extend(raw_tag.strip("()").split(","))