diff --git a/create-notes.py b/create-notes.py
index 377b446..ecb444b 100644
--- a/create-notes.py
+++ b/create-notes.py
@@ -1,4 +1,4 @@
-from parser import *
+from fugashi_parser import *
import os
from pathlib import Path
@@ -21,18 +21,23 @@ if not destination_path.joinpath('vocab').exists():
with open("dump-withFuri.json", "r", encoding="utf-16") as f:
dump = json.load(f)
+vocab = {} #load_vocab('foo.json')
+
for cd in dump:
+ ## The japanese card name
print(dump[cd]['name_J'])
+ ## copy the image if it isn't already there
if Path('YGO_2020/2020.full.illust_j.jpg.zib/' + cd + '.jpg').exists():
##TODO: Ew
if Path(destination_path.joinpath('_attachments/' + cd + '.jpg')).exists() == False:
shutil.copy2(Path('YGO_2020/2020.full.illust_j.jpg.zib/' + cd + '.jpg'), destination_path.joinpath('_attachments'))
with open(destination_path.as_posix() + '/' + cd + '.md', 'w') as card_note:
+ ## add card names as properties
card_note.write("---\n")
card_note.write(f"aliases: [{dump[cd]['name_J']},{dump[cd]['name_E']}]\n")
card_note.write("---\n")
## Name at the top
- card_note.write(f"![[{cd}.jpg]]")
+ card_note.write(f"![[{cd}.jpg]]") ## card image
card_note.write("\n#### Name\n")
card_note.write("")
card_note.write(dump[cd]['name_J'])
@@ -48,42 +53,70 @@ for cd in dump:
card_note.write("
")
# desc_Furi
card_note.write("\n#### Reading\n")
- if(dump[cd].get("furi")):
- card_note.write(f"{dump[cd]['furi']}\n")
- else:
- card_note.write(dump[cd]['name_J'])
- card_note.write("\n")
- card_note.write("##### Glossary\n")
- for vocab in dump[cd]["glossary_Name_J"]:
- print(f"{vocab} : {dump[cd]["glossary_Name_J"][vocab]}", file=card_note)
- card_note.write("\n")
- if(dump[cd].get("desc_Furi")):
- card_note.write(f"{dump[cd]['desc_Furi']}\n")
- else:
- card_note.write(dump[cd]['desc_J'])
- card_note.write("\n")
- card_note.write("##### Glossary\n")
- for vocab in dump[cd]["glossary_Desc_J"]:
- vocab_hash = hashlib.shake_256((vocab + 'Jitendex.org [2026-04-04]').encode()).hexdigest(4)
- ## Only search and create a vocab file if it doesn't exist
- if Path(destination_path.joinpath('vocab/' + vocab_hash + '.md')).exists() == False:
- definitions = anki_fields_term(vocab)
+ vocab = {} ## flush the vocab variable each time
+ result = analyze(dump[cd]['name_J'],vocab)
+ print(f"{result['ruby_html']}\n> [!summary]- Vocab\n>{result['notes_link']}\n",file=card_note)
+ ## Generate the vocab item
+ for word in vocab:
+ if Path(destination_path.joinpath('vocab/' + word + '.md')).exists() == False:
+ definitions = anki_fields_term(word)
if definitions.get("fields"):
- with open(destination_path.as_posix() + '/vocab/' + vocab_hash + '.md', 'w') as vocab_note:
+ with open(destination_path.as_posix() + '/vocab/' + word + '.md', 'w') as vocab_note:
for entry in definitions.get("fields"):
- vocab_note.write("\n")
- print(entry['expression'], file=vocab_note)
- #print(entry['furigana-plain'], file=vocab_note)
+ print(entry['furigana'], file=vocab_note)
if entry['expression'] != entry['reading']:
print(entry['reading'], file=vocab_note)
- print(entry['furigana'], file=vocab_note)
- #print(f"Part of Speech: {entry['part-of-speech']}", file=vocab_note)
+ print("> ",re.sub(r'<.*?>', '', entry['glossary-plain-no-dictionary']), "\n", file=vocab_note)
print(f"Frequency: {entry['frequency-average-rank']}", file=vocab_note)
- #print(entry['glossary-plain-no-dictionary'], file=vocab_note)
vocab_note.write(entry['glossary-first'])
- print("##### Other Definitions", file=vocab_note)
- print(entry['glossary-plain-no-dictionary'], file=vocab_note)
- print(f"[[{vocab_hash}|{vocab}]] : {dump[cd]["glossary_Desc_J"][vocab]}", file=card_note)
+ print("\n", file=vocab_note)
+ # card_note.write("##### Glossary\n")
+ # for vocab in dump[cd]["glossary_Name_J"]:
+ # print(f"{vocab} : {dump[cd]["glossary_Name_J"][vocab]}", file=card_note)
+ vocab = {} ## flush the vocab variable each time
+ result = analyze(dump[cd]['desc_J'],vocab)
+ #card_note.write("\n")
+ print(f"{result['ruby_html']}\n> [!summary]- Vocab\n>{result['notes_link']}\n",file=card_note)
+ for word in vocab:
+ if Path(destination_path.joinpath('vocab/' + word + '.md')).exists() == False:
+ definitions = anki_fields_term(word)
+ if definitions.get("fields"):
+ with open(destination_path.as_posix() + '/vocab/' + word + '.md', 'w') as vocab_note:
+ for entry in definitions.get("fields"):
+ print(entry['furigana'], file=vocab_note)
+ if entry['expression'] != entry['reading']:
+ print(entry['reading'], file=vocab_note)
+ print("> ",re.sub(r'<.*?>', '', entry['glossary-plain-no-dictionary']), "\n", file=vocab_note)
+ print(f"Frequency: {entry['frequency-average-rank']}", file=vocab_note)
+ vocab_note.write(entry['glossary-first'])
+ print("\n", file=vocab_note)
+ # if(dump[cd].get("desc_Furi")):
+ # card_note.write(f"{dump[cd]['desc_Furi']}\n")
+ # else:
+ # card_note.write(dump[cd]['desc_J'])
+ # card_note.write("\n")
+ # card_note.write("##### Glossary\n")
+ # for vocab in dump[cd]["glossary_Desc_J"]:
+ # vocab_hash = hashlib.shake_256((vocab + 'Jitendex.org [2026-04-04]').encode()).hexdigest(4)
+ # ## Only search and create a vocab file if it doesn't exist
+ # if Path(destination_path.joinpath('vocab/' + vocab_hash + '.md')).exists() == False:
+ # definitions = anki_fields_term(vocab)
+ # if definitions.get("fields"):
+ # with open(destination_path.as_posix() + '/vocab/' + vocab_hash + '.md', 'w') as vocab_note:
+ # for entry in definitions.get("fields"):
+ # vocab_note.write("\n")
+ # print(entry['expression'], file=vocab_note)
+ # #print(entry['furigana-plain'], file=vocab_note)
+ # if entry['expression'] != entry['reading']:
+ # print(entry['reading'], file=vocab_note)
+ # print(entry['furigana'], file=vocab_note)
+ # #print(f"Part of Speech: {entry['part-of-speech']}", file=vocab_note)
+ # print(f"Frequency: {entry['frequency-average-rank']}", file=vocab_note)
+ # #print(entry['glossary-plain-no-dictionary'], file=vocab_note)
+ # vocab_note.write(entry['glossary-first'])
+ # print("##### Other Definitions", file=vocab_note)
+ # print(entry['glossary-plain-no-dictionary'], file=vocab_note)
+ # print(f"[[{vocab_hash}|{vocab}]] : {dump[cd]["glossary_Desc_J"][vocab]}", file=card_note)
#print('>' + dump[cd]["glossary_Desc_J"][vocab], file=card_note)
card_note.write("\n")