Coverage for src/wiktextract/extractor/cs/tags.py: 58%

22 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-09-12 08:27 +0000

1from .models import WordEntry 

2 

3# https://cs.wiktionary.org/wiki/Modul:Priznaky/seznam 

4LABEL_TAGS = { 

5 "expresivně": "expressively", 

6 "pejorativně": "pejorative", 

7} 

8 

9GENDER_TAGS = { 

10 "mužský": "masculine", 

11 "životný": "animate", 

12} 

13 

14 

15TAGS = {**LABEL_TAGS, **GENDER_TAGS} 

16 

17TOPICS = {} 

18 

19 

20def translate_raw_tags(data: WordEntry) -> None: 

21 raw_tags = [] 

22 for raw_tag in data.raw_tags: 

23 if raw_tag in TAGS and hasattr(data, "tags"): 

24 tr_tag = TAGS[raw_tag] 

25 if isinstance(tr_tag, str): 25 ↛ 27line 25 didn't jump to line 27 because the condition on line 25 was always true

26 data.tags.append(tr_tag) 

27 elif isinstance(tr_tag, list): 

28 data.tags.extend(tr_tag) 

29 elif raw_tag in TOPICS and hasattr(data, "topics"): 29 ↛ 30line 29 didn't jump to line 30 because the condition on line 29 was never true

30 topic = TOPICS[raw_tag] 

31 if isinstance(topic, str): 

32 data.topics.append(topic) 

33 elif isinstance(topic, list): 

34 data.topics.extend(topic) 

35 else: 

36 raw_tags.append(raw_tag) 

37 data.raw_tags = raw_tags