aboutsummaryrefslogtreecommitdiff
path: root/examples/reading-correction-break.ts
blob: a72e545fe19e063d60d245bbd44df39b1d33295b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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;

// index sentence (generates wrong reading for 「この辺に」)
var sentence = await api.sentence("やっぱりこの辺にある武器も朽ちてるみたいだし");

// generated reading (wrong)
console.log(sentence.furigana());

// insert parser break in the middle of a (wrong) expression
await sentence.break(sentence.at("この辺") + 2);

// generated reading (correct)
console.log(sentence.furigana());

// TODO: this is a bad example, find an example that uses adjacent kanji that
// can become a larger compound, but should be two separate words.