Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pinyin-pro

Package Overview
Dependencies
Maintainers
1
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pinyin-pro - npm Package Compare versions

Comparing version 3.21.0 to 3.21.1

2

package.json
{
"name": "pinyin-pro",
"version": "3.21.0",
"version": "3.21.1",
"description": "准确率和性能最优异的汉字转拼音库。获取中文拼音、韵母、声母、声调、首字母,支持拼音匹配",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -71,31 +71,2 @@ <a href="https://github.com/zh-lx/pinyin-pro"><img src="https://cdn.jsdelivr.net/gh/zh-lx/static-img/pinyin-pro/logo.svg" alt="logo" width="500" /></a>

- 使用词典,获取更准确的拼音。( `pinyin-pro` 内置了一些高频常用词的词典,想要保证高准确率,需要应用更完备的词典)
```js
import { pinyin, addDict } from "pinyin-pro";
// 引入前需要先通过 `npm install @pinyin-pro/data` 进行安装
import ModernChineseDict from "@pinyin-pro/data/modern.json";
import CompleteDict from "@pinyin-pro/data/complete.json";
// 默认使用内置的简单词典
const result1 = pinyin(
"小明硕士毕业于中国科学院计算所,后在日本京都大学深造"
);
// 结果: xiǎo míng shuò shì bì yè yú zhōng guó kē xué yuàn jì suàn suǒ , hòu zài rì běn jīng dōu dà xué shēn zào
// 使用现代汉语词典数据(gzip压缩后大概0.6MB,根据自己的需求决定是否使用)
addDict(ModernChineseDict);
const result2 = pinyin(
"小明硕士毕业于中国科学院计算所,后在日本京都大学深造"
);
// 结果: xiǎo míng shuò shì bì yè yú zhōng guó kē xué yuàn jì suàn suǒ , hòu zài rì běn jīng dū dà xué shēn zào
// 使用完备词典数据(词汇量更全,拼音转换率更加准确,gzip压缩后大概3.99MB,根据自己的需求决定是否使用)
addDict(CompleteDict);
const result3 = pinyin(
"小明硕士毕业于中国科学院计算所,后在日本京都大学深造"
);
// 结果: xiǎo míng shuò shì bì yè yú zhōng guó kē xué yuàn jì suàn suǒ , hòu zài rì běn jīng dū dà xué shēn zào
```
- 文本和拼音匹配,更多匹配规则请查看[match API](https://pinyin-pro.cn/use/match)

@@ -102,0 +73,0 @@

type DICT = {
[key: string]: string | [string] | [string, number] | [string, number, string];
};
export declare function addDict(dict: DICT | {}, name?: string): void;
export declare function removeDict(dictName: string): void;
type DictOptions = {
name?: string;
dict1?: "add" | "replace" | "ignore";
};
export declare function addDict(dict: DICT | {}, options?: string | DictOptions): void;
export declare function removeDict(dictName?: string): void;
export {};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc