add HSK4 en
This commit is contained in:
34
input/HSK/HSK4/script.py
Normal file
34
input/HSK/HSK4/script.py
Normal file
@@ -0,0 +1,34 @@
|
||||
### script.py
|
||||
|
||||
from pathlib import Path
|
||||
import csv
|
||||
|
||||
input_file = Path(r"D:\Projects\anki-hsk-creator-data\input\HSK\HSK4\deepseek_tsv_20260718_c5df6a.txt")
|
||||
data_folder = Path(r"D:\Projects\anki-hsk-creator-data\input\HSK\HSK4")
|
||||
|
||||
def analise():
|
||||
with input_file.open(encoding="utf8", newline='') as file:
|
||||
tsv_reader = csv.reader(file, delimiter='\t')
|
||||
n = 0
|
||||
for lesson, simplified, pinying, tag, meaning in tsv_reader:
|
||||
print(lesson, simplified, pinying, meaning)
|
||||
lesson_n = int(lesson.split()[1])
|
||||
if lesson_n > n:
|
||||
n = lesson_n
|
||||
output_file = data_folder / f"HSK4-{n:02n}.dictionary.txt"
|
||||
with output_file.open("a", encoding="utf8", newline='') as csvfile:
|
||||
spamwriter = csv.writer(csvfile, dialect="excel-tab")
|
||||
spamwriter.writerow([simplified, meaning])
|
||||
|
||||
def create():
|
||||
for file in data_folder.glob(f"*.dictionary.txt"):
|
||||
print(file)
|
||||
file = Path(file)
|
||||
(data_folder / f"{file.name.split(".")[0]}-01.dictation.txt").touch()
|
||||
(data_folder / f"{file.name.split(".")[0]}-02.dictation.txt").touch()
|
||||
(data_folder / f"{file.name.split(".")[0]}-01.phrases.txt").touch()
|
||||
(data_folder / f"{file.name.split(".")[0]}-02.phrases.txt").touch()
|
||||
(data_folder / f"{file.name.split(".")[0]}-03.phrases.txt").touch()
|
||||
|
||||
if __name__ == "__main__":
|
||||
create()
|
||||
Reference in New Issue
Block a user