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

Everything

import { … } from "@johnmorrisdotca/hikidashi";

6.4 kB minified and gzipped, with everything it imports (measured with esbuild)

Hikidashi 引き出し: a drawer of small Japanese text tools. 和暦 era years and dates both ways; kanji numerals both ways, read aloud and in formal 大字; the dictionary forms a conjugated verb or adjective could come from; a word's reading shared out over its kanji, and a かん字テスト made from it; Japanese words and kanji pulled out of pasted text; and how hard a sentence is to read. Pure functions, no dictionary or data of their own, and no dependencies. Each drawer is also an entry of its own, so a page imports only the one it needs: @johnmorrisdotca/hikidashi/wareki, /numerals, /deinflect, /align, /extract and /difficulty.

Exports

NameKindWhat it is
ALIGN_LIMITSconstantWhat segmentWord will work on: a word of up to 64 characters and a reading of up to 256.
buildKanjiTestfunctionThe test: words to write in kanji, then different words to read.
DeinflectiontypeOne answer of dictionaryForms: a dictionary form the written word could come from, and the kind of word it would have to be for that to be true.
dictionaryFormsfunctionEvery dictionary form written could be a conjugation of, with the kind of word it would have to be.
eraOnDatefunctionThe era year a day is in, from YYYY-MM-DD or a Date.
EraYeartypeAn era year that parsed or was found, and the Western year it names: what parseEraYear, eraYearOf, eraYearsOf and eraOnDate give.
eraYearOffunctionThe era year a Western year is usually written as: the newest era's, so 1989 is 平成1 and 2019 is 令和1.
eraYearsOffunctionEvery era year that falls in a Western year, the newest era first.
EXTRACT_LIMITSconstantWhat a paste is held to: read to 20,000 characters and then cut, words of up to 8 characters, and at most 4,000 candidates asked of a dictionary.
extractFromTextfunctionThe words and kanji a paste comes to: the words known lists, longest match first, and every kanji in the text.
ExtractInputtypeWhat to read, and the dictionary to read it against: the argument of extractFromText.
ExtractResulttypeThe words found, then the kanji, each once, in the order they first appear; and what the paste held.
followsAsVerbStemfunctionWhether following opens with an ending that only a verb's stem takes (ます, ました, ません, ましょう, まして, たい, なさい), so that the word before it is being written as a stem.
formatEraYearJapanesefunctionThe era year as it is written in Japanese: 平成3年.
formatEraYearRomajifunctionThe era year as it is written in Latin letters: Heisei 3.
hiraganaToKatakanafunctionHiragana written as katakana: ひらがな to ヒラガナ.
JAPANESE_ERASconstantThe five modern eras, oldest first: 明治, 大正, 昭和, 平成 and 令和.
JapaneseEratypeAn era, as it is written, said and counted: one row of JAPANESE_ERAS.
kanjiAsWordfunctionA kanji on its own, as a word a test can ask.
kanjiCostfunctionThe cost of one kanji.
KanjiDifficultySourcetypeWhat your dictionary knows about a kanji, which kanjiCost turns into a cost.
kanjiInfunctionEvery kanji in the text, once each, in the order they appear.
KanjiTesttypeA test: words to write in kanji from their readings, then different words to read.
KanjiTestQuestiontypeOne question of a test: the word, its reading, and the word cut into its segments, ready to be drawn as squares with the okurigana in brackets.
katakanaToHiraganafunctionKatakana written as hiragana: カタカナ to かたかな.
KnownWordstypeThe words your dictionary confirmed, each with the kinds of word it is.
LARGEST_JAPANESE_NUMBERconstantThe largest number this module will answer for: 9,007,199,254,740,991, JavaScript's largest safe integer.
LONGEST_ENDINGconstantThe longest ending, in characters, that any rule strips, so a caller matching words in running text knows how far past a dictionary word to look for its conjugation.
parseEnglishNumberfunctionThe value of a number written in words, or null when it is not one.
parseEraYearfunctionThe era year a text names, or null when it does not name one.
parseJapaneseNumberfunctionThe value of a number written in Japanese, or null when it is not one.
readJapaneseNumberfunctionThe number said aloud, in hiragana, with the sound changes a learner has to know: 300 is さんびゃく, 600 ろっぴゃく, 800 はっぴゃく, 3,000 さんぜん, 8,000 はっせん, and 一兆 いっちょう.
ReadWordtypeA word and its reading in hiragana: what buildKanjiTest takes a list of, and what kanjiAsWord makes.
sanitizePastedTextfunctionThe text as it will be read: control and invisible characters (and line and paragraph separators) turned into spaces, then cut to EXTRACT_LIMITS.characters.
SEGMENT_KINDSconstantWhat a run of a word is: kanji with their part of the reading, kana inside the word, or the kana that end it (okurigana).
SegmentKindtypeOne kind of run: "kanji", "kana" or "okurigana", the values of SEGMENT_KINDS.
segmentWordfunctionA word cut into its kanji and its kana, each kanji run with its share of the reading.
sentenceDifficultyfunctionThe sentence's score, lowest first: its length in characters plus three times its hardest kanji.
UNKNOWN_KANJI_COSTconstantWhat a kanji costs when nothing is known about it: 20, the most any kanji costs.
VERSIONconstantThe package's version, the same as its package.json.
westernYearForfunctionThe Western year an era year falls in, or null when the era never had that year.
WORD_CLASSESconstantThe kinds of word a conjugated form can come from, each named by itself: godan and ichidan verbs, iAdjective, and the two irregular verbs suru (する) and kuru (来る).
wordCandidatesfunctionEvery substring the dictionary might know, so one question can be asked about the whole paste: look all of them up at once, and pass the ones found as known.
WordClasstypeOne kind of word: "godan", "ichidan", "iAdjective", "suru" or "kuru", the values of WORD_CLASSES.
wordClassesOffunctionThe kinds of word a dictionary entry is, from the parts of speech it lists, so a conjugated form is only taken for a verb or an adjective the dictionary says is one.
WordSegmenttypeOne run of a word, and its share of the reading in hiragana: what segmentWord cuts a word into.
writeJapaneseNumberfunctionThe number as Japanese writes it, in kanji.

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