Coverage for src/wiktextract/extractor/es/sense_data.py: 17%

28 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-10-25 10:11 +0000

1from wikitextprocessor import NodeKind, WikiNode 

2 

3from ...page import clean_node 

4from ...wxr_context import WiktextractContext 

5from .example import process_example_list 

6from .linkage import process_linkage_list_children 

7from .models import WordEntry 

8from .section_titles import LINKAGE_TITLES 

9 

10 

11def process_sense_data_list( 

12 wxr: WiktextractContext, word_entry: list[WordEntry], list_node: WikiNode 

13) -> None: 

14 list_marker = list_node.sarg 

15 

16 if list_marker == ":;": 

17 # XXX: Extract subsenses (rare!) 

18 pass 

19 elif list_marker in [":*"]: 

20 for list_item in list_node.find_child(NodeKind.LIST_ITEM): 

21 children = list(list_item.filter_empty_str_child()) 

22 # The first child will specify what data is listed 

23 list_type = ( 

24 clean_node(wxr, {}, children[0]) 

25 .strip() 

26 .removesuffix(":") 

27 .removesuffix("s") 

28 .lower() 

29 ) 

30 

31 if list_type == "ejemplo": 

32 process_example_list(wxr, word_entry.senses[-1], list_item) 

33 elif list_type in LINKAGE_TITLES: 

34 process_linkage_list_children( 

35 wxr, word_entry, children[1:], LINKAGE_TITLES[list_type] 

36 ) 

37 elif list_type == "ámbito": 

38 # XXX: Extract scope tag 

39 pass 

40 elif list_type == "uso": 

41 # XXX: Extract usage note 

42 pass 

43 else: 

44 wxr.wtp.debug( 

45 f"Found unknown list type '{list_type}' in {list_item}", 

46 sortid="extractor/es/sense_data/process_sense_data_list/46", 

47 ) 

48 

49 elif list_marker in ["::", ":::"]: 

50 # E.g. https://es.wiktionary.org/wiki/silepsis 

51 for list_item in list_node.find_child_recursively(NodeKind.LIST_ITEM): 

52 process_example_list(wxr, word_entry.senses[-1], list_item) 

53 

54 else: 

55 wxr.wtp.debug( 

56 f"Found unknown list marker {list_marker} in: {list_node}", 

57 sortid="extractor/es/sense_data/process_sense_data_list/52", 

58 )