リファレンス · 読み、表記、英語の意味、漢字、ローマ字から単語を引く
loadWords関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
Fetches what JMdict holds for some texts, and nothing else: the pieces of the table those texts are in, about 25 kB gzipped each,
so that wordsOf can then answer for them with no waiting.
A text of kana alone (かみ, カミ) is a reading and costs one piece. Any other text (紙) is a written form: its readings are
found first and then their pieces, so it costs one more. Texts already in previous cost nothing. A text is made plain first
(normalizeText), and one that is odd, empty or far too long is nothing to load and never an error. With romaji: true, a text
of Latin letters is read as romaji (kami loads かみ). With inflected: true the dictionary forms a text could be conjugated
from are loaded as well (食べなかった loads 食べる), so that inflectedOf can answer: it costs a few pieces more.
Lookups at the same moment for the same pieces share one fetch. A piece that fails is asked for once more, and then this
rejects with a WordsLoadError that names it; nothing is remembered of a failure, so asking again tries again.
In safe mode, the default, nothing is fetched that holds what safe mode leaves out, and none of it is in what comes back. With
mode: "unfiltered" the pieces of what was left out are fetched as well, one more for each, and the words are everything JMdict
has. The consumer's block and allow lists are laid over either.
インポート
import { loadWords } from "@johnmorrisdotca/jisho/words";
定義
function loadWords(texts: string | readonly string[], options?: LoadWordsOptions): Promise<Words>
引数
| 名前 | 型 | 説明 |
|---|---|---|
texts | string | readonly string[] | A reading or a written form, or a list of them. |
options (省略可) | LoadWordsOptions | The mode, the lists, |
戻り値
Promise<Words>
The words, ready for wordsOf.
例
import { loadWords, wordsOf } from "@johnmorrisdotca/jisho/words";
const words = await loadWords(["かみ", "紙"]);
console.log(wordsOf(words, "かみ").map((one) => one.written)); // ["紙", "神", "髪", ...]
console.log(wordsOf(words, "紙")[0]?.reading); // かみ[
'紙', '神',
'髪', '加味',
'上', '佳味',
'ネ申', '長官',
'守'
]
かみ出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。