GithubHelp home page GithubHelp logo

自定义核心词库 about pinyin-pro HOT 8 CLOSED

tansongchen avatar tansongchen commented on July 29, 2024
自定义核心词库

from pinyin-pro.

Comments (8)

zh-lx avatar zh-lx commented on July 29, 2024

addDict 是用来让用户自定义词典的 api,在拼音转换时,会根据通过 addDict 添加的词的权重来定义优先级。
如果你要强制定义所有单字的读音,可以使用 customPinyin api,命中 customPinyin 的字词都会优先走这个 api 定义的读音

可以看下这个 api 是否能够解决你的问题

from pinyin-pro.

tansongchen avatar tansongchen commented on July 29, 2024

这个似乎也是在现有的基础上加,不是替换?

我的需求不光是单字,我是打算把「孩子」这种词都注成 hai2 zi3,不标轻声,词音和单字音一样

from pinyin-pro.

zh-lx avatar zh-lx commented on July 29, 2024

这个似乎也是在现有的基础上加,不是替换?

我的需求不光是单字,我是打算把「孩子」这种词都注成 hai2 zi3,不标轻声,词音和单字音一样

是覆盖,比如说 [孩子],你添加了 子: 'zǐ',所有文本中的子的转换结果都是

from pinyin-pro.

yisibl avatar yisibl commented on July 29, 2024

我的需求不光是单字,我是打算把「孩子」这种词都注成 hai2 zi3,不标轻声,词音和单字音一样

这个目前你只能把所有的词库中的轻声用 customPinyin 覆盖一遍,理想情况下,我们需要一个选项来控制是否开启轻声。

from pinyin-pro.

yisibl avatar yisibl commented on July 29, 2024

另外,《通用规范汉字字典》是指商务印书馆出版的这本吗?

请注意,在「通用规范汉字表」中,我们目前还缺少一些字,将在 #228 补充完整。

from pinyin-pro.

tansongchen avatar tansongchen commented on July 29, 2024

目前使用 customPinyin 可以成功自定义二字以上的词。但是,对于一字词,好像没有办法用 customPinyin 来实现所有的需求。例如,

describe("add custom pinyin", () => {
  it("should not interfere with predefined words", () => {
    customPinyin({ : "yín", : "xíng háng héng" });
    expect(pinyin("银行")).toEqual("yín háng");
  });
});
image

我的本意是把整个通规字典导入一遍,以保证程序注音的结果中没匹配到词的单字给注的音一定是字典中的音,但是导致本来成词的也跟着这个表走了


如果感觉这里的行为不太好自定义,那我也可以等 #228 做好之后再搞

from pinyin-pro.

zh-lx avatar zh-lx commented on July 29, 2024

目前使用 customPinyin 可以成功自定义二字以上的词。但是,对于一字词,好像没有办法用 customPinyin 来实现所有的需求。例如,

describe("add custom pinyin", () => {
  it("should not interfere with predefined words", () => {
    customPinyin({ : "yín", : "xíng háng héng" });
    expect(pinyin("银行")).toEqual("yín háng");
  });
});
image 我的本意是把整个通规字典导入一遍,以保证程序注音的结果中没匹配到词的单字给注的音一定是字典中的音,但是导致本来成词的也跟着这个表走了

如果感觉这里的行为不太好自定义,那我也可以等 #228 做好之后再搞

那我理解你只需要对于内置字典中所缺少的字导入一遍。你可以在通规字典导入时,对每个字先使用 pinyin api 转换下,如果转换结果和字本身相同,意味着内置字典缺少这个字。对于这些缺少的字再使用 customPinyin 导入

from pinyin-pro.

zh-lx avatar zh-lx commented on July 29, 2024

已在 3.22.0 版本中完整支持了通用汉字规范表中的字符

from pinyin-pro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.