辭典

dictionaries 옵션에 DictionarySource 客體의 配列을 넘깁니다. 辭典은 順序대로 探索됩니다; 처음 一致한 것이 採擇됩니다.

標準國語大辭典 패키지

@gukhanmun/stdict-fst@gukhanmun/stdict-cdb는 둘 다 內藏 《標準國語大辭典》을 各各 다른 바이너리 形式으로 提供합니다.

import { 
function load(options?: GukhanmunOptions): Promise<Gukhanmun>

Creates a Gukhanmun converter with the given options.

Initialises the WASM module on the first call (subsequent calls reuse the cached module). Dictionaries supplied via GukhanmunOptions.dictionaries are fetched and passed to the Rust engine as FileDictionarySource values.

Note: unlike the Rust ko-kr preset, the JavaScript preset never includes a bundled dictionary. Pass dictionaries: [await stdictFst()] to include the Standard Korean Language Dictionary.

@paramoptions - Conversion options. All fields are optional; defaults match the ko-kr preset.@returnsA Gukhanmun instance.@throws{@linkGukhanmunError } on invalid options or dictionary load failure.
load
} from "@gukhanmun/wasm";
import {
function stdictFst(): Promise<FileDictionarySource>

Loads the bundled Standard Korean Language Dictionary as a

FileDictionarySource ready to pass to load({ dictionaries: [...] }).

@returnsA FileDictionarySource with format: "fst".
stdictFst
} from "@gukhanmun/stdict-fst";
import {
function stdictCdb(): Promise<FileDictionarySource>

Loads the bundled Standard Korean Language Dictionary as a

FileDictionarySource ready to pass to load({ dictionaries: [...] }).

@returnsA FileDictionarySource with format: "cdb".
stdictCdb
} from "@gukhanmun/stdict-cdb";
// FST: 勸奬; 디스크에서 더 작고, 라티스 分割에 더 適合 const
const g: Gukhanmun
g
= await
function load(options?: GukhanmunOptions): Promise<Gukhanmun>

Creates a Gukhanmun converter with the given options.

Initialises the WASM module on the first call (subsequent calls reuse the cached module). Dictionaries supplied via GukhanmunOptions.dictionaries are fetched and passed to the Rust engine as FileDictionarySource values.

Note: unlike the Rust ko-kr preset, the JavaScript preset never includes a bundled dictionary. Pass dictionaries: [await stdictFst()] to include the Standard Korean Language Dictionary.

@paramoptions - Conversion options. All fields are optional; defaults match the ko-kr preset.@returnsA Gukhanmun instance.@throws{@linkGukhanmunError } on invalid options or dictionary load failure.
load
({
GukhanmunOptions.dictionaries?: readonly FileDictionarySource[] | undefined

Ordered list of dictionary sources. Sources are queried in order; earlier entries take precedence. When omitted (or empty), only the fallback Unihan character map is used (no stdict).

Unlike the "ko-kr" Rust preset, JavaScript presets do not automatically include a bundled dictionary. To use the Standard Korean Language Dictionary, add @gukhanmun/stdict-fst or @gukhanmun/stdict-cdb explicitly.

@seeDictionarySource
dictionaries
: [await
function stdictFst(): Promise<FileDictionarySource>

Loads the bundled Standard Korean Language Dictionary as a

FileDictionarySource ready to pass to load({ dictionaries: [...] }).

@returnsA FileDictionarySource with format: "fst".
stdictFst
()] });
// CDB: O(1) 찾기; 더 單純한 配置 const
const g: Gukhanmun
g
= await
function load(options?: GukhanmunOptions): Promise<Gukhanmun>

Creates a Gukhanmun converter with the given options.

Initialises the WASM module on the first call (subsequent calls reuse the cached module). Dictionaries supplied via GukhanmunOptions.dictionaries are fetched and passed to the Rust engine as FileDictionarySource values.

Note: unlike the Rust ko-kr preset, the JavaScript preset never includes a bundled dictionary. Pass dictionaries: [await stdictFst()] to include the Standard Korean Language Dictionary.

