Reference · Look words up by reading, written form, English meaning, kanji or romaji
readTextfunction
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 it
import { readText } from "@johnmorrisdotca/jisho/words";
Definition
function readText(text: string, options?: WordsOptions): Promise<ReadResult>
Parameters
| Name | Type | Description |
|---|---|---|
text | string | Japanese text, up to |
options (optional) | WordsOptions | The mode, the |
Returns
Promise<ReadResult>
The pieces, the unknown stretches and the JMdict release.
Examples
import { readText } from "@johnmorrisdotca/jisho/words";
const result = await readText("私は寿司を食べなかった。");
console.log(result.tokens.map((token) => token.text)); // ["私", "は", "寿司", "を", "食べなかった", "。"][ '私', 'は', '寿司', 'を', '食べなかった', '。' ]What it prints (run when this page was built)