diff --git a/src/wiktextract/extractor/ko/linkage.py b/src/wiktextract/extractor/ko/linkage.py index 705c0b7e..16f7e21f 100644 --- a/src/wiktextract/extractor/ko/linkage.py +++ b/src/wiktextract/extractor/ko/linkage.py @@ -108,3 +108,31 @@ def extract_proverb_section( break if linkage.word != "": word_entry.proverbs.append(linkage) + else: + for t_node in list_item.find_child(NodeKind.TEMPLATE): + if t_node.template_name in ["l", "연결"]: + extract_l_template(wxr, word_entry, t_node, "proverbs") + + +def extract_l_template( + wxr: WiktextractContext, + word_entry: WordEntry, + t_node: TemplateNode, + linkage_type: str, +) -> None: + # https://ko.wiktionary.org/wiki/틀:연결 + # https://en.wiktionary.org/wiki/Template:link + for word_arg in [3, 2]: + if word_arg in t_node.template_parameters: + word = clean_node(wxr, None, t_node.template_parameters[word_arg]) + if word == "": + break + linkage = Linkage(word=word) + for sense_arg in ["t", 4]: + if sense_arg in t_node.template_parameters: + linkage.sense = clean_node( + wxr, None, t_node.template_parameters[sense_arg] + ) + break + getattr(word_entry, linkage_type).append(linkage) + break diff --git a/tests/test_ko_linkage.py b/tests/test_ko_linkage.py index 916fde73..a3d58c18 100644 --- a/tests/test_ko_linkage.py +++ b/tests/test_ko_linkage.py @@ -108,3 +108,23 @@ def test_zh_pinyin(self): {"word": "土产", "roman": "tǔchǎn", "sense": "흙, 땅"}, ], ) + + def test_l_template(self): + data = parse_page( + self.wxr, + "병신", + """== 중국어 == +=== 명사 === +# 다쳐서 +==== 관용구 ==== +* {{l|ko|병신도 제 재미에 산다|t=사람은 각자 자기 잘 난 맛에 산다라는 뜻}}""", + ) + self.assertEqual( + data[0]["proverbs"], + [ + { + "word": "병신도 제 재미에 산다", + "sense": "사람은 각자 자기 잘 난 맛에 산다라는 뜻", + } + ], + )