For AI agents: the complete documentation index is available at https://canary.gukhanmun.org/ko-KR/llms.txt, the full documentation bundle is available at https://canary.gukhanmun.org/ko-KR/llms-full.txt, and this page is available as Markdown at https://canary.gukhanmun.org/ko-KR/guide/javascript/dictionary.md.
  • 한국어 (한글)
  • 사전

    dictionaries 옵션에 DictionarySource 객체의 배열을 넘깁니다. 사전 출처는 컴파일된 산출물(FileDictionarySource)이거나 실행 시점에 계산한 항목 목록 (MapDictionarySource)입니다. 기본 reference-authorized 정책은 출처 역할과 명시적 사전 관계에 따라 후보 순위를 정합니다. sourcePolicy: "ordered"를 선택하면 종래의 배열 우선순위를 사용합니다.

    《표준국어대사전》 패키지

    @gukhanmun/stdict-fst와 @gukhanmun/stdict-cdb는 둘 다 내장 《표준국어대사전》을 각각 다른 바이너리 형식으로 제공합니다.

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

    Creates a Gukhanmun converter with the given options.

    Initialises the WASM module on the first call (subsequent calls reuse the cached module). Compiled dictionaries supplied via GukhanmunOptions.dictionaries are fetched, while MapDictionarySource entry lists are serialised and built in memory as Rust MapDictionary 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" and role: "reference".
    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" and role: "reference".
    stdictCdb
    } from "@gukhanmun/stdict-cdb";
    // FST: 勸奬; 디스크에서 더 작고, 래티스(lattice) 分割에 더 適合 const
    const g: Gukhanmun
    g
    = await
    function load(options?: GukhanmunLoadOptions): Promise<Gukhanmun>

    Creates a Gukhanmun converter with the given options.

    Initialises the WASM module on the first call (subsequent calls reuse the cached module). Compiled dictionaries supplied via GukhanmunOptions.dictionaries are fetched, while MapDictionarySource entry lists are serialised and built in memory as Rust MapDictionary 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
    ({
    dictionaries?: readonly (DictionarySource | LoadedDictionary)[] | undefined
    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" and role: "reference".
    stdictFst
    ()] });
    // CDB: 索引을 使用한 찾기; 더 單純한 파일 配置 const
    const g: Gukhanmun
    g
    = await
    function load(options?: GukhanmunLoadOptions): Promise<Gukhanmun>

    Creates a Gukhanmun converter with the given options.

    Initialises the WASM module on the first call (subsequent calls reuse the cached module). Compiled dictionaries supplied via GukhanmunOptions.dictionaries are fetched, while MapDictionarySource entry lists are serialised and built in memory as Rust MapDictionary 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
    ({
    dictionaries?: readonly (DictionarySource | LoadedDictionary)[] | undefined
    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" and role: "reference".
    stdictCdb
    ()] });

    stdictFst()와 stdictCdb()는 모두 Promise<FileDictionarySource>를 반환합니다.

    같은 사전을 여러 변환기에서 사용하려면 loadDictionary()로 한 번만 불러옵니다. load()와 같은 패키지에서 가져온 함수를 사용합니다.

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

    Creates a Gukhanmun converter with the given options.

    Initialises the WASM module on the first call (subsequent calls reuse the cached module). Compiled dictionaries supplied via GukhanmunOptions.dictionaries are fetched, while MapDictionarySource entry lists are serialised and built in memory as Rust MapDictionary 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
    ,
    function loadDictionary(source: DictionarySource): Promise<LoadedDictionary>

    Loads one immutable dictionary snapshot for reuse by this backend.

    loadDictionary
    } 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" and role: "reference".
    stdictFst
    } from "@gukhanmun/stdict-fst";
    const
    const reference: LoadedDictionary
    reference
    = await
    function loadDictionary(source: DictionarySource): Promise<LoadedDictionary>

    Loads one immutable dictionary snapshot for reuse by this backend.

    loadDictionary
    (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" and role: "reference".
    stdictFst
    ());
    const
    const overrides: {
        entries: {
            hanja: string;
            reading: string;
        }[];
    }
    overrides
    = {
    entries: {
        hanja: string;
        reading: string;
    }[]
    entries
    : [{
    hanja: string
    hanja
    : "東京",
    reading: string
    reading
    : "도쿄" }] };
    const
    const plain: Gukhanmun
    plain
    = await
    function load(options?: GukhanmunLoadOptions): Promise<Gukhanmun>

    Creates a Gukhanmun converter with the given options.

    Initialises the WASM module on the first call (subsequent calls reuse the cached module). Compiled dictionaries supplied via GukhanmunOptions.dictionaries are fetched, while MapDictionarySource entry lists are serialised and built in memory as Rust MapDictionary 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
    ({
    dictionaries?: readonly (DictionarySource | LoadedDictionary)[] | undefined
    dictionaries
    : [
    const overrides: {
        entries: {
            hanja: string;
            reading: string;
        }[];
    }
    overrides
    ,
    const reference: LoadedDictionary
    reference
    ] });
    const
    const ruby: Gukhanmun
    ruby
    = await
    function load(options?: GukhanmunLoadOptions): Promise<Gukhanmun>

    Creates a Gukhanmun converter with the given options.

    Initialises the WASM module on the first call (subsequent calls reuse the cached module). Compiled dictionaries supplied via GukhanmunOptions.dictionaries are fetched, while MapDictionarySource entry lists are serialised and built in memory as Rust MapDictionary 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
    ({
    dictionaries?: readonly (DictionarySource | LoadedDictionary)[] | undefined
    dictionaries
    : [
    const overrides: {
        entries: {
            hanja: string;
            reading: string;
        }[];
    }
    overrides
    ,
    const reference: LoadedDictionary
    reference
    ],
    rendering?: RenderMode | undefined

    How annotations are rendered into output text or markup. Defaults to "hangul-only".

    @seeRenderMode
    rendering
    : "ruby-on-hangul",
    });

    LoadedDictionary는 불러온 시점의 내용과 출처 역할을 보지합니다. 사전 데이터는 공유하지만, 출처 순서와 변환 옵션은 변환기마다 따로 적용합니다. 다른 백엔드에서 사용하거나 바뀐 내용을 반영하려면 다시 불러옵니다. 핸들이 든 옵션의 타입은 GukhanmunLoadOptions입니다.

    《우리말샘》 패키지

    @gukhanmun/opendict-fst와 @gukhanmun/opendict-cdb는 《우리말샘》을 일반어, 북한어, 방언, 옛말 분유별 사전으로 나누어 제공합니다. JavaScript 프리셋은 이 패키지들을 자동으로 불러오지 않으므로, 필요한 분류를 명시적으로 넘겨야 합니다:

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

    Creates a Gukhanmun converter with the given options.

    Initialises the WASM module on the first call (subsequent calls reuse the cached module). Compiled dictionaries supplied via GukhanmunOptions.dictionaries are fetched, while MapDictionarySource entry lists are serialised and built in memory as Rust MapDictionary 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" and role: "reference".
    opendictDialectFst
    ,
    function opendictNorthKoreanFst(): Promise<FileDictionarySource>

    Loads the bundled Open Korean Dictionary 북한어 dictionary.

    @returnsA FileDictionarySource with format: "fst" and role: "reference".
    opendictNorthKoreanFst
    ,
    } from "@gukhanmun/opendict-fst"; const
    const g: Gukhanmun
    g
    = await
    function load(options?: GukhanmunLoadOptions): Promise<Gukhanmun>

    Creates a Gukhanmun converter with the given options.

    Initialises the WASM module on the first call (subsequent calls reuse the cached module). Compiled dictionaries supplied via GukhanmunOptions.dictionaries are fetched, while MapDictionarySource entry lists are serialised and built in memory as Rust MapDictionary 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
    ({
    preset?: Preset | undefined

    Named configuration preset. Defaults to "ko-kr".

    @seePreset
    preset
    : "ko-kp",
    dictionaries?: readonly (DictionarySource | LoadedDictionary)[] | undefined
    dictionaries
    : [
    await
    function opendictNorthKoreanFst(): Promise<FileDictionarySource>

    Loads the bundled Open Korean Dictionary 북한어 dictionary.

    @returnsA FileDictionarySource with format: "fst" and role: "reference".
    opendictNorthKoreanFst
    (),
    await
    function opendictDialectFst(): Promise<FileDictionarySource>

    Loads the bundled Open Korean Dictionary 방언 dictionary.

    @returnsA FileDictionarySource with format: "fst" and role: "reference".
    opendictDialectFst
    (),
    ], });

    같은 분류를 CDB 형식으로 쓰려면 CDB 패키지를 사용합니다:

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

    Creates a Gukhanmun converter with the given options.

    The native addon is synchronously ready; compiled dictionaries supplied via GukhanmunOptions.dictionaries are fetched or read from disk, while MapDictionarySource entry lists are serialised and built in memory as Rust MapDictionary 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" and role: "reference".
    opendictNorthKoreanCdb
    } from "@gukhanmun/opendict-cdb";
    const
    const g: Gukhanmun
    g
    = await
    function load(options?: GukhanmunLoadOptions): Promise<Gukhanmun>

    Creates a Gukhanmun converter with the given options.

    The native addon is synchronously ready; compiled dictionaries supplied via GukhanmunOptions.dictionaries are fetched or read from disk, while MapDictionarySource entry lists are serialised and built in memory as Rust MapDictionary 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
    ({
    preset?: Preset | undefined

    Named configuration preset. Defaults to "ko-kr".

    @seePreset
    preset
    : "ko-kp",
    dictionaries?: readonly (DictionarySource | LoadedDictionary)[] | undefined
    dictionaries
    : [await
    function opendictNorthKoreanCdb(): Promise<FileDictionarySource>

    Loads the bundled Open Korean Dictionary 북한어 dictionary.

    @returnsA FileDictionarySource with format: "cdb" and role: "reference".
    opendictNorthKoreanCdb
    ()],
    });

    《외래어 표기 용례》 패키지

    @gukhanmun/loanwords-fst와 @gukhanmun/loanwords-cdb는 국립국어원 《외래어 표기 용례》 사전을 제공합니다. "ko-kr"과 "ko-kp" 모두 명시적으로 불러와야 하며, 프리셋은 이 사전을 자동으로 추가하지 않습니다. 사용자 정의 사전은 override, stdict·opendict는 reference, 외래어 용례는 loanword 역할로 구별합니다. 공식 로더(loader)는 역할을 명시하므로 기본 정책에서는 외래어 용례와 참조 사전의 상대적인 배열 순서에 의존하지 않습니다:

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

    Creates a Gukhanmun converter with the given options.

    Initialises the WASM module on the first call (subsequent calls reuse the cached module). Compiled dictionaries supplied via GukhanmunOptions.dictionaries are fetched, while MapDictionarySource entry lists are serialised and built in memory as Rust MapDictionary 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 loanwordsFst(): Promise<FileDictionarySource>

    Loads the bundled NIKL loanword examples as a

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

    @returnsA FileDictionarySource with format: "fst" and role: "loanword".
    loanwordsFst
    } from "@gukhanmun/loanwords-fst";
    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" and role: "reference".
    stdictFst
    } from "@gukhanmun/stdict-fst";
    const
    const g: Gukhanmun
    g
    = await
    function load(options?: GukhanmunLoadOptions): Promise<Gukhanmun>

    Creates a Gukhanmun converter with the given options.

    Initialises the WASM module on the first call (subsequent calls reuse the cached module). Compiled dictionaries supplied via GukhanmunOptions.dictionaries are fetched, while MapDictionarySource entry lists are serialised and built in memory as Rust MapDictionary 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
    ({
    preset?: Preset | undefined

    Named configuration preset. Defaults to "ko-kr".

    @seePreset
    preset
    : "ko-kr",
    dictionaries?: readonly (DictionarySource | LoadedDictionary)[] | undefined
    dictionaries
    : [await
    function loanwordsFst(): Promise<FileDictionarySource>

    Loads the bundled NIKL loanword examples as a

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

    @returnsA FileDictionarySource with format: "fst" and role: "loanword".
    loanwordsFst
    (), 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" and role: "reference".
    stdictFst
    ()],
    });
    const g: Gukhanmun
    g
    .
    Gukhanmun.convert(source: string, format?: MediaType): string (+2 overloads)

    Converts source to hangul in one shot. Buffers the entire input before returning.

    @paramsource - The text to convert.@paramformat - Input/output media type. Defaults to "text/plain".@returnsThe converted text.@throws{@linkGukhanmunError } on conversion failure.
    convert
    ("香港"); // "홍콩"

    CDB 형식을 쓰려면 @gukhanmun/loanwords-cdb에서 loanwordsCdb를 가져옵니다. 두 로더 모두 Promise<FileDictionarySource>를 반환하고 @gukhanmun/wasm과 @gukhanmun/napi에서 쓸 수 있습니다. 패키지를 설치하는 것만으로는 변환이 달라지지 않으며, 로더의 결과를 dictionaries에 넣어야 합니다.

    사용자 정의 사전

    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?: GukhanmunLoadOptions): Promise<Gukhanmun>

    Creates a Gukhanmun converter with the given options.

    Initialises the WASM module on the first call (subsequent calls reuse the cached module). Compiled dictionaries supplied via GukhanmunOptions.dictionaries are fetched, while MapDictionarySource entry lists are serialised and built in memory as Rust MapDictionary 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
    ({
    dictionaries?: readonly (DictionarySource | LoadedDictionary)[] | undefined
    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 and never accepted. Pass entries in memory through MapDictionarySource instead of compiling a table.

    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
    : 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?: GukhanmunLoadOptions): Promise<Gukhanmun>

    Creates a Gukhanmun converter with the given options.

    Initialises the WASM module on the first call (subsequent calls reuse the cached module). Compiled dictionaries supplied via GukhanmunOptions.dictionaries are fetched, while MapDictionarySource entry lists are serialised and built in memory as Rust MapDictionary 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
    ({
    dictionaries?: readonly (DictionarySource | LoadedDictionary)[] | undefined
    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 and never accepted. Pass entries in memory through MapDictionarySource instead of compiling a table.

    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?: GukhanmunLoadOptions): Promise<Gukhanmun>

    Creates a Gukhanmun converter with the given options.

    The native addon is synchronously ready; compiled dictionaries supplied via GukhanmunOptions.dictionaries are fetched or read from disk, while MapDictionarySource entry lists are serialised and built in memory as Rust MapDictionary 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
    ({
    dictionaries?: readonly (DictionarySource | LoadedDictionary)[] | undefined
    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 and never accepted. Pass entries in memory through MapDictionarySource instead of compiling a table.

    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?: GukhanmunLoadOptions): Promise<Gukhanmun>

    Creates a Gukhanmun converter with the given options.

    The native addon is synchronously ready; compiled dictionaries supplied via GukhanmunOptions.dictionaries are fetched or read from disk, while MapDictionarySource entry lists are serialised and built in memory as Rust MapDictionary 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
    ({
    dictionaries?: readonly (DictionarySource | LoadedDictionary)[] | undefined
    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 and never accepted. Pass entries in memory through MapDictionarySource instead of compiling a table.

    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" and role: "reference".
    stdictFst
    (), // fallback
    ], });

    사용자 정의 사전 구축

    위에서 불러온 .gukfst와 .gukcdb 파일은 컴파일된 산출물이며, gukhanmun-mkdict 도구로 평문 텍스트 표에서 빌드됩니다. 사전 출처를 작성하고 컴파일하는 방법은 CLI 안내서의 〈사용자 정의 사전 구축〉을 참조하십시오. 항목을 디스크에 두지 않고 실행 중에 계산한다면, 다음 절처럼 직접 넘기면 됩니다.

    실행 시점에 계산한 항목

    MapDictionarySource는 항목을 메모리에 담습니다. 문서를 만드는 도중에 독음을 계산하거나, TSV 파일도 gukhanmun-mkdict도 쓸 수 없는 브라우저·에지 런타임에서 사용합니다:

    const 
    const converter: Gukhanmun
    converter
    = await
    function load(options?: GukhanmunLoadOptions): Promise<Gukhanmun>

    Creates a Gukhanmun converter with the given options.

    Initialises the WASM module on the first call (subsequent calls reuse the cached module). Compiled dictionaries supplied via GukhanmunOptions.dictionaries are fetched, while MapDictionarySource entry lists are serialised and built in memory as Rust MapDictionary 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
    ({
    dictionaries?: readonly (DictionarySource | LoadedDictionary)[] | undefined
    dictionaries
    : [
    {
    MapDictionarySource.entries: readonly DictionaryEntry[]

    The entries of this dictionary.

    Repeated hanja keys append competing readings instead of replacing each other, and DictionaryEntry.preference decides which reading is the context-free default. Several readings for one key also let the engine pick a reading from a following particle (東京을 versus 東京를).

    An empty list contributes nothing, which is a convenient way to express "this document has no overrides".

    entries
    : [
    {
    DictionaryEntry.hanja: string

    The hanja form (dictionary key), e.g. "漢字".

    hanja
    : "高橋",
    DictionaryEntry.reading: string

    The word-initial hangul reading, e.g. "한자".

    reading
    : "다카하시" },
    {
    DictionaryEntry.hanja: string

    The hanja form (dictionary key), e.g. "漢字".

    hanja
    : "東京",
    DictionaryEntry.reading: string

    The word-initial hangul reading, e.g. "한자".

    reading
    : "도쿄",
    DictionaryEntry.preference?: number | undefined

    Relative default preference for this reading within its hanja key, a non-negative integer. Larger values win, so an entry listed twice with different preferences keeps competing readings and uses the higher one by default. Absent means 0.

    List order never selects the default: when two readings share a preference the tie is broken by reading spelling. Set distinct preferences to choose a default deliberately.

    Corresponds to Rust ReadingCandidate::preference.

    preference
    : 10 },
    {
    DictionaryEntry.hanja: string

    The hanja form (dictionary key), e.g. "漢字".

    hanja
    : "年代",
    DictionaryEntry.reading: string

    The word-initial hangul reading, e.g. "한자".

    reading
    : "연대",
    DictionaryEntry.suffixReading?: string | undefined

    The reading used when the match is not word-initial, when it differs from

    reading . For example a 年代 entry with reading: "연대" and suffixReading: "년대" reads 1990年代 as 1990년대 but 年代 alone as 연대.

    Corresponds to Rust ReadingCandidate::suffix_reading.

    suffixReading
    : "년대" },
    ], }, 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" and role: "reference".
    stdictFst
    (),
    ], });

    각 필드는 한자 키를 제외하면 Rust의 ReadingCandidate 타입과 같습니다:

    필드의미
    hanja사전 키
    reading어두 독음
    suffixReading어두가 아닐 때 쓰는 독음 (다를 때만)
    preference같은 키 안에서의 상대 우선 순위; 클수록 우선, 없으면 0
    requireHanja독음과 함께 원본 한자를 항상 보임
    requireHangul원본 한자와 함께 한글 주를 항상 보임

    항목 목록의 기본 역할은 "override"입니다. 사전 협력 정책에서는 같은 표기와 소비 길이에 대해 참조·외래어 출처보다 먼저 적용하며, 여러 덮어쓰기(override)가 있으면 먼저 등록한 것이 우선합니다. sourcePolicy: "ordered"에서는 모든 출처가 배열 순서를 따르므로, 이 모드에서 컴파일된 사전의 키를 덮어쓰려면 항목 목록을 그 사전보다 앞에 둡니다.

    같은 hanja 키를 되풀이하면 앞의 독음을 대체하지 않고 독음을 하나 더 추가합니다. 엔진은 한 표제어의 여러 독음을 모두 지니고 있다가, 뒤따르는 조사가 결정적이면 그 조사에 맞는 독음을 고릅니다:

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

    Creates a Gukhanmun converter with the given options.

    Initialises the WASM module on the first call (subsequent calls reuse the cached module). Compiled dictionaries supplied via GukhanmunOptions.dictionaries are fetched, while MapDictionarySource entry lists are serialised and built in memory as Rust MapDictionary 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
    ({
    dictionaries?: readonly (DictionarySource | LoadedDictionary)[] | undefined
    dictionaries
    : [
    {
    MapDictionarySource.entries: readonly DictionaryEntry[]

    The entries of this dictionary.

    Repeated hanja keys append competing readings instead of replacing each other, and DictionaryEntry.preference decides which reading is the context-free default. Several readings for one key also let the engine pick a reading from a following particle (東京을 versus 東京를).

    An empty list contributes nothing, which is a convenient way to express "this document has no overrides".

    entries
    : [
    {
    DictionaryEntry.hanja: string

    The hanja form (dictionary key), e.g. "漢字".

    hanja
    : "東京",
    DictionaryEntry.reading: string

    The word-initial hangul reading, e.g. "한자".

    reading
    : "동경" },
    {
    DictionaryEntry.hanja: string

    The hanja form (dictionary key), e.g. "漢字".

    hanja
    : "東京",
    DictionaryEntry.reading: string

    The word-initial hangul reading, e.g. "한자".

    reading
    : "도쿄",
    DictionaryEntry.preference?: number | undefined

    Relative default preference for this reading within its hanja key, a non-negative integer. Larger values win, so an entry listed twice with different preferences keeps competing readings and uses the higher one by default. Absent means 0.

    List order never selects the default: when two readings share a preference the tie is broken by reading spelling. Set distinct preferences to choose a default deliberately.

    Corresponds to Rust ReadingCandidate::preference.

    preference
    : 10 },
    ], }, ], });
    const g: Gukhanmun
    g
    .
    Gukhanmun.convert(source: string, format?: MediaType): string (+2 overloads)

    Converts source to hangul in one shot. Buffers the entire input before returning.

    @paramsource - The text to convert.@paramformat - Input/output media type. Defaults to "text/plain".@returnsThe converted text.@throws{@linkGukhanmunError } on conversion failure.
    convert
    ("東京"); // "도쿄": 優先 順位가 높은 讀音
    const g: Gukhanmun
    g
    .
    Gukhanmun.convert(source: string, format?: MediaType): string (+2 overloads)

    Converts source to hangul in one shot. Buffers the entire input before returning.

    @paramsource - The text to convert.@paramformat - Input/output media type. Defaults to "text/plain".@returnsThe converted text.@throws{@linkGukhanmunError } on conversion failure.
    convert
    ("東京을"); // "동경을": 助詞가 다른 讀音을 고름
    const g: Gukhanmun
    g
    .
    Gukhanmun.convert(source: string, format?: MediaType): string (+2 overloads)

    Converts source to hangul in one shot. Buffers the entire input before returning.

    @paramsource - The text to convert.@paramformat - Input/output media type. Defaults to "text/plain".@returnsThe converted text.@throws{@linkGukhanmunError } on conversion failure.
    convert
    ("東京를"); // "도쿄를"

    문맥 없이 쓰는 기본 독음은 preference가 결정합니다. 목록 순서는 결코 기본 독음을 고르지 않습니다. 두 독음의 우선 순위가 같으면 독음 철자 순서로 결정되므로, 선택이 중요하다면 preference를 서로 다르게 지정하십시오.

    빈 entries 목록은 아무것도 기여하지 않으므로, 덮어쓸 항목이 없는 문서에는 { entries: [] }를 그대로 둘 수 있습니다.

    출처에 따른 후보 선택

    기본 reference-authorized 정책은 참조 사전과 외래어 사전의 후보를 별도로 보존합니다. 참조 사전이 동의어나 형식적 전송 관계로 허용한 표기만 우선하며, 같은 후보에 기여한 모든 어의의 허용 범위를 교집합으로 계산합니다. 동일한 한자 표기나 독음만으로 관계를 추측하지 않습니다. 근거가 없으면 참조 사전의 독음을 유지하므로 東扶餘는 동부여, 香港은 홍콩이 됩니다.

    최종 후보 풀 전체에 조사 검사를 한 번 적용합니다. 따라서 기본 독음이 아닌 독립 외래어 후보도 조사에 맞으면 선택할 수 있습니다. 平은 평이지만 平를은 다이라를이 될 수 있습니다. 수치 우선도는 각 사전 내부에서만 비교하며, 격자(lattice)의 목적 함수는 변경하지 않습니다.

    정책동작
    reference-authorized허용된 외래어 표기, 참조 사전의 전송/원독음, 독립 외래어 순
    reference-first참조 사전의 원독음을 독립 외래어보다 우선
    loanword-first독립 외래어를 참조 사전의 원독음보다 우선
    ordered역할과 허용 관계를 무시하고 종래의 사전 순서를 사용

    협력 정책에서 사용자의 override는 같은 표기와 소비 길이의 다른 후보를 대체하며, 더 긴 일치를 제거하지 않습니다. 참조 전용 설정은 독립 외래어를 제외하지만, 참조 사전이 허용한 외래어 실현은 유지합니다.

    선택한 후보의 식별자·별명·위치형·주해(annotation) 표식을 함께 전달합니다. 출처를 보존하는 사전 일치는 인접한 폴백 한자와 별도의 주해로 남으므로, ordered와 비교하여 괄호로 묶이는 범위가 달라질 수 있습니다.

    load({ sourcePolicy: "reference-authorized", referenceOnly: true, dictionaries })로 정책과 참조 전용을 설정합니다. 파일·항목 기술자 모두 role: "override" | "reference" | "loanword"를 받을 수 있습니다. 항목의 기본값은 override이며, 파일은 바이너리의 역할 메타데이터가 있으면 사용하고 없으면 override입니다. 명시적 role은 메타데이터보다 우선합니다. 공식 로더는 역할을 명시합니다. 협력 정책에서 덮어쓰기는 배열 위치와 무관하게 협력 사전보다 우선하고, 덮어쓰기끼리는 앞의 항목이 우선합니다. sourcePolicy: "ordered"는 모든 기술자의 종래 배열 순서를 복원합니다.

    《표준국어대사전》 CDB 로더는 stdict.cdb.gz를 내려받아 해동합니다. 사용자 URL에는 gzip이나 압축하지 않은 CDB를 제공할 수 있으며, npm의 압축하지 않은 stdict.cdb 내보내기는 유지합니다.

    사전 역할은 격자의 점수 목적 함수를 변경하지 않습니다. JavaScript 바인딩은 변환 전에 문서 전체를 버퍼링합니다. 〈스트리밍 API〉를 참조하십시오.