Skip to the content

Hikidashi引き出し

Era dates (和暦) and kanji numerals both ways, the dictionary forms of a conjugated word, a reading shared out over its kanji, words pulled from pasted text, and how hard a sentence is to read.

Hikidashi (引き出し) is a drawer: each tool is pulled out when it is wanted. About the name

Contents

Reference · Reading alignment

segmentWordfunction

A word cut into its kanji and its kana, each kanji run with its share of the reading.

The kana a word is written with are anchors in its reading: 形が合う read かたちがあう is 形 かたち, が, 合 あ, う. Kana that end a word after its kanji are its okurigana, which the writing half asks for in brackets. A katakana reading, or katakana in the word, reads the same as hiragana. A compound of several kanji (絵日記, えにっき) is one segment, since a reading cannot be split between kanji without a dictionary.

Import it

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

Also exported from: @johnmorrisdotca/hikidashi

Definition

function segmentWord(word: string, reading: string): WordSegment[] | null

Parameters

NameTypeDescription
wordstring

The word as it is written, such as 食べる or 形が合う.

readingstring

Its reading in hiragana or katakana, such as たべる.

Returns

WordSegment[] | null

The word's runs left to right, each with its share of the reading; null when the reading does not fit the word (so that a test can leave the word out rather than mark a wrong answer right), and for a word with no kanji, a reading with a space or control character in it, or a word or reading longer than ALIGN_LIMITS.

Examples

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

console.log(segmentWord("形が合う", "かたちがあう")?.map((part) => `${part.text}:${part.reading}:${part.kind}`));
console.log(segmentWord("絵日記", "エニッキ"), segmentWord("食べる", "のむ"));
[ '形:かたち:kanji', 'が:が:kana', '合:あ:kanji', 'う:う:okurigana' ]
[ { text: '絵日記', reading: 'えにっき', kind: 'kanji' } ] null

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/hikidashi 1.1.0.