import Yomikun from "../api/yomikun.ts"; import DirectCoreClient from "../core/direct/client.ts"; // Create a direct (local) API instance var api = new Yomikun(new DirectCoreClient()); // Explicitly wait until everything is ready (not required) await api.ready; // Substitute user to gert (from default login root) api.su("gert"); // Lookup sentence var sentence = await api.sentence("浮上したハイラル城の下にてゼルダ様達の捜索を行うこととなった"); // Freeze disables automatic updating of words after database mutations. It's // used here because there are multiple sequential updates to the database. sentence.freeze(); // Ignore some expressions in JMdict (ignore applies to current user = gert in // this case) sentence.words.find(w => w.written("達") && w.read("だち"))?.ignore(); // wrong reading for this case sentence.at("の下に").ignore(); // expression のもとに sentence.at("下に").ignore(); // expression したに // TODO: 達(だち) should not have to be ignored, but scored lower following // rendaku rules. // Unfreeze allows updates again and implicitly calls .update() sentence.unfreeze(); // Get new reading for sentence var furigana = sentence.furigana(); console.log(furigana);