Coverage for src/wiktextract/extractor/nl/spelling_form.py: 89%
18 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-25 10:11 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-25 10:11 +0000
1from wikitextprocessor import LevelNode, NodeKind, WikiNode
3from ...page import clean_node
4from ...wxr_context import WiktextractContext
5from .models import Form, WordEntry
8def extract_spelling_form_section(
9 wxr: WiktextractContext, word_entry: WordEntry, level_node: LevelNode
10) -> None:
11 for list_item in level_node.find_child_recursively(NodeKind.LIST_ITEM):
12 form_nodes = []
13 note_str = ""
14 for node in list_item.children:
15 if isinstance(node, WikiNode) and node.kind == NodeKind.ITALIC:
16 new_note_str = clean_node(wxr, None, node)
17 if new_note_str.startswith("(") and new_note_str.endswith(")"): 17 ↛ 20line 17 didn't jump to line 20 because the condition on line 17 was always true
18 note_str = new_note_str.strip("() ")
19 else:
20 form_nodes.append(new_note_str)
21 else:
22 form_nodes.append(node)
23 form_str = clean_node(wxr, None, form_nodes)
24 if len(form_str) > 0: 24 ↛ 11line 24 didn't jump to line 11 because the condition on line 24 was always true
25 word_entry.forms.append(Form(form=form_str, note=note_str))