diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-07-13 16:39:01 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-07-13 16:39:01 +0200 |
commit | 28fb362147358819afeb0f0a5fa7a4ad136499ac (patch) | |
tree | 4c4224f503f66fcea1e25b464daf0f9659a09bab /examples | |
parent | 919cdce6bcf12f564901ea536dae4227d025b031 (diff) |
ignore terms
Diffstat (limited to 'examples')
-rw-r--r-- | examples/reading-correction-break.ts | 2 | ||||
-rw-r--r-- | examples/user-ignore.ts | 20 |
2 files changed, 12 insertions, 10 deletions
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. <https://en.wikipedia.org/wiki/Rendaku> // 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()); |