本文へ移動

Hikidashi引き出し

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

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

目次

リファレンス · 読みの割り当て

buildKanjiTest関数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

The test: words to write in kanji, then different words to read.

The seed decides which words and in what order, so the test on paper is the test that was on screen and a link sent to somebody is the same test. Each word is asked once, and a word whose reading does not fit it (segmentWord says null) is left out. A list too short for two halves of different words asks its words both ways rather than leave the second half short.

インポート

import { buildKanjiTest } from "@johnmorrisdotca/hikidashi/align";

ほかのエクスポート元: @johnmorrisdotca/hikidashi

定義

function buildKanjiTest(pool: readonly ReadWord[], { seed, count }: { seed: number; count: number; }): KanjiTest

引数

名前型説明
poolreadonly ReadWord[]

The words to draw from, each with its reading.

options{ seed: number; count: number; }

seed decides which words and in what order; count is how many questions each half has (below one asks nothing).

戻り値

KanjiTest

The writing half and the reading half, each up to count questions; both empty when no word of the pool fits its reading.

例

import { buildKanjiTest } from "@johnmorrisdotca/hikidashi/align";

const pool = [
  { word: "食べる", reading: "たべる" }, { word: "水", reading: "みず" },
  { word: "学校", reading: "がっこう" }, { word: "形が合う", reading: "かたちがあう" },
];
const test = buildKanjiTest(pool, { seed: 7, count: 2 });
console.log(test.writing.map((one) => one.word), test.reading.map((one) => one.word));
console.log(JSON.stringify(buildKanjiTest(pool, { seed: 7, count: 2 })) === JSON.stringify(test));
[ '学校', '水' ] [ '形が合う', '食べる' ]
true

出力(このページを作ったときに実行した結果)

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

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