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

[ku] fix Lua error and improve linkage section code #1048

Merged
merged 2 commits into from
Feb 24, 2025
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
8 changes: 7 additions & 1 deletion src/wiktextract/data/ku/config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"save_ns_names": ["Main", "Template", "Module", "Tewandin"]
"save_ns_names": [
"Main",
"Template",
"Module",
"Tewandin",
"Nimînok"
]
}
10 changes: 9 additions & 1 deletion src/wiktextract/extractor/ku/linkage.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,11 @@ def extract_linkage_list_item(
shared_tags: list[str] = [],
) -> None:
raw_tags = []
forms = []
for node in list_item.children:
if isinstance(node, WikiNode) and node.kind == NodeKind.LINK:
if (
isinstance(node, WikiNode) and node.kind == NodeKind.LINK
) or isinstance(node, str):
word = clean_node(wxr, None, node)
if word != "":
if linkage_type != "":
Expand All @@ -233,10 +236,12 @@ def extract_linkage_list_item(
raw_tags=raw_tags,
tags=shared_tags,
)
forms.append(l_data)
translate_raw_tags(l_data)
getattr(word_entry, linkage_type).append(l_data)
else:
form = Form(form=word, raw_tags=raw_tags, tags=shared_tags)
forms.append(l_data)
translate_raw_tags(form)
word_entry.forms.append(form)
elif isinstance(node, TemplateNode):
Expand Down Expand Up @@ -268,6 +273,9 @@ def extract_linkage_list_item(
raw_tag = clean_node(wxr, None, node).strip("() ")
if raw_tag != "":
raw_tags.append(raw_tag)
for form in forms:
form.raw_tags.append(raw_tag)
translate_raw_tags(form)


def extract_stûn_template(
Expand Down
20 changes: 20 additions & 0 deletions tests/test_ku_linkage.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,23 @@ def test_kol_tag(self):
self.assertEqual(
page_data[0]["derived"], [{"word": "aqil kirin", "tags": ["verb"]}]
)

def test_kol_mj(self):
self.wxr.wtp.add_page("Şablon:ziman", 10, "Îngilîzî")
self.wxr.wtp.add_page("Şablon:mj", 10, "(xweşbêjî)")
page_data = parse_page(
self.wxr,
"go the way of all flesh",
"""== {{ziman|en}} ==
=== Biwêj ===
# [[texsîrî]]
==== Jê ====
==== Hevmane ====
{{kol3|en|cure=Hevmane
|exit {{mj|{{nimînok|xweşbêjî}}}}
}}""",
)
self.assertEqual(
page_data[0]["synonyms"],
[{"word": "exit", "tags": ["euphemistic"]}],
)