Skip to content

Commit

Permalink
Merge pull request #1048 from xxyzz/ku
Browse files Browse the repository at this point in the history
[ku] fix Lua error and improve linkage section code
  • Loading branch information
xxyzz authored Feb 24, 2025
2 parents 8a9b3fc + 3e22526 commit 5624056
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
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"]}],
)

0 comments on commit 5624056

Please sign in to comment.