リファレンス · 読み、表記、英語の意味、漢字、ローマ字から単語を引く
readText関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
Reads a text: it is cut into words by taking, from each place, the longest stretch that the dictionary has a word for, either as
it stands or as a conjugated form (食べなかった is 食べる). Each word comes with its furigana, its meaning, the hardest JLPT level
among its kanji, and each kanji's grade and level; a stretch of Japanese that no word fits is unknown and is listed; spaces,
punctuation, Latin letters and digits are kept as other. Nothing but Jisho's own pieces is fetched, about 25 kB gzipped each, as
the stretches need them (a few for each word), and a piece is kept for the next one, so a text costs the pieces of its words once.
It picks the longest stretch, not the best reading of a sentence: there is no model of grammar, so a rare word that happens to
be longer can win, and a name is unknown or cut into small words. Among equal stretches the commonest word is taken, and the
others are in alternatives. In safe mode a word the mode leaves out is not found, so its text is unknown.
インポート
import { readText } from "@johnmorrisdotca/jisho/words";
定義
function readText(text: string, options?: WordsOptions): Promise<ReadResult>
引数
| 名前 | 型 | 説明 |
|---|---|---|
text | string | Japanese text, up to |
options (省略可) | WordsOptions | The mode, the |
戻り値
Promise<ReadResult>
The pieces, the unknown stretches and the JMdict release.
例
import { readText } from "@johnmorrisdotca/jisho/words";
const result = await readText("私は寿司を食べなかった。");
console.log(result.tokens.map((token) => token.text)); // ["私", "は", "寿司", "を", "食べなかった", "。"][ '私', 'は', '寿司', 'を', '食べなかった', '。' ]出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。