本文へ移動

Hikidashi引き出し

和暦と漢数字の相互変換、活用した語の辞書形、漢字への読みの割り当て、貼り付けた文からの単語の抽出、文の難しさ。日本語のテキストを扱う小さな道具を集めた引き出しです。

「引き出し」という名前は、道具が一つずつしまってあり、必要なときに取り出して使える、という意味です。 名前について(英語)

目次

リファレンス

文の難しさ

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.

ソースを見るGitHub で編集@johnmorrisdotca/hikidashi 1.1.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。