Skip to content

[FEAT REQ] 允许导入输入法词库 #362

Open

Description

@WFLing-seaer

heteronym=1对长词十分不友好,因为其很容易导致笛卡尔积爆炸。
如果允许导入输入法词库,则可以使用输入法的无调拼音用于过滤多音字,极大降低笛卡尔积数。
导入源使用输入法是因为CC-CEDICT的覆盖面相对来说并不够全。

Activity

  1. mozillazg commented on Feb 15, 2026

    @mozillazg
    Owner

    @WFLing-seaer 你是想用输入法的无调拼音调整每个字的多音字数量吗?如果是这样的话,你可以基于输入法词库的拼音数据对 https://github.com/mozillazg/pinyin-data/blob/master/pinyin.txt 中的数据进行精简,然后使用 load_single_dict 导入精简后的数据就可以了(类似 https://github.com/mozillazg/pypinyin-dict 这个项目)。

  2. WFLing-seaer commented on Feb 23, 2026

    @WFLing-seaer
    Author

    其实主要问题——或许也是所有拼音库面临的最大问题——是,没有一个权威且全面的拼音数据源;因此只能用短词甚至单字的拼音来拼凑推测长词的拼音,而这势必会导致长词的拼音质量极大下降。并且人工标注亦不现实。您有无这方面的解决方案推荐?
    目前中文成词约300万±100万词(见薨词典项目,此项目很久没更新,可能稍有过时)。而其中具有明确拼音标注的大概只有百一到百五,而拼音中又有约有千一到万一有错误。因此这可能诚然是任重而道远的了……

    附阴间拼音案例若干:

    >>> from pypinyin_dict.phrase_pinyin_data import large_pinyin
    >>> large_pinyin.load()
    >>> pypinyin.pinyin("阿埃二氏病变",style=8,heteronym=1)
    [['a1', 'e1', 'e3', 'a3', 'a4', 'a'], ['ai1', 'zhi4'], ['er4'], ['shi4'], ['bing4'], ['bian4']]
    >>> pypinyin.pinyin("啊啊啊啊啊啊啊啊啊啊啊啊啊",style=8,heteronym=1)
    [['a', 'a1', 'a2', 'a3', 'a4', 'e4'], ['a', 'a1', 'a2', 'a3', 'a4', 'e4'], ['a', 'a1', 'a2', 'a3', 'a4', 'e4'], ['a', 'a1', 'a2', 'a3', 'a4', 'e4'], ['a', 'a1', 'a2', 'a3', 'a4', 'e4'], ['a', 'a1', 'a2', 'a3', 'a4', 'e4'], ['a', 'a1', 'a2', 'a3', 'a4', 'e4'], ['a', 'a1', 'a2', 'a3', 'a4', 'e4'], ['a', 'a1', 'a2', 'a3', 'a4', 'e4'], ['a', 'a1', 'a2', 'a3', 'a4', 'e4'], ['a', 'a1', 'a2', 'a3', 'a4', 'e4'], ['a', 'a1', 'a2', 'a3', 'a4', 'e4'], ['a', 'a1', 'a2', 'a3', 'a4', 'e4']]
    >>> pyperclip.paste()
    '㹧𱮒湖'
    >>> pypinyin.pinyin(_,style=8,heteronym=1)
    [['㹧'], ['𱮒'], ['hu2']]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions