### Install HanjaDict Package Source: https://github.com/seyoungsong/hanjadict-js/blob/master/README.md Install the HanjaDict package using npm or yarn. ```sh npm install hanjadict # or yarn add hanjadict ``` -------------------------------- ### Lookup Hanja character meanings (훈음) Source: https://context7.com/seyoungsong/hanjadict-js/llms.txt Use the `lookup` function to get the full 훈음 string for a Hanja character. Returns `null` for unknown or non-Hanja input. Handles multi-reading characters. ```typescript import { lookup } from "hanjadict" // Standard lookup console.log(lookup("雪")) // "눈 설" console.log(lookup("山")) // "메 산" console.log(lookup("水")) // "물 수" console.log(lookup("火")) // "불 화" // Multi-reading characters (comma / slash / parentheses formats) console.log(lookup("燕")) // "제비 연/잔치 연" console.log(lookup("㴕")) // "샘솟을 집, 샘솟을 설" console.log(lookup("䴫")) // "영양 령(영)" // Unknown / non-Hanja input console.log(lookup("한")) // null (Hangul, not Hanja) console.log(lookup("xyz")) // null console.log(lookup("")) // null // Batch lookup with null-filtering const chars = ["雪", "山", "水", "한글", "xyz"] const results = chars .map(c => ({ char: c, hunEum: lookup(c) })) .filter(r => r.hunEum !== null) console.log(results) // [ // { char: "雪", hunEum: "눈 설" }, // { char: "山", hunEum: "메 산" }, // { char: "水", hunEum: "물 수" } // ] ``` -------------------------------- ### Import and Use HanjaDict Functions Source: https://github.com/seyoungsong/hanjadict-js/blob/master/README.md Import and utilize the lookup, isHanja, pronunciation, and tableData functions from the hanjadict package. ```js import { lookup, isHanja, pronunciation, tableData } from "hanjadict" // Look up a Hanja character const result = lookup("雪") console.log(result) // Output: '눈 설' // Check if a character is Hanja const isHanjaChar = isHanja("雪") console.log(isHanjaChar) // Output: true // Get only the pronunciation (음/音) part const pron = pronunciation("雪") console.log(pron) // Output: '설' // Access the raw dictionary data console.log(Object.keys(tableData).length) // Output: 53458 // If the character is not found, returns null const notFound = lookup("xyz") console.log(notFound) // Output: null ``` -------------------------------- ### Accessing and Iterating Hanja Dictionary Data Source: https://context7.com/seyoungsong/hanjadict-js/llms.txt Demonstrates how to access the raw dictionary data, count entries, perform direct lookups, and iterate to find characters based on pronunciation or meaning. Requires importing `tableData` from 'hanjadict'. ```typescript import { tableData } from "hanjadict" // Total number of entries console.log(Object.keys(tableData).length) // 53458 // Direct key access (same as lookup, but no null-safety wrapper) console.log(tableData["雪"]) // "눈 설" // Iterate over all entries and collect characters whose pronunciation is "수" const suChars = Object.entries(tableData) .filter(([, hunEum]) => hunEum.endsWith(" 수") || hunEum.includes(" 수/") || hunEum.includes(" 수,")) .map(([char]) => char) console.log(`Characters pronounced "수": ${suChars.length}`) // Characters pronounced "수": (number varies) // Find all entries that include a specific 훈 (meaning keyword) const snowMeaning = Object.entries(tableData) .filter(([, hunEum]) => hunEum.startsWith("눈 ")) .map(([char, hunEum]) => ({ char, hunEum })) console.log(snowMeaning) // [{ char: "雪", hunEum: "눈 설" }, ...] ``` ```typescript import { writeFileSync } from "fs" import { tableData } from "hanjadict" // Export a plain JSON snapshot of all entries writeFileSync("hanja-export.json", JSON.stringify(tableData, null, 2), "utf-8") ``` -------------------------------- ### lookup(c: string): string | null Source: https://context7.com/seyoungsong/hanjadict-js/llms.txt Returns the full 훈음 (hun-eum) string for a given Hanja character. The returned string is in the format "훈 음" (meaning followed by pronunciation), or one of the extended formats documented under `pronunciation()`. Returns `null` if the character is not in the dictionary. ```APIDOC ## lookup(c: string): string | null ### Description Returns the full 훈음 (hun-eum) string for a given Hanja character. The returned string is in the format "훈 음" (meaning followed by pronunciation), or one of the extended formats documented under `pronunciation()`. Returns `null` if the character is not in the dictionary. ### Parameters #### Path Parameters - **c** (string) - Required - The Hanja character to look up. ### Request Example ```javascript import { lookup } from "hanjadict" // Standard lookup console.log(lookup("雪")) // "눈 설" console.log(lookup("山")) // "메 산" console.log(lookup("水")) // "물 수" console.log(lookup("火")) // "불 화" // Multi-reading characters (comma / slash / parentheses formats) console.log(lookup("燕")) // "제비 연/잔치 연" console.log(lookup("㴕")) // "샘솟을 집, 샘솟을 설" console.log(lookup("䴫")) // "영양 령(영)" // Unknown / non-Hanja input console.log(lookup("한")) // null (Hangul, not Hanja) console.log(lookup("xyz")) // null console.log(lookup("")) // null // Batch lookup with null-filtering const chars = ["雪", "山", "水", "한글", "xyz"] const results = chars .map(c => ({ char: c, hunEum: lookup(c) })) .filter(r => r.hunEum !== null) console.log(results) // [ // { char: "雪", hunEum: "눈 설" }, // { char: "山", hunEum: "메 산" }, // { char: "水", hunEum: "물 수" } // ] ``` ### Response #### Success Response (200) - **string | null**: The 훈음 string or null if not found. ``` -------------------------------- ### lookup(c) Source: https://github.com/seyoungsong/hanjadict-js/blob/master/README.md Retrieves the full 훈음 (hun-eum) information for a given Hanja character. Returns null if the character is not found in the dictionary. ```APIDOC ## lookup(c) ### Description Get the full 훈음 information for a character. ### Parameters #### Path Parameters - **c** (string) - Required - The Hanja character to look up. ### Response #### Success Response (200) - Returns a string in the format 'meaning pronunciation' (e.g., '눈 설') or null if not found. ### Request Example ```javascript import { lookup } from "hanjadict" const result = lookup("雪") console.log(result) // Output: '눈 설' const notFound = lookup("xyz") console.log(notFound) // Output: null ``` ``` -------------------------------- ### tableData Source: https://github.com/seyoungsong/hanjadict-js/blob/master/README.md Provides access to the raw dictionary data, which is a JavaScript object containing all Hanja information. ```APIDOC ## tableData ### Description Access the raw dictionary data. ### Parameters None ### Response #### Success Response (200) - Returns a JavaScript object where keys are Hanja characters and values are their corresponding 훈음 information. ### Request Example ```javascript import { tableData } from "hanjadict" console.log(Object.keys(tableData).length) // Output: 53458 console.log(tableData["雪"]) // Output: '눈 설' ``` ``` -------------------------------- ### Extract Hanja pronunciation (음) Source: https://context7.com/seyoungsong/hanjadict-js/llms.txt The `pronunciation` function extracts only the Sino-Korean pronunciation (음) from a dictionary entry. It handles various dictionary formats and returns `null` for unknown characters. ```typescript import { pronunciation } from "hanjadict" // Normal format: "눈 설" → "설" console.log(pronunciation("雪")) // "설" // Slash-separated: "제비 연/잔치 연" → takes first segment → "연" console.log(pronunciation("燕")) // "연" // Comma-separated: "샘솟을 집, 샘솟을 설" → takes first segment → "집" console.log(pronunciation("㴕")) // "집" // Parentheses: "영양 령(영)" → strips parens → "령" console.log(pronunciation("䴫")) // "령" // Unknown input console.log(pronunciation("xyz")) // null console.log(pronunciation("")) // null // Build a pronunciation index for an array of characters const chars = ["雪", "山", "水", "火", "木", "金", "土"] const pronunciationMap = Object.fromEntries( chars .map(c => [c, pronunciation(c)]) .filter(([, p]) => p !== null) ) console.log(pronunciationMap) // { "雪": "설", "山": "산", "水": "수", "火": "화", "木": "목", "金": "금", "土": "토" } ``` -------------------------------- ### pronunciation(c) Source: https://github.com/seyoungsong/hanjadict-js/blob/master/README.md Extracts only the Sino-Korean pronunciation (음/音) part of a Hanja character's 훈음 information. Handles various dictionary formats. ```APIDOC ## pronunciation(c) ### Description Extract only the Sino-Korean pronunciation (음/音) part. ### Parameters #### Path Parameters - **c** (string) - Required - The Hanja character to get the pronunciation for. ### Response #### Success Response (200) - Returns a string representing the pronunciation (e.g., '설'). Handles various formats like comma-separated or slash-separated entries. ### Request Example ```javascript import { pronunciation } from "hanjadict" const pron = pronunciation("雪") console.log(pron) // Output: '설' // Handles comma-separated const pronComma = pronunciation("샘솟을 집, 샘솟을 설") console.log(pronComma) // Output: '집' // Handles slash-separated const pronSlash = pronunciation("제비 연/잔치 연") console.log(pronSlash) // Output: '연' ``` ``` -------------------------------- ### pronunciation(c: string): string | null Source: https://context7.com/seyoungsong/hanjadict-js/llms.txt Extracts only the Sino-Korean pronunciation (음/音) — the last syllable of the first reading — from the dictionary entry. The function handles all special dictionary formats: comma-separated multiple readings, slash-separated alternate meanings, and parenthesised alternate pronunciations. Returns `null` for unknown characters. ```APIDOC ## pronunciation(c: string): string | null ### Description Extracts only the Sino-Korean pronunciation (음/音) — the last syllable of the first reading — from the dictionary entry. The function handles all special dictionary formats: comma-separated multiple readings, slash-separated alternate meanings, and parenthesised alternate pronunciations. Returns `null` for unknown characters. ### Parameters #### Path Parameters - **c** (string) - Required - The Hanja character to extract pronunciation from. ### Request Example ```javascript import { pronunciation } from "hanjadict" // Normal format: "눈 설" → "설" console.log(pronunciation("雪")) // "설" // Slash-separated: "제비 연/잔치 연" → takes first segment → "연" console.log(pronunciation("燕")) // "연" // Comma-separated: "샘솟을 집, 샘솟을 설" → takes first segment → "집" console.log(pronunciation("㴕")) // "집" // Parentheses: "영양 령(영)" → strips parens → "령" console.log(pronunciation("䴫")) // "령" // Unknown input console.log(pronunciation("xyz")) // null console.log(pronunciation("")) // null // Build a pronunciation index for an array of characters const chars = ["雪", "山", "水", "火", "木", "金", "土"] const pronunciationMap = Object.fromEntries( chars .map(c => [c, pronunciation(c)]) .filter(([, p]) => p !== null) ) console.log(pronunciationMap) // { "雪": "설", "山": "산", "水": "수", "火": "화", "木": "목", "金": "금", "土": "토" } ``` ### Response #### Success Response (200) - **string | null**: The pronunciation string or null if not found. ``` -------------------------------- ### isHanja(c: string): boolean Source: https://context7.com/seyoungsong/hanjadict-js/llms.txt Returns `true` if the given character exists in the HanjaDict dictionary, `false` otherwise. Useful for filtering or validating input before performing a full lookup. ```APIDOC ## isHanja(c: string): boolean ### Description Returns `true` if the given character exists in the HanjaDict dictionary, `false` otherwise. Useful for filtering or validating input before performing a full lookup. ### Parameters #### Path Parameters - **c** (string) - Required - The character to check. ### Request Example ```javascript import { isHanja } from "hanjadict" // Hanja characters console.log(isHanja("雪")) // true console.log(isHanja("山")) // true console.log(isHanja("水")) // true // Non-Hanja (Hangul, Latin, empty string) console.log(isHanja("한")) // false console.log(isHanja("A")) // false console.log(isHanja("")) // false // Practical use: split a mixed string into Hanja vs. non-Hanja const text = "雪山한글Water水" const hanjaChars = [...text].filter(c => isHanja(c)) const nonHanjaChars = [...text].filter(c => !isHanja(c)) console.log(hanjaChars) // ["雪", "山", "水"] console.log(nonHanjaChars) // ["한", "글", "W", "a", "t", "e", "r"] ``` ### Response #### Success Response (200) - **boolean**: `true` if the character is Hanja, `false` otherwise. ``` -------------------------------- ### isHanja(c) Source: https://github.com/seyoungsong/hanjadict-js/blob/master/README.md Checks if a given character is a valid Hanja present in the HanjaDict dictionary. ```APIDOC ## isHanja(c) ### Description Check if a character is a valid Hanja in the dictionary. ### Parameters #### Path Parameters - **c** (string) - Required - The character to check. ### Response #### Success Response (200) - Returns a boolean: `true` if the character is a Hanja in the dictionary, `false` otherwise. ### Request Example ```javascript import { isHanja } from "hanjadict" const isHanjaChar = isHanja("雪") console.log(isHanjaChar) // Output: true const notHanja = isHanja("a") console.log(notHanja) // Output: false ``` ``` -------------------------------- ### Check if a character is Hanja Source: https://context7.com/seyoungsong/hanjadict-js/llms.txt Use `isHanja` to determine if a character is present in the HanjaDict dictionary. Useful for input validation or filtering. ```typescript import { isHanja } from "hanjadict" // Hanja characters console.log(isHanja("雪")) // true console.log(isHanja("山")) // true console.log(isHanja("水")) // true // Non-Hanja (Hangul, Latin, empty string) console.log(isHanja("한")) // false console.log(isHanja("A")) // false console.log(isHanja("")) // false // Practical use: split a mixed string into Hanja vs. non-Hanja const text = "雪山한글Water水" const hanjaChars = [...text].filter(c => isHanja(c)) const nonHanjaChars = [...text].filter(c => !isHanja(c)) console.log(hanjaChars) // ["雪", "山", "水"] console.log(nonHanjaChars) // ["한", "글", "W", "a", "t", "e", "r"] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.