Convert numbered pinyin to pinyin with tone marks

前端 未结 7 1139
春和景丽
春和景丽 2021-02-04 02:40

Are there any scripts, libraries, or programs using Python, or BASH tools (e.g. awk, perl, sed) which can correc

7条回答
  •  离开以前
    2021-02-04 02:58

    With python dragonmapper (pip install dragonmapper):

    Hanzi to pinyin

    from dragonmapper.transcriptions import hanzi
    
    hanzi.to_pinyin("过河拆桥。")
    # >>> 'guòhéchāiqiáo。'
    
    hanzi.to_pinyin("过河拆桥。", accented=False)
    # >>> 'guo4he2chai1qiao2。'
    

    Accented pinyin to numbered pinyin

    from dragonmapper.transcriptions import accented_to_numbered
    
    accented_to_numbered('guò hé chāi qiáo。')
    # >>> 'guo4 he2 chai1 qiao2。'
    

    Numbered pinyin to accented pinyin

    from dragonmapper.transcriptions import numbered_to_accented
    
    numbered_to_accented('guo4 he2 chai1 qiao2。')
    # >>> 'guò hé chāi qiáo。'
    

    DISCLAIMER: I have no connection with the dragonmapper author

提交回复
热议问题