本文へ移動

Hikidashi引き出し

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

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

目次

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

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. Capped at EXTRACT_LIMITS.candidates, because a long paste of Japanese has more substrings than anybody needs to look up. Conjugated forms are offered as the dictionary forms they could come from, and a single character is never offered, since that is a kanji.

インポート

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

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

定義

function wordCandidates(text: string): string[]

引数

名前型説明
textstring

The pasted text; it is cleaned and cut as sanitizePastedText does first.

戻り値

string[]

Every run of two or more characters a dictionary might list, and the dictionary forms of conjugated runs, each once, at most EXTRACT_LIMITS.candidates; an empty list for text with no Japanese in it.

例

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

const candidates = wordCandidates("学校へ行きます");
console.log(candidates.includes("学校"), candidates.includes("行く"), candidates.length);
true true 31

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

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

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