Skip to content

Api

Dictionary + tokenizer API helpers.

Functions

apiByRadicals()

function apiByRadicals(radicals, mode?): Promise<KanjiInfo[]>;

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

Finds kanji by their radical components.

Parameters

Parameter Type Default value Description
radicals string[] undefined The radical glyphs.
mode? "all" | "any" "all" Whether a kanji must contain every picked radical or at least one of them.

Returns

Promise\<KanjiInfo[]>

The matching kanji.


apiDictQuery()

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

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

Looks up dictionary data for a word or wildcard pattern. Optional token hints (reading + part of speech, from tokenization) rank matching entries first and let unknown written forms fall back to a lookup by reading.

Parameters

Parameter Type Default value Description
word string undefined The word or wildcard pattern.
wildcard? boolean false Treat word as a wildcard pattern.
hints? { pos?: string; reading?: string; } undefined Token hints, when known.
hints.pos? string undefined -
hints.reading? string undefined -

Returns

Promise\<KotobaseData>

The lookup result.


apiKanji()

function apiKanji(literal): Promise<KanjiInfo>;

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

Fetches the full profile of a single kanji.

Parameters

Parameter Type Description
literal string The kanji character.

Returns

Promise\<KanjiInfo>

The kanji profile.


apiKanjiAudio()

function apiKanjiAudio(literal): Promise<KanjiAudio>;

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

Lists the pronunciation clips available for a kanji (Kanji Alive).

Parameters

Parameter Type Description
literal string The kanji character.

Returns

Promise\<KanjiAudio>

The clip listing (empty without the audio pack).


apiKanjiSentences()

function apiKanjiSentences(literal, limit?): Promise<Example[]>;

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

Lists example sentences that contain a kanji.

Parameters

Parameter Type Default value Description
literal string undefined The kanji character.
limit? number 10 Maximum sentences to return.

Returns

Promise\<Example[]>

The matching sentences with translations.


apiKanjiStrokes()

function apiKanjiStrokes(literal): Promise<string>;

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

Fetches a kanji's stroke-order diagram as an inline-able SVG document (KanjiVG). Rejects with a 404 ApiError when no stroke data exists.

Parameters

Parameter Type Description
literal string The kanji character.

Returns

Promise\<string>

The SVG markup.


apiKanjiWords()

function apiKanjiWords(literal, limit?): Promise<JMEntry[]>;

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

Lists dictionary entries whose written form uses a kanji.

Parameters

Parameter Type Default value Description
literal string undefined The kanji character.
limit? number 50 Maximum entries to return.

Returns

Promise\<JMEntry[]>

The matching entries.


apiRadicals()

function apiRadicals(): Promise<RadicalInfo[]>;

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

Lists every search radical with its stroke count (RADKFILE).

Returns

Promise\<RadicalInfo[]>

All search radicals.


apiResolveRef()

function apiResolveRef(ref): Promise<JMEntry[]>;

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

Resolves a sense cross-reference or antonym code into its entries.

Parameters

Parameter Type Description
ref string The reference code from a sense's xrefs/antonyms.

Returns

Promise\<JMEntry[]>

The referenced entries.


apiSearchEnglish()

function apiSearchEnglish(q, limit?): Promise<JMEntry[]>;

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

Searches dictionary entries by English meaning (reverse lookup).

Parameters

Parameter Type Default value Description
q string undefined The English search text.
limit? number 50 Maximum entries to return.

Returns

Promise\<JMEntry[]>

The matching entries.


apiTokenize()

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

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

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:43

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.


dictAudioClipUrl()

function dictAudioClipUrl(literal, clip): string;

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

Builds the playable URL of one pronunciation clip, for use as an <audio> source (the dictionary endpoints are not profile-scoped).

Parameters

Parameter Type Description
literal string The kanji character the clip belongs to.
clip string The clip id from apiKanjiAudio.

Returns

string

The clip URL.


isEmptyDict()

function isEmptyDict(data): boolean;

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

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

Parameters

Parameter Type Description
data KotobaseData The lookup result.

Returns

boolean

true when empty.