From c14eb1b4c402238389d6e99154c2b085a92f453a Mon Sep 17 00:00:00 2001 From: Nitsud Yarg Date: Sat, 23 May 2026 22:54:38 -0700 Subject: [PATCH] stuff --- append_vocab_tab.py | 28 ++++++++++++++++++++++++++++ fugashi_parser.py | 10 +++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 append_vocab_tab.py diff --git a/append_vocab_tab.py b/append_vocab_tab.py new file mode 100644 index 0000000..d64344a --- /dev/null +++ b/append_vocab_tab.py @@ -0,0 +1,28 @@ +from fugashi_parser import * + +import os +from pathlib import Path +import shutil +import hashlib + +vocab_destination_path = Path('/run/media/deck/YF8SD/Sync/Notebooks/Obsidian/Japanese/vocab') + +pos_list = list() +for file_path in vocab_destination_path.iterdir(): + if file_path.is_file(): # Ensure it's a file, not a subdirectory + pos = file_path.stem.split('_')[1] + pos_list.append(pos) + if CONTENT_LINK_TAG.get(pos): + #do a thing + with open(file_path, "a") as file: + #file.write("This text will be added to the end.") + print(f"#{CONTENT_LINK_TAG[pos]}", file=file) + 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) \ No newline at end of file diff --git a/fugashi_parser.py b/fugashi_parser.py index 5e5de82..8ebbf41 100644 --- a/fugashi_parser.py +++ b/fugashi_parser.py @@ -101,7 +101,11 @@ def term_entries(term :str) -> dict: CONTENT_LINK_TAG = { '名詞': 'meishi', # noun '動詞': 'doshi', # verb - '形容詞': 'keiyoshi' # Adjective + '形容詞': 'keiyoshi', # Adjective + '形状詞': 'keijoshi', # form word + '代名詞':'daimeishi', # pronoun + '感動詞': 'kandoshi', # interjection + '副詞' : 'fukushi' # adverb #'副詞' : 'fukushi' #adverb } @@ -420,7 +424,7 @@ def write_word_note(word: str, destination_dir: Path, part_of_speech:str='', ove vocab_note.write(entry['glossary-first']) #print("##### Other Definitions", file=vocab_note) print("\n", file=vocab_note) - # if CONTENT_LINK_TAG.get(part_of_speech, '') != '': - # print(f"#{CONTENT_LINK_TAG[part_of_speech]}", file=vocab_note) + if CONTENT_LINK_TAG.get(part_of_speech, '') != '': + print(f"#{CONTENT_LINK_TAG[part_of_speech]}", file=vocab_note)