Skip to content

Commit

Permalink
update dependencies, add CHANGELOG.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Connum committed Jul 19, 2022
1 parent ca7b192 commit 910ff57
Show file tree
Hide file tree
Showing 7 changed files with 5,324 additions and 24 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
strict-peer-dependencies=false
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

## [1.0.4] - 2022-07-19

### Added
* Changelog

### Changed
* log a test call to pinyin2ipa() to the console in test/test_bundle.html
* updated pinyin-separate and all other dependencies except eslint and eslint-config-airbnb due to major changes

[1.1.0]: https://github.com/Connum/npm-pinyin2ipa/compare/1.0.3...1.0.4
17 changes: 12 additions & 5 deletions dist/pinyin2ipa.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* pinyin2ipa v1.0.2 (July 19th 2019)
* pinyin2ipa v1.0.4 (July 19th 2022)
* Converts Mandarin Chinese pinyin notation to IPA (international phonetic alphabet) notation
*
* https://github.com/Connum/npm-pinyin2ipa#readme
Expand Down Expand Up @@ -1031,14 +1031,21 @@ module.exports={
// @ts-check

var vowels = 'aāáǎăàeēéěĕèiīíǐĭìoōóǒŏòuūúǔŭùüǖǘǚǚü̆ǜvv̄v́v̆v̌v̀';
var tones = 'āáǎăàēéěĕèīíǐĭìōóǒŏòūúǔŭùǖǘǚǚü̆ǜv̄v́v̆v̌v̀';
var tones = 'ā|á|ǎ|ă|à|ē|é|ě|ĕ|è|ī|í|ǐ|ĭ|ì|ō|ó|ǒ|ŏ|ò|ū|ú|ǔ|ŭ|ù|ǖ|ǘ|ǚ|ǚ|ü̆|ǜ|v̄|v́|v̆|v̌|v̀';
var initials = 'b|p|m|f|d|t|n|l|g|k|h|j|q|x|zh|ch|sh|r|z|c|s';
function separate(pinyin) {
return pinyin.replace(/'/g, ' ') // single quote used for separation
.replace(new RegExp('(' + tones + ')(' + tones + ')', 'gi'), '$1 $2') // split two consecutive tones
.replace(new RegExp('([' + vowels + '])([^' + vowels + 'nr])', 'gi'), '$1 $2') // This line does most of the work
.replace(new RegExp('(\\w)([csz]h)', 'gi'), '$1 $2') // double-consonant initials
.replace(new RegExp('([' + vowels + ']{2}(ng? )?)([^\\snr])', 'gi'), '$1 $3') // double-vowel finals
.replace(new RegExp('([' + vowels + ']{2})(n[' + vowels + '])', 'gi'), '$1 $2') // double-vowel followed by n initial
.replace(new RegExp('(n)([^' + vowels + 'vg])', 'gi'), '$1 $2') // cleans up most n compounds
.replace(new RegExp('((ch|sh|(y|b|p|m|f|d|t|n|l|j|q|x)i)(a|\u0101|\xE1|\u01CE|\u0103|\xE0)) (o)', 'gi'), '$1$5') // fix https://github.com/Connum/npm-pinyin-separate/issues/1
.replace(new RegExp('(w|gu|ku|hu|zhu|chu|shu)(a|\u0101|\xE1|\u01CE|\u0103|\xE0) (i)', 'gi'), '$1$2$3') // fix "i" being split from syllables ending in (u)ai
.replace(new RegExp('((a|\u0101|\xE1|\u01CE|\u0103|\xE0)o)(' + initials + ')', 'gi'), '$1 $3') // fix syllable ending in ao followed by another syllable
.replace(new RegExp('((o|\u014D|\xF3|\u01D2|\u014F|\xF2)u)(' + initials + ')', 'gi'), '$1 $3') // fix syllable ending in ou followed by another syllable
.replace(new RegExp('(y(u|\u016B|\xFA|\u01D4|\u016D|\xF9|\xFC|\u01D6|\u01D8|\u01DA|u\u0308\u030C|u\u0308\u0306|\u01DC|v|v\u0304|v\u0301|v\u0306|v\u030C|v\u0300))(n)(u|\u016B|\xFA|\u01D4|\u016D|\xF9|\xFC|\u01D6|\u01D8|\u01DA|u\u0308\u030C|u\u0308\u0306|\u01DC|v|v\u0304|v\u0301|v\u0306|v\u030C|v\u0300)', 'gi'), '$1 $3$4') // fix two "u" (or "ü") separated by an "n" not being split
.replace(new RegExp('([' + vowels + 'v])([^' + vowels + '\\w\\s])([' + vowels + 'v])', 'gi'), '$1 $2$3') // assumes correct Pinyin (i.e., no missing apostrophes)
.replace(new RegExp('([' + vowels + 'v])(n)(g)([' + vowels + 'v])', 'gi'), '$1$2 $3$4') // assumes correct Pinyin, i.e. changan = chan + gan
.replace(new RegExp('([gr])([^' + vowels + '])', 'gi'), '$1 $2') // fixes -ng and -r finals not followed by vowels
Expand All @@ -1060,16 +1067,16 @@ module.exports = function separatePinyinInSyllables(pinyin, separateBySpaces) {
var pinyinSeparated = separate(pinyin).split(' ');
var newPinyin = [];

pinyinSeparated.forEach(function (p) {
pinyinSeparated.forEach(function (p, i) {
var totalTones = 1;
var pregMatch = p.match(new RegExp('([' + tones + '])', 'g'));
var pregMatch = p.match(new RegExp('(' + tones + ')', 'g'));
if (pregMatch) {
totalTones = pregMatch.length;
}

if (p.length > 4 || totalTones > 1) {
separate(p).split(' ').forEach(function (newP) {
pregMatch = newP.match(new RegExp('([' + tones + '])', 'g'));
pregMatch = newP.match(new RegExp('(' + tones + ')', 'g'));
if (pregMatch) {
totalTones = pregMatch.length;
}
Expand Down
6 changes: 3 additions & 3 deletions dist/pinyin2ipa.min.js

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pinyin2ipa",
"version": "1.0.3",
"version": "1.0.4",
"description": "Converts Mandarin Chinese pinyin notation to IPA (international phonetic alphabet) notation",
"main": "./lib/index.js",
"scripts": {
Expand Down Expand Up @@ -39,28 +39,28 @@
},
"homepage": "https://github.com/Connum/npm-pinyin2ipa#readme",
"dependencies": {
"pinyin-separate": "^1.0.7"
"pinyin-separate": "^1.1.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-eslint": "^10.0.2",
"babel-plugin-add-module-exports": "^1.0.2",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-inline-json-import": "^0.3.2",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-minify": "^0.5.0",
"browserify": "^16.3.0",
"browserify-banner": "^1.0.14",
"chai": "^4.2.0",
"cross-env": "^5.2.0",
"babel-preset-minify": "^0.5.2",
"browserify": "^17.0.0",
"browserify-banner": "^2.0.4",
"chai": "^4.3.6",
"cross-env": "^7.0.3",
"eslint": "^6.0.1",
"eslint-config-airbnb": "^17.1.1",
"eslint-plugin-import": "^2.18.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.14.2",
"istanbul": "^1.0.0-alpha",
"mocha": "^6.2.0",
"rimraf": "^2.6.3",
"uglifyify": "^5.0.1"
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.6.0",
"eslint-plugin-react": "^7.30.1",
"istanbul": "^1.1.0-alpha.1",
"mocha": "^10.0.0",
"rimraf": "^3.0.2",
"uglifyify": "^5.0.2"
}
}
Loading

0 comments on commit 910ff57

Please sign in to comment.