@paramoptions - Conversion options. All fields are optional; defaults match the ko-kr preset.@returnsA Gukhanmun instance.@throws{@linkGukhanmunError } on invalid options or dictionary load failure.
load
({
GukhanmunOptions.dictionaries?: readonly FileDictionarySource[] | undefined

Ordered list of dictionary sources. Sources are queried in order; earlier entries take precedence. When omitted (or empty), only the fallback Unihan character map is used (no stdict).

Unlike the "ko-kr" Rust preset, JavaScript presets do not automatically include a bundled dictionary. To use the Standard Korean Language Dictionary, add @gukhanmun/stdict-fst or @gukhanmun/stdict-cdb explicitly.

@seeDictionarySource
dictionaries
: [await
function stdictCdb(): Promise<FileDictionarySource>

Loads the bundled Standard Korean Language Dictionary as a

FileDictionarySource ready to pass to load({ dictionaries: [...] }).

@returnsA FileDictionarySource with format: "cdb".
stdictCdb
()] });

stdictFst()stdictCdb()는 모두 Promise<FileDictionarySource>를 返還합니다.

使用者 定義 辭典

FileDictionarySource는 바이너리 形式과 불러올 데이터를 指定합니다:

interface FileDictionarySource {
  
FileDictionarySource.format: "fst" | "cdb"
format
: "fst" | "cdb";
FileDictionarySource.data: string | ArrayBuffer | ArrayBufferView<ArrayBufferLike> | URL
data
: ArrayBuffer |
interface ArrayBufferView<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike>
ArrayBufferView
| URL | string;
}

data 필드는 다음을 받습니다:

種類位置備考
ArrayBuffer/ArrayBufferView모든 環境이미 메모리에 있는 바이트
URL모든 環境遠隔 또는 로컬 URL; fetch()로 불러옴
stringNode.js, Deno, Bun파일시스템 經路

URL에서 불러오기

const 
const g: Gukhanmun
g
= await
function load(options?: GukhanmunOptions): Promise<Gukhanmun>

Creates a Gukhanmun converter with the given options.

Initialises the WASM module on the first call (subsequent calls reuse the cached module). Dictionaries supplied via GukhanmunOptions.dictionaries are fetched and passed to the Rust engine as FileDictionarySource values.

Note: unlike the Rust ko-kr preset, the JavaScript preset never includes a bundled dictionary. Pass dictionaries: [await stdictFst()] to include the Standard Korean Language Dictionary.

@paramoptions - Conversion options. All fields are optional; defaults match the ko-kr preset.@returnsA Gukhanmun instance.@throws{@linkGukhanmunError } on invalid options or dictionary load failure.
load
({
GukhanmunOptions.dictionaries?: readonly FileDictionarySource[] | undefined

Ordered list of dictionary sources. Sources are queried in order; earlier entries take precedence. When omitted (or empty), only the fallback Unihan character map is used (no stdict).

Unlike the "ko-kr" Rust preset, JavaScript presets do not automatically include a bundled dictionary. To use the Standard Korean Language Dictionary, add @gukhanmun/stdict-fst or @gukhanmun/stdict-cdb explicitly.

@seeDictionarySource
dictionaries
: [{
FileDictionarySource.format: "fst" | "cdb"

The on-disk format of the dictionary file.

  • "fst" — Gukhanmun FST file (*.gukfst); preferred for small WebAssembly bundles. Supported in all runtimes.
  • "cdb" — Gukhanmun CDB-trie file (*.gukcdb); preferred when code auditability or trivial mmap support matters. Requires a filesystem or in-memory bytes; supported in Node-API and (with from_bytes) in WASM builds that include the cdb feature.

The "tsv" format is reserved for future use; passing it throws GukhanmunError with code "unsupported-content-type".

format
: "fst",
FileDictionarySource.data: string | URL | ArrayBuffer | ArrayBufferView<ArrayBufferLike>

The binary dictionary data or a reference to where it can be loaded.

Pass a BufferSource for data already in memory, a URL for a remote or local URL (resolved via fetch or readFile), or a path string for filesystem paths (Node.js / Deno 2.0+ / Bun only).

data
: new
var URL: new (url: string | URL, base?: string | URL) => URL

The URL interface is used to parse, construct, normalize, and encode URLs. It works by providing properties which allow you to easily read and modify the components of a URL.

MDN Reference

URL class is a global reference for import { URL } from 'url' https://nodejs.org/api/url.html#the-whatwg-url-api

@sincev10 .0.0
URL
("./legal.gukfst", import.meta.
ImportMeta.url: string

The absolute file: URL of the module.

This is defined exactly the same as it is in browsers providing the URL of the current module file.

This enables useful patterns such as relative file loading:

import { readFileSync } from 'node:fs';
const buffer = readFileSync(new URL('./data.proto', import.meta.url));
url
),
}], });

