# Path: cjktools/kana_table.py
# class KanaTable(object):
#     def __init__(self):
#     def _build_dicts(self):
#     def get_coords(self, kana):
#     def from_coords(self, consonant, vowel):
#     def to_vowel_line(self, kana):
#     def to_consonant_line(self, kana):
#     def is_voiced(self, kana):
#     def is_semivoiced(self, kana):
#     def get_table(self):
#     def get_cached(cls):
#     def __repr__(self):
# 
# Path: cjktools/scripts.py
# class Script(Enum):
# class ScriptMapping:
#     def __init__(self, from_script, to_script):
#     def __call__(self, j_string):
# def normalize_ascii(j_string):
# def normalize_kana(j_string):
# def normalize(j_string):
# def get_script(script):
# def compare_kana(j_string_a, j_string_b):
# def contains_script(script, j_string):
# def script_type(char):
# def script_boundaries(j_string):
# def script_types(j_string):
# def unique_kanji(j_string):
# 
# Path: cjktools/maps.py
# def chain_mapping(*dictionaries):
# def invert_mapping(dictionary):
# def is_injective(dictionary):
# def invert_injective_mapping(dictionary):
# def map_dict(method, dictionary, in_place=False):
# def multi_dict(input_pairs):
# def procmap(method, item_list):
# def merge_dicts(*args):
# def partial_map(method, object_seq):
# def filtered_map(method, object_list):


from cjktools import kana_table
from cjktools import scripts
from cjktools import maps
from six import unichr as chr
from six import iteritems
from itertools import product
import re


def _create_voicing_map():
    """
    Constructs map from kana to their voiced alternatives.
    """
    table = kana_table.KanaTable.get_cached().get_table()
    voiced_line = table['か'] + table['さ'] + table['た']
    double_voiced_line = table['は']

    voicing_map = {}
    for kana in scripts.get_script(scripts.Script.Hiragana):
        ord_kana = ord(kana)

        if kana in voiced_line:
            voicing_map[kana] = [chr(ord_kana+1)]
        elif kana in double_voiced_line:
            voicing_map[kana] = [chr(ord_kana+1), chr(ord_kana+2)]
        else:
            voicing_map[kana] = []

    # Add katakana into the mix
    katakana_vm = {scripts.to_katakana(k): list(map(scripts.to_katakana, v))
                   for k, v in iteritems(voicing_map)}

    voicing_map.update(katakana_vm)

    return voicing_map

to_voiced = _create_voicing_map()

# Path: cjktools/kana_table.py
# class KanaTable(object):
#     def __init__(self):
#     def _build_dicts(self):
#     def get_coords(self, kana):
#     def from_coords(self, consonant, vowel):
#     def to_vowel_line(self, kana):
#     def to_consonant_line(self, kana):
#     def is_voiced(self, kana):
#     def is_semivoiced(self, kana):
#     def get_table(self):
#     def get_cached(cls):
#     def __repr__(self):
# 
# Path: cjktools/scripts.py
# class Script(Enum):
# class ScriptMapping:
#     def __init__(self, from_script, to_script):
#     def __call__(self, j_string):
# def normalize_ascii(j_string):
# def normalize_kana(j_string):
# def normalize(j_string):
# def get_script(script):
# def compare_kana(j_string_a, j_string_b):
# def contains_script(script, j_string):
# def script_type(char):
# def script_boundaries(j_string):
# def script_types(j_string):
# def unique_kanji(j_string):
# 
# Path: cjktools/maps.py
# def chain_mapping(*dictionaries):
# def invert_mapping(dictionary):
# def is_injective(dictionary):
# def invert_injective_mapping(dictionary):
# def map_dict(method, dictionary, in_place=False):
# def multi_dict(input_pairs):
# def procmap(method, item_list):
# def merge_dicts(*args):
# def partial_map(method, object_seq):
# def filtered_map(method, object_list):


# Path: cjktools/alternations.py
from cjktools import kana_table
from cjktools import scripts
from cjktools import maps
from six import unichr as chr
from six import iteritems
from itertools import product
import re



def _create_voicing_map():
    """
    Constructs map from kana to their voiced alternatives.
    """
    table = kana_table.KanaTable.get_cached().get_table()
    voiced_line = table['か'] + table['さ'] + table['た']
    double_voiced_line = table['は']

    voicing_map = {}
    for kana in scripts.get_script(scripts.Script.Hiragana):
        ord_kana = ord(kana)

        if kana in voiced_line:
            voicing_map[kana] = [chr(ord_kana+1)]
        elif kana in double_voiced_line:
            voicing_map[kana] = [chr(ord_kana+1), chr(ord_kana+2)]
        else:
            voicing_map[kana] = []

    # Add katakana into the mix
    katakana_vm = {scripts.to_katakana(k): list(map(scripts.to_katakana, v))
                   for k, v in iteritems(voicing_map)}

    voicing_map.update(katakana_vm)

    return voicing_map

to_voiced = _create_voicing_map()

from_voiced = maps.invert_mapping(to_voiced)