From 28fb362147358819afeb0f0a5fa7a4ad136499ac Mon Sep 17 00:00:00 2001 From: lonkaars Date: Thu, 13 Jul 2023 16:39:01 +0200 Subject: ignore terms --- examples/reading-correction-break.ts | 2 +- examples/user-ignore.ts | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'examples') diff --git a/examples/reading-correction-break.ts b/examples/reading-correction-break.ts index a72e545..3c45d27 100644 --- a/examples/reading-correction-break.ts +++ b/examples/reading-correction-break.ts @@ -14,7 +14,7 @@ var sentence = await api.sentence("やっぱりこの辺にある武器も朽ち console.log(sentence.furigana()); // insert parser break in the middle of a (wrong) expression -await sentence.break(sentence.at("この辺") + 2); +await sentence.break(sentence.indexOf("この辺") + 2); // generated reading (correct) console.log(sentence.furigana()); diff --git a/examples/user-ignore.ts b/examples/user-ignore.ts index d0abbe3..f15baed 100644 --- a/examples/user-ignore.ts +++ b/examples/user-ignore.ts @@ -13,24 +13,26 @@ api.su("gert"); // Lookup sentence var sentence = await api.sentence("浮上したハイラル城の下にてゼルダ様達の捜索を行うこととなった"); +// Get reading for sentence +console.log(sentence.furigana()); + // Freeze disables automatic updating of words after database mutations. It's // used here because there are multiple sequential updates to the database. -sentence.freeze(); +await 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 したに +// this case) (TODO: this only works on a fresh database) +await sentence.words.find(w => w.written("達") && w.read("だち"))?.ignore(); // wrong reading for this case +await sentence.at("の下に")?.ignore(); // expression のもとに +await sentence.forceUpdate(); // manual update to get last wrong term +await 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(); +await sentence.unfreeze(); // Get new reading for sentence -var furigana = sentence.furigana(); - -console.log(furigana); +console.log(sentence.furigana()); -- cgit v1.2.3