브라우저에서는 URL이 fetch()로 가져와집니다. Node.js·Deno·Bun에서는 file:// URL이 디스크에서 읽힙니다.

바이트에서 불러오기

const 
const response: Response
response
= await
function fetch(input: string | URL | Request, init?: RequestInit): Promise<Response> (+1 overload)
fetch
("/custom.gukcdb");
const
const buf: ArrayBuffer
buf
= await
const response: Response
response
.
Body.arrayBuffer(): Promise<ArrayBuffer>
arrayBuffer
();
const
const g: Gukhanmun
g
= await
function load(options?: GukhanmunOptions): Promise<Gukhanmun>

Creates a Gukhanmun converter with the given options.

Initialises the WASM module on the first call (subsequent calls reuse the cached module). Dictionaries supplied via GukhanmunOptions.dictionaries are fetched and passed to the Rust engine as FileDictionarySource values.

Note: unlike the Rust ko-kr preset, the JavaScript preset never includes a bundled dictionary. Pass dictionaries: [await stdictFst()] to include the Standard Korean Language Dictionary.

@paramoptions - Conversion options. All fields are optional; defaults match the ko-kr preset.@returnsA Gukhanmun instance.@throws{@linkGukhanmunError } on invalid options or dictionary load failure.
load
({
GukhanmunOptions.dictionaries?: readonly FileDictionarySource[] | undefined

Ordered list of dictionary sources. Sources are queried in order; earlier entries take precedence. When omitted (or empty), only the fallback Unihan character map is used (no stdict).

Unlike the "ko-kr" Rust preset, JavaScript presets do not automatically include a bundled dictionary. To use the Standard Korean Language Dictionary, add @gukhanmun/stdict-fst or @gukhanmun/stdict-cdb explicitly.

@seeDictionarySource
dictionaries
: [{
FileDictionarySource.format: "cdb" | "fst"

The on-disk format of the dictionary file.

  • "fst" — Gukhanmun FST file (*.gukfst); preferred for small WebAssembly bundles. Supported in all runtimes.
  • "cdb" — Gukhanmun CDB-trie file (*.gukcdb); preferred when code auditability or trivial mmap support matters. Requires a filesystem or in-memory bytes; supported in Node-API and (with from_bytes) in WASM builds that include the cdb feature.

The "tsv" format is reserved for future use; passing it throws GukhanmunError with code "unsupported-content-type".

format
: "cdb",
FileDictionarySource.data: string | URL | ArrayBuffer | ArrayBufferView<ArrayBufferLike>

The binary dictionary data or a reference to where it can be loaded.

Pass a BufferSource for data already in memory, a URL for a remote or local URL (resolved via fetch or readFile), or a path string for filesystem paths (Node.js / Deno 2.0+ / Bun only).

data
:
const buf: ArrayBuffer
buf
}],
});

파일 經路에서 불러오기(Node.js/Deno/Bun)

const 
const g: Gukhanmun
g
= await
function load(options?: GukhanmunOptions): Promise<Gukhanmun>

Creates a Gukhanmun converter with the given options.

The native addon is synchronously ready; dictionaries supplied via GukhanmunOptions.dictionaries are fetched or read from disk and passed to the Rust engine as FileDictionarySource values.

Note: unlike the Rust ko-kr preset, the JavaScript preset never includes a bundled dictionary. Pass dictionaries: [await stdictFst()] to include the Standard Korean Language Dictionary.

@paramoptions - Conversion options. All fields are optional; defaults match the ko-kr preset.@returnsA Gukhanmun instance.@throws{@linkGukhanmunError } on invalid options or dictionary load failure.
load
({
GukhanmunOptions.dictionaries?: readonly FileDictionarySource[] | undefined

Ordered list of dictionary sources. Sources are queried in order; earlier entries take precedence. When omitted (or empty), only the fallback Unihan character map is used (no stdict).

Unlike the "ko-kr" Rust preset, JavaScript presets do not automatically include a bundled dictionary. To use the Standard Korean Language Dictionary, add @gukhanmun/stdict-fst or @gukhanmun/stdict-cdb explicitly.

@seeDictionarySource
dictionaries
: [{
FileDictionarySource.format: "fst" | "cdb"

The on-disk format of the dictionary file.

  • "fst" — Gukhanmun FST file (*.gukfst); preferred for small WebAssembly bundles. Supported in all runtimes.
  • "cdb" — Gukhanmun CDB-trie file (*.gukcdb); preferred when code auditability or trivial mmap support matters. Requires a filesystem or in-memory bytes; supported in Node-API and (with from_bytes) in WASM builds that include the cdb feature.

The "tsv" format is reserved for future use; passing it throws GukhanmunError with code "unsupported-content-type".

format
: "fst",
FileDictionarySource.data: string | ArrayBuffer | ArrayBufferView<ArrayBufferLike> | URL

The binary dictionary data or a reference to where it can be loaded.

Pass a BufferSource for data already in memory, a URL for a remote or local URL (resolved via fetch or readFile), or a path string for filesystem paths (Node.js / Deno 2.0+ / Bun only).

data
: "/data/domain.gukfst" }],
});

브라우저에서 純粹 文字列 經路를 넘기면 "io" 코드와 함께 GukhanmunError를 던집니다.

여러 辭典 結合

const 
const g: Gukhanmun
g
= await
function load(options?: GukhanmunOptions): Promise<Gukhanmun>

Creates a Gukhanmun converter with the given options.

The native addon is synchronously ready; dictionaries supplied via GukhanmunOptions.dictionaries are fetched or read from disk and passed to the Rust engine as FileDictionarySource values.

Note: unlike the Rust ko-kr preset, the JavaScript preset never includes a bundled dictionary. Pass dictionaries: [await stdictFst()] to include the Standard Korean Language Dictionary.

@paramoptions - Conversion options. All fields are optional; defaults match the ko-kr preset.@returnsA Gukhanmun instance.@throws{@linkGukhanmunError } on invalid options or dictionary load failure.
load
({
GukhanmunOptions.dictionaries?: readonly FileDictionarySource[] | undefined

Ordered list of dictionary sources. Sources are queried in order; earlier entries take precedence. When omitted (or empty), only the fallback Unihan character map is used (no stdict).

Unlike the "ko-kr" Rust preset, JavaScript presets do not automatically include a bundled dictionary. To use the Standard Korean Language Dictionary, add @gukhanmun/stdict-fst or @gukhanmun/stdict-cdb explicitly.

@seeDictionarySource
dictionaries
: [
{
FileDictionarySource.format: "fst" | "cdb"

The on-disk format of the dictionary file.

  • "fst" — Gukhanmun FST file (*.gukfst); preferred for small WebAssembly bundles. Supported in all runtimes.
  • "cdb" — Gukhanmun CDB-trie file (*.gukcdb); preferred when code auditability or trivial mmap support matters. Requires a filesystem or in-memory bytes; supported in Node-API and (with from_bytes) in WASM builds that include the cdb feature.

The "tsv" format is reserved for future use; passing it throws GukhanmunError with code "unsupported-content-type".

format
: "fst",
FileDictionarySource.data: string | ArrayBuffer | ArrayBufferView<ArrayBufferLike> | URL

The binary dictionary data or a reference to where it can be loaded.

Pass a BufferSource for data already in memory, a URL for a remote or local URL (resolved via fetch or readFile), or a path string for filesystem paths (Node.js / Deno 2.0+ / Bun only).

data
: "/data/legal.gukfst" }, // 먼저 檢査
await
function stdictFst(): Promise<FileDictionarySource>

Loads the bundled Standard Korean Language Dictionary as a

FileDictionarySource ready to pass to load({ dictionaries: [...] }).

@returnsA FileDictionarySource with format: "fst".
stdictFst
(), // fallback
], });

使用者 定義 辭典 構築

위에서 불러온 .gukfst.gukcdb 파일은 컴파일된 産出物이며, gukhanmun-mkdict 道具로 純粹 텍스트 表에서 빌드됩니다. 辭典 出處를 作成하고 컴파일하는 方法은 CLI 案內書의 〈使用者 定義 辭典 構築〉을 參照하십시오.