Coverage for src/wiktextract/extractor/ko/tags.py: 68%

13 statements  

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

1from .models import WordEntry 

2 

3# https://ko.wiktionary.org/wiki/모듈:labels/data/topical 

4# https://ko.wiktionary.org/wiki/모듈:labels/data 

5GLOSS_TAGS = { 

6 "인명": "name", 

7 "고어": "archaic", 

8 "구식": "archaic", 

9 # "대명동사": "", 

10 # "말고름": "", 

11 "비유": "metaphoric", 

12 "사어": "obsolete", # dead language 

13 "유아어": "baby-talk", 

14 "자동사": "intransitive", 

15 "직역": "literally", 

16 "타동사": "transitive", 

17} 

18 

19TAGS = {**GLOSS_TAGS} 

20 

21TOPICS = { 

22 "금융": "finance", 

23 "광고": "advertising", 

24 "군사": "military", 

25 "어류": "fish", 

26 "물리": "physics", 

27 "법률": "law", 

28 "식물": "botany", 

29 "역사": "history", 

30 "의류": "clothing", 

31 "의학": "medicine", 

32 "전기": "electricity", 

33 # "조류": "birds", 

34 "지리": "geography", 

35 "프로그래밍": "programming", 

36 "컴퓨터": "computer", 

37 "해부학": "anatomy", 

38 "정치": "politics", 

39 "종교": "religion", 

40 "가톨릭": "Catholicism", 

41 "축구": "football", 

42 # "체육": "physical-education", 

43} 

44 

45 

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

47 raw_tags = [] 

48 for raw_tag in data.raw_tags: 

49 if raw_tag in TAGS: 49 ↛ 51line 49 didn't jump to line 51 because the condition on line 49 was always true

50 data.tags.append(TAGS[raw_tag]) 

51 elif raw_tag in TOPICS: 

52 data.topics.append(TOPICS[raw_tag]) 

53 else: 

54 raw_tags.append(raw_tag) 

55 data.raw_tags = raw_tags