jamorasep.main ============== .. py:module:: jamorasep.main Attributes ---------- .. autoapisummary:: jamorasep.main.parse Classes ------- .. autoapisummary:: jamorasep.main.Kanamap jamorasep.main.Morasep Module Contents --------------- .. py:class:: Kanamap(kanamap_csv: Optional[str] = None) .. py:attribute:: kanamap .. py:method:: load_kanamap(kanamap_csv: Optional[str] = None) -> Dict[str, Dict[str, str]] .. py:method:: __call__(kana: str) -> Dict[str, str] .. py:method:: get_2letter_morae() -> List[str] .. py:method:: lst_katakana() -> List[str] .. py:method:: header() -> List[str] .. py:class:: Morasep(kanamap_csv: Optional[str] = None) .. py:attribute:: kanamap .. py:attribute:: two_letter_morae .. py:attribute:: subscript :value: ['ァ', 'ィ', 'ゥ', 'ェ', 'ォ', 'ャ', 'ュ', 'ョ', 'ヮ', 'ぁ', 'ぃ', 'ぅ', 'ぇ', 'ぉ', 'ゃ', 'ゅ', 'ょ', 'ゎ'] .. py:attribute:: upper .. py:method:: check_if_successive_2chars_compose_mora(i: str, j: str) -> List[str] Check if the successive 2 characters compose a mora. If so, return the mora. If not, return the list of morae depending on the relationship between the 2 characters. Rules: RULE 0: i + j forms a known two-letter mora (e.g., "キャ", "シュ") RULE 1: i is normal kana + j is subscript but not a valid mora -> convert subscript to normal (e.g., "カァ" -> ["カ", "ア"]) RULE 2: i is subscript + j is normal kana -> return [] (handled by previous pair) RULE 3: i is subscript + j is subscript -> convert j to normal (e.g., "ァァ" -> ["ア"]) RULE 4: Otherwise -> return [i] .. py:method:: kana2mora(txt: str) -> List[str] Convert a string of Japanese text (hiragana or katakana) into a list of morae. Symbols and characters other than hiragana/katakana are separated character-wise and returned without modification. .. rubric:: Example "あいうえお・きゃきゅきょ" -> ["あ", "い", "う", "え", "お", "・", "きゃ", "きゅ", "きょ"] :param txt: A string of Japanese text (hiragana or katakana). :returns: A list of morae. .. py:method:: modify_special_mora(morae: List[str]) -> List[str] Modify Q (ッ) in a romanized mora list. - If Q is the last mora, replace with a space. - If the next mora starts with a consonant, replace Q with that consonant. - If the next mora starts with a vowel or symbol, replace Q with a space. :param morae: A list of morae. :returns: A list of morae with Q replaced. .. py:method:: _convert_to_hiragana(lst: List[str]) -> List[str] .. py:method:: _convert_to_katakana(lst: List[str]) -> List[str] .. py:method:: _convert_to_other_format(lst: List[str], output_format: str) -> List[str] .. py:method:: convert_lst_of_mora(lst: List[str], output_format: str = 'katakana', phoneme: bool = False) -> List[str] Convert a list of morae into katakana, hiragana, or other formats. :param lst: A list of morae. :param output_format: The output format. Options are "katakana", "hiragana", and any column in kanamap.csv (e.g., "kunrei", "hepburn", "simple-ipa"). :param phoneme: If True, split the output into individual phonemes. Only effective when output_format is a romanization format. :returns: A list of morae in the specified format. .. py:method:: parse(txt: str = '', output_format: Optional[str] = None, phoneme: bool = False, **kwargs) -> List[str] Convert a kana string into a list of morae. :param txt: A string of katakana or hiragana. :param output_format: The output format. If None, return morae as-is. Options are "katakana", "hiragana", and any column in kanamap.csv (e.g., "kunrei", "hepburn", "simple-ipa"). :param phoneme: If True, split the output into individual phonemes. :returns: A list of morae. .. py:data:: parse