リファレンス
文の難しさ
import { … } from "@johnmorrisdotca/hikidashi/difficulty";
最小化と gzip 圧縮をしたサイズは 0.3 kB(読み込むものをすべて含み、esbuild で計測)
リファレンスの説明と例は英語です。見出しと目次は日本語です。
難しさ: how hard an example sentence is to read, so the easiest one can lead.
A character like 水 appears in thousands of example sentences, and showing whichever one a database returned first hands a first-grader a sentence built from rare name kanji. Score each sentence once (when it is added, say) and the query is a plain sort.
Two things make a sentence hard: how long it is, and the hardest character in it. Length is the honest baseline, since a short sentence is readable even when every word is new, and the hardest kanji dominates, because one unknown character stops a learner as surely as ten do.
What a kanji costs comes from the school grade or the frequency rank you hold for it (KANJIDIC2 has both). The package carries no table of its own.
エクスポート
| 名前 | 種類 | 概要 |
|---|---|---|
kanjiCost | 関数 | The cost of one kanji. |
KanjiDifficultySource | 型 | What your dictionary knows about a kanji, which kanjiCost turns into a cost. |
kanjiIn | 関数 | Every kanji in the text, once each, in the order they appear. |
sentenceDifficulty | 関数 | The sentence's score, lowest first: its length in characters plus three times its hardest kanji. |
UNKNOWN_KANJI_COST | 定数 | What a kanji costs when nothing is known about it: 20, the most any kanji costs. |
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。