本文へ移動

Hikidashi引き出し

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

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

目次

リファレンス · 貼り付けた文

extractFromText関数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

The words and kanji a paste comes to: the words known lists, longest match first, and every kanji in the text.

Both, rather than one or the other. A handout of vocabulary is wanted as words; the same handout is also the kanji a learner has to write, and which of the two somebody meant is not for this to decide. Show the result first, and let them take out what they did not want.

インポート

import { extractFromText } from "@johnmorrisdotca/hikidashi/extract";

ほかのエクスポート元: @johnmorrisdotca/hikidashi

定義

function extractFromText({ text, known }: ExtractInput): ExtractResult

引数

名前型説明
inputExtractInput

The text, and known, the words your dictionary confirmed (a Map from word to its kinds).

戻り値

ExtractResult

The words known lists, in dictionary form and in the order they first appear, every kanji in the text, and counts of what the paste held. With no known, words is empty.

例

import type { WordClass } from "@johnmorrisdotca/hikidashi/deinflect";
import { extractFromText } from "@johnmorrisdotca/hikidashi/extract";

const known = new Map<string, WordClass[]>([["先生", []], ["学校", []], ["行く", ["godan"]], ["行き", []]]);
console.log(extractFromText({ text: "先生と学校へ行きます", known }).words);
console.log(extractFromText({ text: "東京行きの電車", known }).words);
[ '先生', '学校', '行く' ]
[ '行き' ]

出力(このページを作ったときに実行した結果)

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

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