Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

乾字转化有问题,转成了干 #24

Open
itstudygeen opened this issue May 31, 2024 · 2 comments
Open

乾字转化有问题,转成了干 #24

itstudygeen opened this issue May 31, 2024 · 2 comments

Comments

@itstudygeen
Copy link

松原市乾安县远辉新能源发展有限公司 转化成了 松原市干安县远辉新能源发展有限公司

const converter = OpenCC.Converter({ from: 'hk', to: 'cn' });
const result = converter('松原市乾安县远辉新能源发展有限公司');
console.log(result); // 结果为: 松原市干安县远辉新能源发展有限公司

见图:

image

@ren1244
Copy link
Collaborator

ren1244 commented Jun 9, 2024

You may try adding word mapping.

const customHkToCn = [
    ['乾安', '乾安'],
];
const converter = OpenCC.ConverterFactory(
    OpenCC.Locale.from.hk,
    OpenCC.Locale.to.cn.concat([customHkToCn])
);
console.log(converter('松原市乾安县远辉新能源发展有限公司'));

@itstudygeen
Copy link
Author

好的,谢谢,按照你的方法,问题已解决

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants