#사전
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: 勸奬; 디스크에서 더 작고, 래티스(lattice) 分割에 더 適合
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[] | undefinedOrdered 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 bundled dictionaries).
JavaScript presets do not
automatically include bundled dictionary data. To use the Standard
Korean Language Dictionary, add @gukhanmun/stdict-fst or
@gukhanmun/stdict-cdb explicitly. To use Open Korean Dictionary
categories, add @gukhanmun/opendict-fst or
@gukhanmun/opendict-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[] | undefinedOrdered 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 bundled dictionaries).
JavaScript presets do not
automatically include bundled dictionary data. To use the Standard
Korean Language Dictionary, add @gukhanmun/stdict-fst or
@gukhanmun/stdict-cdb explicitly. To use Open Korean Dictionary
categories, add @gukhanmun/opendict-fst or
@gukhanmun/opendict-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>를
반환합니다.
#《우리말샘》 패키지
@gukhanmun/opendict-fst와 @gukhanmun/opendict-cdb는 《우리말샘》을
일반어, 북한어, 방언, 옛말 분유별 사전으로 나누어 제공합니다. JavaScript
프리셋은 이 패키지들을 자동으로 불러오지 않으므로, 필요한 분류를 명시적으로
넘겨야 합니다:
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 opendictDialectFst(): Promise<FileDictionarySource>Loads the bundled Open Korean Dictionary 방언 dictionary.
@returnsA FileDictionarySource with format: "fst". opendictDialectFst ,
function opendictNorthKoreanFst(): Promise<FileDictionarySource>Loads the bundled Open Korean Dictionary 북한어 dictionary.
@returnsA FileDictionarySource with format: "fst". opendictNorthKoreanFst ,
} from "@gukhanmun/opendict-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.preset?: Preset | undefinedNamed configuration preset. Defaults to "ko-kr".
@seePreset preset : "ko-kp",
GukhanmunOptions.dictionaries?: readonly FileDictionarySource[] | undefinedOrdered 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 bundled dictionaries).
JavaScript presets do not
automatically include bundled dictionary data. To use the Standard
Korean Language Dictionary, add @gukhanmun/stdict-fst or
@gukhanmun/stdict-cdb explicitly. To use Open Korean Dictionary
categories, add @gukhanmun/opendict-fst or
@gukhanmun/opendict-cdb explicitly.
@seeDictionarySource dictionaries : [
await function opendictNorthKoreanFst(): Promise<FileDictionarySource>Loads the bundled Open Korean Dictionary 북한어 dictionary.
@returnsA FileDictionarySource with format: "fst". opendictNorthKoreanFst (),
await function opendictDialectFst(): Promise<FileDictionarySource>Loads the bundled Open Korean Dictionary 방언 dictionary.
@returnsA FileDictionarySource with format: "fst". opendictDialectFst (),
],
});같은 분류를 CDB 형식으로 쓰려면 CDB 패키지를 사용합니다:
import { 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 } from "@gukhanmun/napi";
import { function opendictNorthKoreanCdb(): Promise<FileDictionarySource>Loads the bundled Open Korean Dictionary 북한어 dictionary.
@returnsA FileDictionarySource with format: "cdb". opendictNorthKoreanCdb } from "@gukhanmun/opendict-cdb";
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.preset?: Preset | undefinedNamed configuration preset. Defaults to "ko-kr".
@seePreset preset : "ko-kp",
GukhanmunOptions.dictionaries?: readonly FileDictionarySource[] | undefinedOrdered 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 bundled dictionaries).
JavaScript presets do not
automatically include bundled dictionary data. To use the Standard
Korean Language Dictionary, add @gukhanmun/stdict-fst or
@gukhanmun/stdict-cdb explicitly. To use Open Korean Dictionary
categories, add @gukhanmun/opendict-fst or
@gukhanmun/opendict-cdb explicitly.
@seeDictionarySource dictionaries : [await function opendictNorthKoreanCdb(): Promise<FileDictionarySource>Loads the bundled Open Korean Dictionary 북한어 dictionary.
@returnsA FileDictionarySource with format: "cdb". opendictNorthKoreanCdb ()],
});#사용자 정의 사전
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()로 불러옴 |
string | Node.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[] | undefinedOrdered 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 bundled dictionaries).
JavaScript presets do not
automatically include bundled dictionary data. To use the Standard
Korean Language Dictionary, add @gukhanmun/stdict-fst or
@gukhanmun/stdict-cdb explicitly. To use Open Korean Dictionary
categories, add @gukhanmun/opendict-fst or
@gukhanmun/opendict-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) => URLThe 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.
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: stringThe 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[] | undefinedOrdered 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 bundled dictionaries).
JavaScript presets do not
automatically include bundled dictionary data. To use the Standard
Korean Language Dictionary, add @gukhanmun/stdict-fst or
@gukhanmun/stdict-cdb explicitly. To use Open Korean Dictionary
categories, add @gukhanmun/opendict-fst or
@gukhanmun/opendict-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[] | undefinedOrdered 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 bundled dictionaries).
JavaScript presets do not
automatically include bundled dictionary data. To use the Standard
Korean Language Dictionary, add @gukhanmun/stdict-fst or
@gukhanmun/stdict-cdb explicitly. To use Open Korean Dictionary
categories, add @gukhanmun/opendict-fst or
@gukhanmun/opendict-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> | URLThe 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[] | undefinedOrdered 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 bundled dictionaries).
JavaScript presets do not
automatically include bundled dictionary data. To use the Standard
Korean Language Dictionary, add @gukhanmun/stdict-fst or
@gukhanmun/stdict-cdb explicitly. To use Open Korean Dictionary
categories, add @gukhanmun/opendict-fst or
@gukhanmun/opendict-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> | URLThe 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 안내서의
〈사용자 정의 사전 구축〉을
참조하십시오.