Skip to the content

Hikidashi引き出し

Era dates (和暦) and kanji numerals both ways, the dictionary forms of a conjugated word, a reading shared out over its kanji, words pulled from pasted text, and how hard a sentence is to read.

Hikidashi (引き出し) is a drawer: each tool is pulled out when it is wanted. About the name

Contents

Reference · Sentence difficulty

sentenceDifficultyfunction

The sentence's score, lowest first: its length in characters plus three times its hardest kanji.

Kana-only sentences score their length alone, which puts them at the top where they belong: a beginner can read every one of them. A kanji missing from costs counts as the hardest kind.

Import it

import { sentenceDifficulty } from "@johnmorrisdotca/hikidashi/difficulty";

Also exported from: @johnmorrisdotca/hikidashi

Definition

function sentenceDifficulty(text: string, costs: ReadonlyMap<string, number>): number

Parameters

NameTypeDescription
textstring

The sentence.

costsReadonlyMap<string, number>

Each kanji's cost, from kanjiCost, as a Map; a kanji not in it costs UNKNOWN_KANJI_COST.

Returns

number

The score: the number of characters plus three times the cost of the hardest kanji. Lower is easier.

Examples

import { kanjiCost, sentenceDifficulty } from "@johnmorrisdotca/hikidashi/difficulty";

const costs = new Map([["水", kanjiCost({ grade: 1, frequencyRank: 223 })], ["飲", kanjiCost({ grade: 3, frequencyRank: 969 })]]);
console.log(sentenceDifficulty("みずをのむ。", costs), sentenceDifficulty("水を飲む。", costs), sentenceDifficulty("麒麟を見た。", costs));
6 14 66

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/hikidashi 1.1.0.