naive_util.py 文件源码

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

项目:Ossian 作者: CSTR-Edinburgh 项目源码 文件源码
def int_to_alphabetic(number): 
    """Convert non-negative integer to base 26 representation using uppercase A-Z
    as symbols. Can use this instead of numbers in feature delimiters because:
        -- gives shorter full context model names (esp. with many features)
        -- trivially, split-context-balanced.py expects delimiters to contain no digits        
    """    
    assert number >= 0,"Function not intended to handle negative input values"    
    if number == 0:
        return string.uppercase[0]    
    alphabetic = ""
    current = number
    while current!=0:
        remainder = current % 26
        remainder_string = string.uppercase[remainder]        
        alphabetic = remainder_string + alphabetic
        current = current / 26
    return alphabetic
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号