utils.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:basis_speech 作者: CPUFronz 项目源码 文件源码
def phone_to_num(phone_values):
    """Converts all phone strings into numerical values.

    This helper function iterates over a set of different phones and returns an
    alphabetically orderd directory where the phone string is the key and the
    numerical value is the corrosponding value.

    :params phone_values: a set (or list) of phone values
    :returns: an ordered directory with the numerical values as values
    """
    phone_values = OrderedDict.fromkeys(sorted(phone_values))
    for i,k in enumerate(phone_values.keys()):
        phone_values[k] = i
    phone_values['None'] = -1
    return phone_values
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号