num2words/lang_JA.py
def rendaku_merge_pairs(lpair, rpair):
    """Merge lpair < rpair while applying semi-irregular rendaku rules"""
    ltext, lnum = lpair
    rtext, rnum = rpair
    if lnum > rnum:
        raise ValueError

    if rpair == ("ひゃく", 100):
        if lpair == ("さん", 3):
            rtext = "びゃく"
        elif lpair == ("ろく", 6):
            ltext = "ろっ"
            rtext = "ぴゃく"
        elif lpair == ("はち", 8):
            ltext = "はっ"
            rtext = "ぴゃく"
    elif rpair == ("せん", 1000):
        if lpair == ("さん", 3):
            rtext = "ぜん"
        elif lpair == ("はち", 8):
            ltext = "はっ"
    elif rpair == ("ちょう", 10**12):
        if lpair == ("いち", 1):
            ltext = "いっ"
        elif lpair == ("はち", 8):
            ltext = "はっ"
        elif lpair == ("じゅう", 10):
            ltext = "じゅっ"
    elif rpair == ("けい", 10**16):
        if lpair == ("いち", 1):
            ltext = "いっ"
        elif lpair == ("ろく", 6):
            ltext = "ろっ"
        elif lpair == ("はち", 8):
            ltext = "はっ"
        elif lpair == ("じゅう", 10):
            ltext = "じゅっ"
        elif lpair == ("ひゃく", 100):
            ltext = "ひゃっ"

    return ("%s%s" % (ltext, rtext), lnum * rnum)
def rendaku_merge_pairs(lpair, rpair):
    """Merge lpair < rpair while applying semi-irregular rendaku rules"""
    ltext, lnum = lpair
    rtext, rnum = rpair
    if lnum > rnum:
        raise ValueError

    if rpair == ("ひゃく", 100):
        if lpair == ("さん", 3):
            rtext = "びゃく"
        elif lpair == ("ろく", 6):
            ltext = "ろっ"
            rtext = "ぴゃく"
        elif lpair == ("はち", 8):
            ltext = "はっ"
            rtext = "ぴゃく"
    elif rpair == ("せん", 1000):
        if lpair == ("さん", 3):
            rtext = "ぜん"
        elif lpair == ("はち", 8):
            ltext = "はっ"
    elif rpair == ("ちょう", 10**12):
        if lpair == ("いち", 1):
            ltext = "いっ"
        elif lpair == ("はち", 8):
            ltext = "はっ"
        elif lpair == ("じゅう", 10):
            ltext = "じゅっ"
    elif rpair == ("けい", 10**16):
        if lpair == ("いち", 1):
            ltext = "いっ"
        elif lpair == ("ろく", 6):
            ltext = "ろっ"
        elif lpair == ("はち", 8):
            ltext = "はっ"
        elif lpair == ("じゅう", 10):
            ltext = "じゅっ"
        elif lpair == ("ひゃく", 100):
            ltext = "ひゃっ"

    return ("%s%s" % (ltext, rtext), lnum * rnum)
Merge lpair < rpair while applying semi-irregular rendaku rules