def match_pinyin(pinyin1, pinyin2):
    """Similarity score between two pinyin.
    计算两个拼音的相似度得分。
    """
    assert pinyin1 != '', 'pinyin1 can not be empty'
    assert pinyin2 != '', 'pinyin2 can not be empty'
    pv_match = 0
    if len(pinyin1) < len(pinyin2):
        len_short = len(pinyin1)
        len_long = len(pinyin2)
        pv_long = pinyin2
        pv_short = pinyin1
    else:
        len_short = len(pinyin2)
        len_long = len(pinyin1)
        pv_long = pinyin1
        pv_short = pinyin2
    for i in range(0, len_short):
        if pv_short[i] == pv_long[i]:
            pv_match += 1
    score = pv_match / len_long
    return score
