本文へ移動

Hikidashi引き出し

和暦と漢数字の相互変換、活用した語の辞書形、漢字への読みの割り当て、貼り付けた文からの単語の抽出、文の難しさ。日本語のテキストを扱う小さな道具を集めた引き出しです。

「引き出し」という名前は、道具が一つずつしまってあり、必要なときに取り出して使える、という意味です。 名前について(英語)

目次

リファレンス

すべて

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

最小化と gzip 圧縮をしたサイズは 6.4 kB(読み込むものをすべて含み、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.

エクスポート

名前種類概要
ALIGN_LIMITS定数What segmentWord will work on: a word of up to 64 characters and a reading of up to 256.
buildKanjiTest関数The test: words to write in kanji, then different words to read.
Deinflection型One 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.
dictionaryForms関数Every dictionary form written could be a conjugation of, with the kind of word it would have to be.
eraOnDate関数The era year a day is in, from YYYY-MM-DD or a Date.
EraYear型An era year that parsed or was found, and the Western year it names: what parseEraYear, eraYearOf, eraYearsOf and eraOnDate give.
eraYearOf関数The era year a Western year is usually written as: the newest era's, so 1989 is 平成1 and 2019 is 令和1.
eraYearsOf関数Every era year that falls in a Western year, the newest era first.
EXTRACT_LIMITS定数What 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.
extractFromText関数The words and kanji a paste comes to: the words known lists, longest match first, and every kanji in the text.
ExtractInput型What to read, and the dictionary to read it against: the argument of extractFromText.
ExtractResult型The words found, then the kanji, each once, in the order they first appear; and what the paste held.
followsAsVerbStem関数Whether following opens with an ending that only a verb's stem takes (ます, ました, ません, ましょう, まして, たい, なさい), so that the word before it is being written as a stem.
formatEraYearJapanese関数The era year as it is written in Japanese: 平成3年.
formatEraYearRomaji関数The era year as it is written in Latin letters: Heisei 3.
hiraganaToKatakana関数Hiragana written as katakana: ひらがな to ヒラガナ.
JAPANESE_ERAS定数The five modern eras, oldest first: 明治, 大正, 昭和, 平成 and 令和.
JapaneseEra型An era, as it is written, said and counted: one row of JAPANESE_ERAS.
kanjiAsWord関数A kanji on its own, as a word a test can ask.
kanjiCost関数The cost of one kanji.
KanjiDifficultySource型What your dictionary knows about a kanji, which kanjiCost turns into a cost.
kanjiIn関数Every kanji in the text, once each, in the order they appear.
KanjiTest型A test: words to write in kanji from their readings, then different words to read.
KanjiTestQuestion型One 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.
katakanaToHiragana関数Katakana written as hiragana: カタカナ to かたかな.
KnownWords型The words your dictionary confirmed, each with the kinds of word it is.
LARGEST_JAPANESE_NUMBER定数The largest number this module will answer for: 9,007,199,254,740,991, JavaScript's largest safe integer.
LONGEST_ENDING定数The 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.
parseEnglishNumber関数The value of a number written in words, or null when it is not one.
parseEraYear関数The era year a text names, or null when it does not name one.
parseJapaneseNumber関数The value of a number written in Japanese, or null when it is not one.
readJapaneseNumber関数The number said aloud, in hiragana, with the sound changes a learner has to know: 300 is さんびゃく, 600 ろっぴゃく, 800 はっぴゃく, 3,000 さんぜん, 8,000 はっせん, and 一兆 いっちょう.
ReadWord型A word and its reading in hiragana: what buildKanjiTest takes a list of, and what kanjiAsWord makes.
sanitizePastedText関数The 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_KINDS定数What a run of a word is: kanji with their part of the reading, kana inside the word, or the kana that end it (okurigana).
SegmentKind型One kind of run: "kanji", "kana" or "okurigana", the values of SEGMENT_KINDS.
segmentWord関数A word cut into its kanji and its kana, each kanji run with its share of the reading.
sentenceDifficulty関数The sentence's score, lowest first: its length in characters plus three times its hardest kanji.
UNKNOWN_KANJI_COST定数What a kanji costs when nothing is known about it: 20, the most any kanji costs.
VERSION定数The package's version, the same as its package.json.
westernYearFor関数The Western year an era year falls in, or null when the era never had that year.
WORD_CLASSES定数The 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 (来る).
wordCandidates関数Every 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.
WordClass型One kind of word: "godan", "ichidan", "iAdjective", "suru" or "kuru", the values of WORD_CLASSES.
wordClassesOf関数The 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.
WordSegment型One run of a word, and its share of the reading in hiragana: what segmentWord cuts a word into.
writeJapaneseNumber関数The number as Japanese writes it, in kanji.

ソースを見るGitHub で編集@johnmorrisdotca/hikidashi 1.1.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。