33 lines
1.4 KiB
Python
33 lines
1.4 KiB
Python
from fugashi_parser import *
|
|
|
|
import os
|
|
from pathlib import Path
|
|
import shutil
|
|
import hashlib
|
|
|
|
season_path = Path('/run/media/deck/YF8SD/Sync/Notebooks/Obsidian/Japanese/JPod101/3N_Absolute Beginner Season 2/')
|
|
|
|
pos_list = list()
|
|
with open(season_path.parent.joinpath(season_path.stem + '.md'), 'w') as out_file:
|
|
for file_path in sorted(season_path.iterdir()):
|
|
if file_path.is_file() and file_path.suffix == '.md': # Ensure it's a file, not a subdirectory
|
|
#out_file = file_path.parent.parent.joinpath(file_path.parent.stem + '_READ.md')
|
|
with open(file_path, "r") as file:
|
|
#file.write("This text will be added to the end.")
|
|
print(f"###### [[{file_path.name}]]", file=out_file)
|
|
file.seek(0)
|
|
kanji_block = re.search(r'·+\s*KANJI(.*?)·+\s*[KANA|ROMANIZATION]', file.read(), re.DOTALL)
|
|
if (kanji_block):
|
|
kanji_block.group(1)
|
|
print( kanji_block.group(1).strip().replace('····','') , file=out_file)
|
|
else:
|
|
print(file_path.stem, 'No Kanji block found')
|
|
# else:
|
|
# print(pos, ' - no tag')
|
|
|
|
# with file_path.open('r') as file:
|
|
# content = file.read()
|
|
# print(f"Content of {file_path.name}: {content}")
|
|
|
|
unique_values = list(set(pos_list))
|
|
print(unique_values) |