### Character Normalization Examples (Python) Source: https://github.com/ikegami-yukino/jaconv/blob/master/README.rst Illustrates the character normalization capabilities of jaconv, focusing on expanding common Japanese Unicode variations to standard forms. Shows replacements for various dash and quotation mark characters. ```python # jaconv.normalize method expand unicodedata.normalize for Japanese language processing. # '〜' => 'ー' # '~' => 'ー' # " => " # '”'=> '"' # '“' => '``' # '―' => '-' # '‐' => '-' # '˗' => '-' # '֊' => '-' # '‐' => '-' # '‑' => '-' # '‒' => '-' # '–' => '-' # '⁃' => '-' # '⁻' => '-' # '₋' => '-' # '−' => '-' # '﹣' => 'ー' # '-' => 'ー' # '—' => 'ー' # '―' => 'ー' # '━' => 'ー' # '─' => 'ー' ``` -------------------------------- ### Basic Japanese Character Conversions (Python) Source: https://github.com/ikegami-yukino/jaconv/blob/master/README.rst Demonstrates fundamental conversions between Hiragana, Katakana, and their half-width/full-width variants using the jaconv library. Includes direct conversion functions and aliases. ```python import jaconv # Hiragana to Katakana jaconv.hira2kata('ともえまみ') # => 'トモエマミ' # Hiragana to half-width Katakana jaconv.hira2hkata('ともえまみ') # => 'トモエマミ' # Katakana to Hiragana jaconv.kata2hira('巴マミ') # => '巴まみ' # half-width character to full-width character # default parameters are followings: kana=True, ascii=False, digit=False jaconv.h2z('ティロ・フィナーレ') # => 'ティロ・フィナーレ' # half-width character to full-width character # but only ascii characters jaconv.h2z('abc', kana=False, ascii=True, digit=False) # => 'abc' # half-width character to full-width character # but only digit characters jaconv.h2z('123', kana=False, ascii=False, digit=True) # => '123' # half-width character to full-width character # except half-width Katakana jaconv.h2z('アabc123', kana=False, digit=True, ascii=True) # => 'アabc123' # an alias of h2z jaconv.hankaku2zenkaku('ティロ・フィナーレabc123') # => 'ティロ・フィナーレabc123' # full-width character to half-width character # default parameters are followings: kana=True, ascii=False, digit=False jaconv.z2h('ティロ・フィナーレ') # => 'ティロ・フィナーレ' # full-width character to half-width character # but only ascii characters jaconv.z2h('abc', kana=False, ascii=True, digit=False) # => 'abc' # full-width character to half-width character # but only digit characters jaconv.z2h('123', kana=False, ascii=False, digit=True) # => '123' # full-width character to half-width character # except full-width Katakana jaconv.z2h('アabc123', kana=False, digit=True, ascii=True) # => 'アabc123' # an alias of z2h jaconv.zenkaku2hankaku('ティロ・フィナーレabc123') # => 'ティロ・フィナーレabc123' ``` -------------------------------- ### Convert Half-width to Full-width Source: https://context7.com/ikegami-yukino/jaconv/llms.txt Uses h2z to convert half-width characters to full-width. Supports optional flags to include ASCII and digits in the conversion process. ```python import jaconv # Convert half-width Katakana to full-width (default behavior) result = jaconv.h2z('ティロ・フィナーレ') print(result) # Output: ティロ・フィナーレ # Ignore specific characters result = jaconv.h2z('ティロフィナーレ', ignore='ィ') print(result) # Output: ティロフィナーレ # Convert only ASCII characters (not Kana) result = jaconv.h2z('abc', kana=False, ascii=True) print(result) # Output: abc # Convert only digits result = jaconv.h2z('123', kana=False, digit=True) print(result) # Output: 123 # Convert ASCII and digits but not Kana result = jaconv.h2z('アabc123', kana=False, ascii=True, digit=True) print(result) # Output: アabc123 # Convert everything (Kana, ASCII, and digits) result = jaconv.h2z('ティロabc123', kana=True, ascii=True, digit=True) print(result) # Output: ティロabc123 # Using alias function result = jaconv.hankaku2zenkaku('ティロ・フィナーレabc123') print(result) # Output: ティロ・フィナーレabc123 ``` -------------------------------- ### Advanced Japanese Character Operations (Python) Source: https://github.com/ikegami-yukino/jaconv/blob/master/README.rst Covers advanced functionalities like character normalization, enlarging small Kana characters, and converting between Kana and alphabets using the jaconv library. Includes specific normalization forms and options for ignoring characters. ```python import jaconv # normalize jaconv.normalize('ティロ・フィナ〜レ', 'NFKC') # => 'ティロ・フィナーレ' # Convert small Hiragana or Katakana to normal size jaconv.enlarge_smallkana('わぁい') # => 'わあい' jaconv.enlarge_smallkana('きょういっぱい', ignore='っ') # => 'きよういっぱい' # Hiragana to alphabet jaconv.kana2alphabet('じゃぱん') # => 'japan' # Alphabet to Hiragana jaconv.alphabet2kana('japan') # => 'じゃぱん' # Katakana to Alphabet jaconv.kata2alphabet('ケツイ') # => 'ketsui' # Alphabet to Katakana jaconv.alphabet2kata('namba') # => 'ナンバ' # Hiragana to Julius's phoneme format jaconv.hiragana2julius('てんきすごくいいいいいい') # => 't e N k i s u g o k u i:' ``` -------------------------------- ### Convert Full-width to Half-width Source: https://context7.com/ikegami-yukino/jaconv/llms.txt Uses z2h to convert full-width characters to half-width. Provides parameters to toggle conversion for Kana, ASCII, and digits. ```python import jaconv # Convert full-width Katakana to half-width (default behavior) result = jaconv.z2h('ティロフィナーレ') print(result) # Output: ティロフィナーレ # Ignore specific characters during conversion result = jaconv.z2h('ティロフィナーレ', ignore='ィ') print(result) # Output: ティロフィナーレ # Convert only ASCII characters to half-width result = jaconv.z2h('abc', kana=False, ascii=True) print(result) # Output: abc # Convert only digits to half-width result = jaconv.z2h('123', kana=False, digit=True) print(result) # Output: 123 # Convert ASCII and digits but not Katakana result = jaconv.z2h('アabc123', kana=False, ascii=True, digit=True) print(result) # Output: アabc123 ``` -------------------------------- ### Unicode Normalization for Japanese Text Source: https://context7.com/ikegami-yukino/jaconv/llms.txt Performs Unicode normalization, primarily NFKC, with enhanced support for Japanese characters. It handles variants of wave dash, different dash types, and quotation marks, ensuring consistent text representation. ```python import jaconv # Normalize Japanese text with wave dash and mixed widths result = jaconv.normalize('ティロ・フィナ〜レ', 'NFKC') print(result) # Output: ティロ・フィナーレ # Normalize text with various dash types result = jaconv.normalize('東京―大阪', 'NFKC') print(result) # Output: 東京-大阪 # Normalize smart quotes result = jaconv.normalize('"Hello"', 'NFKC') print(result) # Output: "Hello" # Handle full-width wave dash variants (〜, ~) -> Katakana prolonged sound mark (ー) result = jaconv.normalize('ゲーム〜', 'NFKC') print(result) # Output: ゲームー ``` -------------------------------- ### Romaji to Hiragana Source: https://context7.com/ikegami-yukino/jaconv/llms.txt Converts Roman alphabet input to Hiragana using Japanese input method rules. ```APIDOC ## alphabet2kana - Romaji to Hiragana ### Description Converts Roman alphabet input to Hiragana using Japanese input method rules. Supports various romanization systems including Hepburn and Kunrei-shiki. Handles double consonants, long vowels, and special character combinations. ### Method `jaconv.alphabet2kana(text)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **text** (string) - Required - The Romanized text to convert. ### Request Example ```python import jaconv # Basic romaji to Hiragana result = jaconv.alphabet2kana('mamisan') print(result) # Output: まみさん # Double consonants automatically create っ result = jaconv.alphabet2kana('doggu doguu') print(result) # Output: どっぐ どぐう result = jaconv.alphabet2kana('botchi') print(result) # Output: ぼっち # Complex foreign word representation result = jaconv.alphabet2kana('fainarufantaji-') print(result) # Output: ふぁいなるふぁんたじー # Various romanization patterns result = jaconv.alphabet2kana('atsui') print(result) # Output: あつい # Final 'h' converts to う (common in names like Itoh) result = jaconv.alphabet2kana('itoh') print(result) # Output: いとう # 'oh' pattern for long 'o' sound result = jaconv.alphabet2kana('ohtaku') print(result) # Output: おおたく ``` ### Response #### Success Response (200) - **result** (string) - The converted Hiragana text. ``` -------------------------------- ### Convert Hiragana to Julius Phoneme Format using jaconv Source: https://context7.com/ikegami-yukino/jaconv/llms.txt Converts Hiragana text into the phoneme format required by the Julius speech recognition engine. It correctly handles Japanese phonetic rules, including long vowels (':'), the moraic nasal 'N', and geminate consonants ('q'). This is valuable for speech synthesis and recognition applications. ```python import jaconv # Basic phoneme conversion result = jaconv.hiragana2julius('てんき') print(result) # Output: t e N k i # Double consonants become 'q' result = jaconv.hiragana2julius('やったー') print(result) # Output: y a q t a: # Long vowels with repeated characters result = jaconv.hiragana2julius('かわいいいいい') print(result) # Output: k a w a i: # Long 'o' sound (おう becomes o:) result = jaconv.hiragana2julius('やろうぜ') print(result) # Output: y a r o: z e # Complex sentence with multiple features result = jaconv.hiragana2julius('てんきすごくいいいいいい') print(result) # Output: t e N k i s u g o k u i: ``` -------------------------------- ### Convert Romaji to Hiragana using jaconv Source: https://context7.com/ikegami-yukino/jaconv/llms.txt Converts Roman alphabet input to Hiragana. It handles specific phonetic rules like 'n' before certain consonants becoming 'ん' and accepts both 'si'/'shi' for 'し'. The 'nn' combination is used to represent 'ん'. ```python import jaconv # 'm' before certain consonants becomes ん result = jaconv.alphabet2kana('namba') print(result) # Output: なんば # Both si/shi work for し result = jaconv.alphabet2kana('siba') print(result) # Output: しば result = jaconv.alphabet2kana('shiba') print(result) # Output: しば # nn creates ん result = jaconv.alphabet2kana('hannei') print(result) # Output: はんえい ``` -------------------------------- ### Expand Small Kana Source: https://context7.com/ikegami-yukino/jaconv/llms.txt Converts small Hiragana or Katakana characters to their normal-sized equivalents, useful for text normalization. ```APIDOC ## enlarge_smallkana - Expand Small Kana to Normal Size ### Description Converts small Hiragana or Katakana characters (like ぁ, ぃ, ゅ, ょ, etc.) to their normal-sized equivalents. This is useful for text normalization in search applications or when processing text where small kana distinctions are not important. The optional `ignore` parameter allows specific small kana to be preserved. ### Method `jaconv.enlarge_smallkana(text, ignore=None)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **text** (string) - Required - The input text containing small kana. - **ignore** (string or None) - Optional - A string of characters to ignore during conversion. If None, all small kana are converted. ### Request Example ```python import jaconv # Convert small kana in Hiragana result = jaconv.enlarge_smallkana('わぁい') print(result) # Output: わあい # Convert small kana in Katakana result = jaconv.enlarge_smallkana('キュゥべえ') print(result) # Output: キユウべえ # Ignore specific small kana during conversion result = jaconv.enlarge_smallkana('きょういっぱい', ignore='っ') print(result) # Output: きよういっぱい # Ignore multiple characters result = jaconv.enlarge_smallkana('きょういっぱい', ignore='ょっ') print(result) # Output: きょういっぱい # Handle special Katakana in Kanji compounds result = jaconv.enlarge_smallkana('霞ヶ関') print(result) # Output: 霞ケ関 result = jaconv.enlarge_smallkana('一ヵ月') print(result) # Output: 一カ月 ``` ### Response #### Success Response (200) - **result** (string) - The text with small kana expanded. ``` -------------------------------- ### Convert Full-width to Half-width Characters Source: https://context7.com/ikegami-yukino/jaconv/llms.txt Converts full-width alphanumeric characters and symbols to their half-width equivalents. This is useful for standardizing text input or processing. ```python import jaconv result = jaconv.zenkaku2hankaku('ティロ・フィナーレabc123') print(result) # Output: ティロ・フィナーレabc123 ``` -------------------------------- ### Unicode Normalization Source: https://context7.com/ikegami-yukino/jaconv/llms.txt Performs Unicode normalization for Japanese text, handling specific character variants like wave dashes and quotation marks. The default mode is 'NFKC'. ```APIDOC ## normalize - Unicode Normalization for Japanese ### Description Performs Unicode normalization with enhanced support for Japanese-specific character variants. This function extends Python's `unicodedata.normalize()` by handling wave dash variants, various dash/hyphen characters, and quotation marks commonly found in Japanese text. The default mode is 'NFKC'. ### Method `jaconv.normalize(text, mode='NFKC')` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **text** (string) - Required - The Japanese text to normalize. - **mode** (string) - Optional - The Unicode normalization form (e.g., 'NFKC', 'NFC', 'NFKD', 'NKFD'). Defaults to 'NFKC'. ### Request Example ```python import jaconv # Normalize Japanese text with wave dash and mixed widths result = jaconv.normalize('ティロ・フィナ〜レ', 'NFKC') print(result) # Output: ティロ・フィナーレ # Normalize text with various dash types result = jaconv.normalize('東京―大阪', 'NFKC') print(result) # Output: 東京-大阪 # Normalize smart quotes result = jaconv.normalize('"Hello"', 'NFKC') print(result) # Output: "Hello" # Handle full-width wave dash variants (〜, ~) -> Katakana prolonged sound mark (ー) result = jaconv.normalize('ゲーム〜', 'NFKC') print(result) # Output: ゲームー ``` ### Response #### Success Response (200) - **result** (string) - The normalized Japanese text. ``` -------------------------------- ### Katakana to Romaji Source: https://context7.com/ikegami-yukino/jaconv/llms.txt Converts Katakana text to Roman alphabet representation, useful for loanwords and foreign names. ```APIDOC ## kata2alphabet - Katakana to Romaji ### Description Converts Katakana text to Roman alphabet representation. Internally converts Katakana to Hiragana first, then applies romanization rules. Useful for converting loanwords and foreign names to ASCII-compatible format. ### Method `jaconv.kata2alphabet(text)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **text** (string) - Required - The Katakana text to convert. ### Request Example ```python import jaconv # Basic Katakana to romaji conversion result = jaconv.kata2alphabet('マミサン') print(result) # Output: mamisan # Foreign words with double consonants result = jaconv.kata2alphabet('ドッグ') print(result) # Output: doggu # Long vowels result = jaconv.kata2alphabet('ドグー') print(result) # Output: doguu # Complex words result = jaconv.kata2alphabet('ファイナルファンタジー') print(result) # Output: fainarufantaji- result = jaconv.kata2alphabet('ケツイ') print(result) # Output: ketsui ``` ### Response #### Success Response (200) - **result** (string) - The Romanized text. ``` -------------------------------- ### Convert Hiragana to Full-width Katakana Source: https://context7.com/ikegami-yukino/jaconv/llms.txt Uses hira2kata to transform Hiragana characters into full-width Katakana. Supports an optional ignore parameter to preserve specific characters during the conversion process. ```python import jaconv # Basic Hiragana to Katakana conversion result = jaconv.hira2kata('ともえまみ') print(result) # Output: トモエマミ # Convert with specific characters ignored result = jaconv.hira2kata('まどまぎ', ignore='ど') print(result) # Output: マどマギ # Mixed text - only Hiragana is converted result = jaconv.hira2kata('こんにちは世界') print(result) # Output: コンニチハ世界 ``` -------------------------------- ### Hiragana to Romaji Source: https://context7.com/ikegami-yukino/jaconv/llms.txt Converts Hiragana text to Roman alphabet representation using standard Japanese romanization rules. ```APIDOC ## kana2alphabet - Hiragana to Romaji ### Description Converts Hiragana text to Roman alphabet representation using standard Japanese romanization rules. Handles special cases like double consonants (っ), long vowels, and combination characters (拗音). Small tsu (っ) at the end of words is converted to 'xtsu'. ### Method `jaconv.kana2alphabet(text)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **text** (string) - Required - The Hiragana text to convert. ### Request Example ```python import jaconv # Basic Hiragana to romaji conversion result = jaconv.kana2alphabet('まみさん') print(result) # Output: mamisan # Handle double consonants (っ) result = jaconv.kana2alphabet('はっとり') print(result) # Output: hattori # Trailing small tsu result = jaconv.kana2alphabet('はっ') print(result) # Output: haxtsu # F-sounds result = jaconv.kana2alphabet('ふぁふぃふぇふぉ') print(result) # Output: fafifefo # Multiple small tsu result = jaconv.kana2alphabet('っって') print(result) # Output: xtsutte # V-sounds (using ゔ) result = jaconv.kana2alphabet('ゔぃーた') print(result) # Output: vi-ta # Combination characters (拗音) result = jaconv.kana2alphabet('きゅ') print(result) # Output: kyu result = jaconv.kana2alphabet('りゅう') print(result) # Output: ryuu ``` ### Response #### Success Response (200) - **result** (string) - The Romanized text. ``` -------------------------------- ### Expand Small Kana to Normal Size Source: https://context7.com/ikegami-yukino/jaconv/llms.txt Converts small Hiragana and Katakana characters to their normal-sized equivalents. This function is useful for text normalization, especially in search functionalities, and can optionally ignore specific characters. ```python import jaconv # Convert small kana in Hiragana result = jaconv.enlarge_smallkana('わぁい') print(result) # Output: わあい # Convert small kana in Katakana result = jaconv.enlarge_smallkana('キュゥべえ') print(result) # Output: キユウべえ # Ignore specific small kana during conversion result = jaconv.enlarge_smallkana('きょういっぱい', ignore='っ') print(result) # Output: きよういっぱい # Ignore multiple characters result = jaconv.enlarge_smallkana('きょういっぱい', ignore='ょっ') print(result) # Output: きょういっぱい # Handle special Katakana in Kanji compounds result = jaconv.enlarge_smallkana('霞ヶ関') print(result) # Output: 霞ケ関 result = jaconv.enlarge_smallkana('一ヵ月') print(result) # Output: 一カ月 ``` -------------------------------- ### Convert Katakana to Hiragana Source: https://context7.com/ikegami-yukino/jaconv/llms.txt Uses kata2hira to transform full-width Katakana into Hiragana. Non-Katakana characters are preserved, making this useful for text normalization. ```python import jaconv # Basic Katakana to Hiragana conversion result = jaconv.kata2hira('巴マミ') print(result) # Output: 巴まみ # Ignore specific characters during conversion result = jaconv.kata2hira('マミサン', ignore='ン') print(result) # Output: まみさン # Full sentence with mixed content result = jaconv.kata2hira('ティロフィナーレ') print(result) # Output: てぃろふぃなーれ ``` -------------------------------- ### Convert Hiragana to Half-width Katakana Source: https://context7.com/ikegami-yukino/jaconv/llms.txt Uses hira2hkata to transform Hiragana characters into half-width Katakana, often used in legacy systems or fixed-width database fields. ```python import jaconv # Basic conversion to half-width Katakana result = jaconv.hira2hkata('ともえまみ') print(result) # Output: トモエマミ # Exclude specific characters from conversion result = jaconv.hira2hkata('ともえまみ', ignore='み') print(result) # Output: トモエマみ # Convert longer text result = jaconv.hira2hkata('さくらもち') print(result) # Output: サクラモチ ``` -------------------------------- ### Convert Romaji to Katakana using jaconv Source: https://context7.com/ikegami-yukino/jaconv/llms.txt Converts Roman alphabet input directly to Katakana. This function is useful for representing foreign words and names in their Katakana form. It internally uses alphabet2kana followed by a Hiragana to Katakana conversion. ```python import jaconv # Basic romaji to Katakana result = jaconv.alphabet2kata('mamisan') print(result) # Output: マミサン # Foreign names result = jaconv.alphabet2kata('namba') print(result) # Output: ナンバ # Loanwords result = jaconv.alphabet2kata('kompyuutaa') print(result) # Output: コンピューター result = jaconv.alphabet2kata('sofutowea') print(result) # Output: ソフトウエア ``` -------------------------------- ### Convert Romaji to Hiragana Source: https://context7.com/ikegami-yukino/jaconv/llms.txt Converts Roman alphabet input into Hiragana, mimicking Japanese input method behavior. It supports various romanization systems and correctly handles double consonants, long vowels, and specific character combinations. ```python import jaconv # Basic romaji to Hiragana result = jaconv.alphabet2kana('mamisan') print(result) # Output: まみさん # Double consonants automatically create っ result = jaconv.alphabet2kana('doggu doguu') print(result) # Output: どっぐ どぐう result = jaconv.alphabet2kana('botchi') print(result) # Output: ぼっち # Complex foreign word representation result = jaconv.alphabet2kana('fainarufantaji-') print(result) # Output: ふぁいなるふぁんたじー # Various romanization patterns result = jaconv.alphabet2kana('atsui') print(result) # Output: あつい # Final 'h' converts to う (common in names like Itoh) result = jaconv.alphabet2kana('itoh') print(result) # Output: いとう # 'oh' pattern for long 'o' sound result = jaconv.alphabet2kana('ohtaku') print(result) # Output: おおたく ``` -------------------------------- ### Convert Hiragana to Romaji Source: https://context7.com/ikegami-yukino/jaconv/llms.txt Converts Hiragana text to its Roman alphabet representation using standard Japanese romanization rules. It handles double consonants, long vowels, and combination characters (拗音), with special handling for trailing small tsu. ```python import jaconv # Basic Hiragana to romaji conversion result = jaconv.kana2alphabet('まみさん') print(result) # Output: mamisan # Handle double consonants (っ) result = jaconv.kana2alphabet('はっとり') print(result) # Output: hattori # Trailing small tsu result = jaconv.kana2alphabet('はっ') print(result) # Output: haxtsu # F-sounds result = jaconv.kana2alphabet('ふぁふぃふぇふぉ') print(result) # Output: fafifefo # Multiple small tsu result = jaconv.kana2alphabet('っって') print(result) # Output: xtsutte # V-sounds (using ゔ) result = jaconv.kana2alphabet('ゔぃーた') print(result) # Output: vi-ta # Combination characters (拗音) result = jaconv.kana2alphabet('きゅ') print(result) # Output: kyu result = jaconv.kana2alphabet('りゅう') print(result) # Output: ryuu ``` -------------------------------- ### Convert Katakana to Romaji Source: https://context7.com/ikegami-yukino/jaconv/llms.txt Converts Katakana text to its Roman alphabet representation by first converting it to Hiragana. This function is useful for standardizing loanwords and foreign names into an ASCII-compatible format. ```python import jaconv # Basic Katakana to romaji conversion result = jaconv.kata2alphabet('マミサン') print(result) # Output: mamisan # Foreign words with double consonants result = jaconv.kata2alphabet('ドッグ') print(result) # Output: doggu # Long vowels result = jaconv.kata2alphabet('ドグー') print(result) # Output: doguu # Complex words result = jaconv.kata2alphabet('ファイナルファンタジー') print(result) # Output: fainarufantaji- result = jaconv.kata2alphabet('ケツイ') print(result) # Output: ketsui ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.