First commit
This commit is contained in:
commit
b6ab07d55c
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
build/
|
||||
*.xlsx
|
50
README.md
Normal file
50
README.md
Normal file
@ -0,0 +1,50 @@
|
||||
# remember-the-JLPT
|
||||
|
||||
## What is it?
|
||||
|
||||
remember-the-JLPT is a little python tool that allows to combine the [Remember the Kanji (RTK)](https://en.wikipedia.org/wiki/Remembering_the_Kanji_and_Remembering_the_Hanzi) technique with the [Japanese Language Proficiency Test (JLPT)](https://www.jlpt.jp/e/) requirements. It also includes the indexes for the French edition of RTK, called [Les Kanjis dans la tête (KDLT)](https://maniette.fr/).
|
||||
|
||||
For instance, imagine you're starting the RTK method, but want to work towards the JLPT N4. There's only around 250 kanjis required, but they go up to number 2172 out of 2200. Which pretty much means finishing the book! Since it can take quite a lot of time to get there, this tool can allow you to know which kanjis you should learn for the exam, while using the RTK technique.
|
||||
|
||||
This tool outputs a configurable list of kanjis depending on various options, mainly the JLPT level and whether it's from the English or French index. Once you've got this list, you can for example make your own [Anki deck](https://apps.ankiweb.net/). Another option is to work with [Kanji Koohii](https://kanji.koohii.com/), where you can search the indexes or kanjis.
|
||||
|
||||
Kanjis are made up of other kanjis learned before, so you will still need to search for previous occurrences in the indices of the original book. But remember-the-JLPT makes it definitely easier to have a kick-start.
|
||||
|
||||
## Database information
|
||||
|
||||
The database is a CSV file located in the `source` folder. You can also access the formatted ODS version, which you can open with your favorite spreadsheet software. You can also directly work with the ODS file if you wish.
|
||||
|
||||
The French book has more kanjis and different indexes from the English original one.
|
||||
|
||||
There are some kanjis that are not referenced in the JLPT lists, and those have a JLPT level of 0 in the database. You can query them if needed.
|
||||
|
||||
## Configuration
|
||||
|
||||
* -jlpt {0,1,2,3,4,5}
|
||||
* Choose the JLPT levels you want to output. You can select multiple ones. [Mandatory]
|
||||
* -ref {KDLT,RTK}
|
||||
* Choose whether you want the English (RTK) or French (KDLT) index. [Mandatory]
|
||||
* -type {name,kanji,number}
|
||||
* Choose the output data you want. You can select multiple ones and the order you want. [Mandatory]
|
||||
* -output {display,file}
|
||||
* Output on the standard output or in a file. You can select both option. File will be saved to the `build` folder. [Mandatory]
|
||||
* -separator
|
||||
* The default separator is ", " for a CSV file. You can change it with this parameter. [Optional]
|
||||
|
||||
## Example
|
||||
|
||||
`python3 .\remember-the-JLPT.py -jlpt 5 4 3 -ref RTK -type number kanji name -output display -separator " - "`
|
||||
|
||||
Sample output:
|
||||
```
|
||||
[...]
|
||||
126 - 太 - plump
|
||||
134 - 川 - stream
|
||||
137 - 水 - water
|
||||
142 - 原 - meadow
|
||||
143 - 願 - petition
|
||||
144 - 泳 - swim
|
||||
154 - 活 - lively
|
||||
155 - 消 - extinguish
|
||||
[...]
|
||||
```
|
83
remember-the-JLPT.py
Normal file
83
remember-the-JLPT.py
Normal file
@ -0,0 +1,83 @@
|
||||
import os
|
||||
import csv
|
||||
import argparse
|
||||
|
||||
# Parse arguments
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-jlpt", type=int, choices={5, 4, 3, 2, 1, 0}, nargs="+", help="Choose the JLPT levels you want to output. You can select multiple ones. [Mandatory]", required = True)
|
||||
parser.add_argument("-ref", type=str, choices={"RTK", "KDLT"}, help="Choose whether you want the English (RTK) or French (KDLT) index. [Mandatory]", required = True)
|
||||
parser.add_argument("-type", type=str, choices={"number", "kanji", "name"}, nargs="+", help="Choose the output data you want. You can select multiple ones and the order you want. [Mandatory]", required = True)
|
||||
parser.add_argument("-output", type=str, choices={"file", "display"}, nargs="+", help="Output on the standard output or in a file. You can select both option. File will be saved to the build folder. [Mandatory]", required = True)
|
||||
parser.add_argument("-separator", type=str, help="The default separator is \", \" for a CSV file. You can change it with this parameter. [Optional]")
|
||||
args = parser.parse_args()
|
||||
levels = args.jlpt
|
||||
reference = args.ref
|
||||
type = args.type
|
||||
output = args.output
|
||||
output.sort()
|
||||
if args.separator:
|
||||
separator = args.separator
|
||||
else:
|
||||
separator = ", "
|
||||
|
||||
# Parameters
|
||||
csv_Kanji = "Kanji"
|
||||
csv_RTKNum = "RTK Number"
|
||||
csv_RTKName = "RTK Name"
|
||||
csv_KDLTNum = "KDLT Number"
|
||||
csv_KDLTName = "KDLT Name"
|
||||
csv_JLPT = "JLPT Level"
|
||||
csv_source = "source/kanji_list.csv"
|
||||
level_formatted = "N" + "_N".join([str(i) for i in levels])
|
||||
output_file_name = "build/" + reference + "_" + level_formatted + ".csv"
|
||||
|
||||
# Fill data from the database
|
||||
def make_result():
|
||||
result = []
|
||||
csv_file = open(csv_source, 'r', encoding='utf-8-sig')
|
||||
reader = csv.DictReader(csv_file)
|
||||
|
||||
for row in reader:
|
||||
for lvl in levels:
|
||||
if row[csv_JLPT] == str(lvl) and row[reference + " Number"] != "0":
|
||||
result.append((int(row[reference + " Number"]), row["Kanji"], row[reference + " Name"]))
|
||||
|
||||
result.sort()
|
||||
return result
|
||||
|
||||
# Format the result depending on the parameters
|
||||
def format_result(result):
|
||||
formatted_result = []
|
||||
|
||||
for item in result:
|
||||
temp_str = ""
|
||||
for index, value in enumerate(type):
|
||||
if value == "number":
|
||||
temp_str += (separator if index >= 1 else "") + str(item[0])
|
||||
elif value == "kanji":
|
||||
temp_str += (separator if index >= 1 else "") + str(item[1])
|
||||
elif value == "name":
|
||||
temp_str += (separator if index >= 1 else "") + str(item[2])
|
||||
formatted_result.append(temp_str)
|
||||
|
||||
return formatted_result
|
||||
|
||||
# Output the result to a file
|
||||
def output_result_to_file(result):
|
||||
os.makedirs(os.path.dirname(output_file_name), exist_ok=True)
|
||||
output_file = open(output_file_name, "w", encoding='utf-8-sig')
|
||||
for row in result:
|
||||
output_file.write(row + "\n")
|
||||
|
||||
# Displays the result
|
||||
def display_result(result):
|
||||
for row in result:
|
||||
print(row)
|
||||
|
||||
# Program
|
||||
for value in output:
|
||||
if value == "display":
|
||||
display_result(format_result(make_result()))
|
||||
elif value == "file":
|
||||
output_result_to_file(format_result(make_result()))
|
||||
print("Saved to file", output_file_name + "!")
|
2223
source/kanji_list.csv
Normal file
2223
source/kanji_list.csv
Normal file
File diff suppressed because it is too large
Load Diff
BIN
source/kanji_list.ods
Normal file
BIN
source/kanji_list.ods
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user