Skip to content

Commit

Permalink
fix(3.7.1): 修复 “嗯” 在 toneType: 'none' 下拼音转换错误的问题
Browse files Browse the repository at this point in the history
fix(3.7.1): 修复 “嗯” 在 `toneType: 'none'` 下拼音转换错误的问题
  • Loading branch information
zh-lx authored Jan 11, 2022
2 parents 780c8be + 96ee344 commit b3c0128
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 26 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## 3.7.0

当前版本: 3.7.0 -> 3.7.1

- 修复问题
- 修复 “嗯” 在 `toneType: 'none'` 下拼音转换错误的问题

## 3.7.0

当前版本: 3.6.2 -> 3.7.0

- 使用完善
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@

## 版本更新

当前版本: 3.6.2 -> 3.7.0
当前版本: 3.7.0 -> 3.7.1

- 使用完善
- 增加 esm 引入方式
- 完善测试用例
- 修复问题
- 修复 “嗯” 在 `toneType: 'none'` 下拼音转换错误的问题

点击查看 [版本更新文档](./CHANGELOG.md)

Expand Down Expand Up @@ -60,14 +59,14 @@ yarn add pinyin-pro
</script>
```

ESModule 引入
commonjs 浏览器引入

```javascript
import { pinyin } from 'pinyin-pro';
pinyin('汉语拼音'); // 'hàn yǔ pīn yīn'
```

commonjs 引入:
commonjs node 引入:

```javascript
const { pinyin } = require('pinyin-pro');
Expand Down
2 changes: 1 addition & 1 deletion data/dict1-pinyin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4595,7 +4595,7 @@ export const DICT1: { [prop: string]: string } = {
: 'lán',
: 'làng',
: 'miǎo',
: 'ňg',
: 'ǹg ńg ňg',
: 'niū',
: 'òu',
: 'qiàng',
Expand Down
2 changes: 1 addition & 1 deletion data/dict1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4595,7 +4595,7 @@ DICT1[37124] = 'juàn';
DICT1[35124] = 'lán';
DICT1[38406] = 'làng';
DICT1[32520] = 'miǎo';
DICT1[21999] = 'ňg';
DICT1[21999] = 'ǹg ńg ňg';
DICT1[22942] = 'niū';
DICT1[27812] = 'òu';
DICT1[36292] = 'qiàng';
Expand Down
2 changes: 1 addition & 1 deletion dist/index.cjs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/pinyin-pro.js

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions docs/3.7.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@

## 版本更新

当前版本: 3.6.2 -> 3.7.0
当前版本: 3.7.0 -> 3.7.1

- 使用完善
- 增加 esm 引入方式
- 完善测试用例
- 修复问题
- 修复 “嗯” 在 `toneType: 'none'` 下拼音转换错误的问题

点击查看 [版本更新文档](./CHANGELOG.md)

Expand Down Expand Up @@ -60,14 +59,14 @@ yarn add pinyin-pro
</script>
```

ESModule 引入
commonjs 浏览器引入

```javascript
import { pinyin } from 'pinyin-pro';
pinyin('汉语拼音'); // 'hàn yǔ pīn yīn'
```

commonjs 引入:
commonjs node 引入:

```javascript
const { pinyin } = require('pinyin-pro');
Expand Down
4 changes: 1 addition & 3 deletions lib/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ export const getCustomDict = () => {

export function hasCustomConfig() {
for (let key in customDict) {
if (key) {
return true;
}
return true;
}
return false;
}
11 changes: 6 additions & 5 deletions lib/handle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ const getPinyinWithoutTone: GetPinyinWithoutTone = (pinyin) => {
.replace(/(ē|é|ě|è)/g, 'e')
.replace(/(ī|í|ǐ|ì)/g, 'i')
.replace(/(ū|ú|ǔ|ù)/g, 'u')
.replace(/(ǖ|ǘ|ǚ|ǜ)/g, 'ü');
.replace(/(ǖ|ǘ|ǚ|ǜ)/g, 'ü')
.replace(/(ń|ň|ǹ)/g, 'n');
};

/**
Expand Down Expand Up @@ -224,10 +225,10 @@ const getInitialAndFinal: GetInitialAndFinal = (pinyin) => {
type GetNumOfTone = (pinyin: string) => string;
const getNumOfTone: GetNumOfTone = (pinyin) => {
const reg_tone1 = /(ā|ō|ē|ī|ū|ǖ)/;
const reg_tone2 = /(á|ó|é|í|ú|ǘ)/;
const reg_tone3 = /(ǎ|ǒ|ě|ǐ|ǔ|ǚ)/;
const reg_tone4 = /(à|ò|è|ì|ù|ǜ)/;
const reg_tone0 = /(a|o|e|i|u|ü)/;
const reg_tone2 = /(á|ó|é|í|ú|ǘ)/;
const reg_tone3 = /(ǎ|ǒ|ě|ǐ|ǔ|ǚ)/;
const reg_tone4 = /(à|ò|è|ì|ù|ǜ)/;
const reg_tone0 = /(a|o|e|i|u|ü|n)/;
const tone_num_arr: string[] = [];
const pinyin_arr = pinyin.split(' ');
pinyin_arr.forEach((_pinyin) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pinyin-pro",
"version": "3.7.0",
"version": "3.7.1",
"description": "汉字转拼音库。获取中文拼音、韵母、声母、声调、首字母,支持拼音匹配",
"main": "./dist/index.cjs.js",
"module": "./dist/index.esm.js",
Expand Down
5 changes: 5 additions & 0 deletions test/dist.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ describe('toneType', () => {
expect(result).to.be.equal('han yu pin yin');
});

it('none-嗯', () => {
const result = pinyin('阿斯蒂芬嗯', { pattern: 'first', toneType: 'none' });
expect(result).to.be.equal('a s d f n');
});

it('none-array', () => {
const result = pinyin('汉语拼音', { toneType: 'none', type: 'array' });
expect(result).to.deep.equal(['han', 'yu', 'pin', 'yin']);
Expand Down

0 comments on commit b3c0128

Please sign in to comment.