Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[zh] fix TypeError exception and silence Lua errors in "rfdef" template #953

Merged
merged 2 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/wiktextract/extractor/zh/gloss.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(","))
Expand Down
5 changes: 1 addition & 4 deletions src/wiktextract/extractor/zh/section_titles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
6 changes: 5 additions & 1 deletion src/wiktextract/extractor/zh/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading