Skip to content

Api

Dictionary + tokenizer API helpers.

Functions

apiDictQuery()

function apiDictQuery(word, wildcard?): Promise<KotobaseData>;

Defined in: src/shared/dict/api.ts:51

Looks up dictionary data for a word or wildcard pattern.

Parameters

Parameter Type Default value Description
word string undefined The word or wildcard pattern.
wildcard? boolean false Treat word as a wildcard pattern.

Returns

Promise\<KotobaseData>

The lookup result.


apiTokenize()

function apiTokenize(sentence, mode?): Promise<JapaneseWord[]>;

Defined in: src/shared/dict/api.ts:16

Tokenizes a sentence on the server, returning one stitched JapaneseWord per word (no dictionary data).

Parameters

Parameter Type Default value Description
sentence string undefined The Japanese sentence.
mode? BundleMode "grammar" How aggressively to group tokens.

Returns

Promise\<JapaneseWord[]>

The stitched words.


apiTokenizeBatch()

function apiTokenizeBatch(sentences, mode?): Promise<JapaneseWord[][]>;

Defined in: src/shared/dict/api.ts:34

Tokenizes many sentences in one request (used to pre-tokenize a whole subtitle file).

Parameters

Parameter Type Default value Description
sentences string[] undefined The sentences, in order.
mode? BundleMode "grammar" How aggressively to group tokens.

Returns

Promise\<JapaneseWord[][]>

One word list per input sentence.


isEmptyDict()

function isEmptyDict(data): boolean;

Defined in: src/shared/dict/api.ts:62

Whether a dictionary lookup found nothing (every result list empty).

Parameters

Parameter Type Description
data KotobaseData The lookup result.

Returns

boolean

true when empty.