Skip to content

Commit

Permalink
Update and sort zh difficulty JSON file
Browse files Browse the repository at this point in the history
The latest coct file removed 43 location names
  • Loading branch information
xxyzz committed Aug 8, 2024
1 parent e3934f0 commit 8faaaf5
Show file tree
Hide file tree
Showing 4 changed files with 13,008 additions and 13,053 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies = [
]

[project.optional-dependencies]
dev = ["mypy", "ruff", "requests"]
dev = ["mypy", "ruff", "requests", "types-requests"]

[project.scripts]
proficiency = "proficiency.main:main"
Expand Down
4 changes: 2 additions & 2 deletions src/proficiency/zh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

- [kaikki.org](https://kaikki.org/dictionary/Chinese/index.html)

- [Corpus of Contemporary Taiwanese Mandarin](https://coct.naer.edu.tw/download/tech_report)
- [華語文能力基準 三等七級詞語表(2022-11-14)](https://coct.naer.edu.tw/file/files/臺灣華語文能力基準詞語表_111-11-14.ods)

## Convert difficulty level

- P1, 1, 1+, 2, 2+, 3, 3+ -> 5
- 1, 1\*, 2, 2\*, 3, 3\* -> 5

- 4 -> 4

Expand Down
18 changes: 8 additions & 10 deletions src/proficiency/zh/convert_naer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@
import re


def convert_difficulty(level: str) -> int:
match level:
case "第P1級" | "第1級" | "第1+級" | "第2級" | "第2+級" | "第3級" | "第3+級":
def convert_difficulty(level_str: str) -> int:
match int(level_str[1]):
case 1 | 2 | 3:
return 5
case "第4級":
case 4:
return 4
case "第5級":
case 5:
return 3
case "第6級":
case 6:
return 2
case "第7級":
return 1
case _:
return -1
return 1


def main() -> None:
Expand Down Expand Up @@ -55,7 +53,7 @@ def main() -> None:
words[word] = difficulty

with open("difficulty.json", "w") as f:
json.dump(words, f, indent=2, ensure_ascii=False)
json.dump(words, f, indent=2, ensure_ascii=False, sort_keys=True)


if __name__ == "__main__":
Expand Down
Loading

0 comments on commit 8faaaf5

Please sign in to comment.