├── .eslintignore
├── dist
├── .gitkeep
├── pinyin2ipa.min.js
└── pinyin2ipa.js
├── .npmrc
├── examples
├── index.js
└── example.js
├── .travis.yml
├── .eslintrc
├── .editorconfig
├── CHANGELOG.md
├── .npmignore
├── .babelrc
├── test
├── test_bundle.html
└── index.js
├── .gitignore
├── .github
└── workflows
│ └── node.js.yml
├── LICENSE
├── package.json
├── README.md
└── src
├── index.js
└── methods
├── sophisticated.json
└── default.json
/.eslintignore:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dist/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | strict-peer-dependencies=false
2 |
--------------------------------------------------------------------------------
/examples/index.js:
--------------------------------------------------------------------------------
1 | const example = require('./example');
2 |
3 | module.exports = {
4 | example
5 | };
6 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - '8'
4 | - '6'
5 | script:
6 | - npm run test
7 | - npm run build
8 | branches:
9 | only:
10 | - master
11 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "parser": "babel-eslint",
3 | "extends": "airbnb",
4 | "env": {
5 | "mocha": true
6 | },
7 | "rules": {
8 | "comma-dangle": ["error", "only-multiline"],
9 | "no-plusplus": ["error", { "allowForLoopAfterthoughts": true }]
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig helps developers define and maintain
2 | # consistent coding styles between different editors and IDEs.
3 |
4 | root = true
5 |
6 | [*]
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 | indent_style = space
12 | indent_size = 2
13 |
14 | [*.md]
15 | trim_trailing_whitespace = false
16 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## [1.0.4] - 2022-07-19
4 |
5 | ### Added
6 | * Changelog
7 |
8 | ### Changed
9 | * log a test call to pinyin2ipa() to the console in test/test_bundle.html
10 | * updated pinyin-separate and all other dependencies except eslint and eslint-config-airbnb due to major changes
11 |
12 | [1.0.4]: https://github.com/Connum/npm-pinyin2ipa/compare/1.0.2...1.0.4
13 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | *.log
2 | npm-debug.log*
3 |
4 | # Coverage directory used by tools like istanbul
5 | coverage
6 | .nyc_output
7 |
8 | # Dependency directories
9 | node_modules
10 |
11 | # npm package lock
12 | package-lock.json
13 | yarn.lock
14 |
15 | # project files
16 | src
17 | test
18 | examples
19 | CHANGELOG.md
20 | .travis.yml
21 | .editorconfig
22 | .eslintignore
23 | .eslintrc
24 | .babelrc
25 | .gitignore
26 |
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "development": {
4 | "presets": ["env"],
5 | "plugins": [
6 | "add-module-exports"
7 | ]
8 | },
9 | "production": {
10 | "presets": ["env", ["minify", {
11 | "builtIns": false,
12 | "mangle": { "topLevel": true },
13 | "regexpConstructors": false,
14 | "evaluate": false
15 | }]],
16 | "comments": false,
17 | "plugins": [
18 | "add-module-exports",
19 | "inline-json-import"
20 | ]
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/test/test_bundle.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Test bundle.js
7 |
8 |
9 |
10 |
11 | pinyin2ipa should be available as a global pinyinSaparate and can be played around with in the console.
12 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 |
6 | # Runtime data
7 | pids
8 | *.pid
9 | *.seed
10 |
11 | # Directory for instrumented libs generated by jscoverage/JSCover
12 | lib-cov
13 |
14 | # Coverage directory used by tools like istanbul
15 | coverage
16 |
17 | # nyc test coverage
18 | .nyc_output
19 |
20 | # Compiled binary addons (http://nodejs.org/api/addons.html)
21 | build/Release
22 |
23 | # Dependency directories
24 | node_modules
25 | jspm_packages
26 |
27 | # Optional npm cache directory
28 | .npm
29 |
30 | # Optional REPL history
31 | .node_repl_history
32 |
33 | # Editors
34 | .idea
35 |
36 | # Lib
37 | lib
38 |
39 | others
40 | .DS_Store
41 |
--------------------------------------------------------------------------------
/examples/example.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-console */
2 | const pinyin2ipa = require('../lib');
3 | // const { awesomeFunction } = require('../lib');
4 |
5 | console.log(pinyin2ipa('nĭhăoma'));
6 |
7 | console.log(pinyin2ipa('nĭhăoma', {
8 | markNeutral: true
9 | }));
10 |
11 | console.log(pinyin2ipa('nĭhăoma', {
12 | superscript: true
13 | }));
14 |
15 | console.log(pinyin2ipa('nĭhăoma', {
16 | method: "sophisticated",
17 | toneMarker: "chaonumber",
18 | superscript: true
19 | }));
20 |
21 | console.log(pinyin2ipa('nĭhăoma', {
22 | method: "sophisticated",
23 | toneMarker: "chaoletter"
24 | }));
25 |
26 | console.log(pinyin2ipa('ni3hao3ma', {
27 | toneMarker: "number",
28 | superscript: true
29 | }));
30 |
--------------------------------------------------------------------------------
/.github/workflows/node.js.yml:
--------------------------------------------------------------------------------
1 | # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
3 |
4 | name: Node.js CI
5 |
6 | on:
7 | push:
8 | branches: [ "master" ]
9 | pull_request:
10 | branches: [ "master" ]
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 |
17 | strategy:
18 | matrix:
19 | node-version: [14.x, 16.x, 18.x]
20 | # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21 |
22 | steps:
23 | - uses: actions/checkout@v3
24 | - name: Use Node.js ${{ matrix.node-version }}
25 | uses: actions/setup-node@v3
26 | with:
27 | node-version: ${{ matrix.node-version }}
28 | cache: 'npm'
29 | - run: npm ci
30 | - run: npm run build --if-present
31 | - run: npm test
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2019 Connum
4 | npm-module-boilerplate Copyright (c) 2018 Dineshkumar Pandiyan
5 | separate-pinyin-in-syllables.js (c) pierophp
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in all
15 | copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | SOFTWARE.
24 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "pinyin2ipa",
3 | "version": "1.0.4",
4 | "description": "Converts Mandarin Chinese pinyin notation to IPA (international phonetic alphabet) notation",
5 | "main": "./lib/index.js",
6 | "scripts": {
7 | "clean": "rimraf lib",
8 | "test": "npm run lint && npm run test:only",
9 | "test:prod": "cross-env BABEL_ENV=production npm run test",
10 | "test:only": "mocha --require babel-core/register --require babel-polyfill --recursive",
11 | "test:watch": "npm test -- --watch",
12 | "test:examples": "node examples/",
13 | "lint": "eslint src test",
14 | "build": "babel src --out-dir lib --copy-files && npm run dist",
15 | "dist": "browserify -p [ browserify-banner --file build/dist-banner.txt ] lib/index.js > dist/pinyin2ipa.js --standalone pinyin2ipa && cross-env BABEL_ENV=production babel src --out-dir build/temp && browserify -p [ browserify-banner --file build/dist-banner.txt ] -g uglifyify build/temp/index.js > dist/pinyin2ipa.min.js --standalone pinyin2ipa && rimraf build/temp",
16 | "prepublishOnly": "npm run clean && npm run lint && npm run test && npm run build"
17 | },
18 | "files": [
19 | "lib",
20 | "dist"
21 | ],
22 | "repository": {
23 | "type": "git",
24 | "url": "git+https://github.com/Connum/npm-pinyin2ipa.git"
25 | },
26 | "keywords": [
27 | "chinese",
28 | "mandarin",
29 | "language",
30 | "linguistics",
31 | "ipa",
32 | "pinyin",
33 | "converter"
34 | ],
35 | "author": "Connum ",
36 | "license": "MIT",
37 | "bugs": {
38 | "url": "https://github.com/Connum/npm-pinyin2ipa/issues"
39 | },
40 | "homepage": "https://github.com/Connum/npm-pinyin2ipa#readme",
41 | "dependencies": {
42 | "pinyin-separate": "^1.1.0"
43 | },
44 | "devDependencies": {
45 | "babel-cli": "^6.26.0",
46 | "babel-eslint": "^10.0.2",
47 | "babel-plugin-add-module-exports": "^1.0.4",
48 | "babel-plugin-inline-json-import": "^0.3.2",
49 | "babel-polyfill": "^6.26.0",
50 | "babel-preset-env": "^1.7.0",
51 | "babel-preset-minify": "^0.5.2",
52 | "browserify": "^17.0.0",
53 | "browserify-banner": "^2.0.4",
54 | "chai": "^4.3.6",
55 | "cross-env": "^7.0.3",
56 | "eslint": "^6.0.1",
57 | "eslint-config-airbnb": "^17.1.1",
58 | "eslint-plugin-import": "^2.26.0",
59 | "eslint-plugin-jsx-a11y": "^6.6.0",
60 | "eslint-plugin-react": "^7.30.1",
61 | "istanbul": "^1.1.0-alpha.1",
62 | "mocha": "^10.0.0",
63 | "rimraf": "^3.0.2",
64 | "uglifyify": "^5.0.2"
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/test/index.js:
--------------------------------------------------------------------------------
1 | import { assert } from 'chai';
2 | import pinyin2ipa from '../src';
3 |
4 | describe('Conversion tests', () => {
5 | it('should convert nĭhăoma', () => {
6 | const expectedVal = 'ni3 xau3 ma';
7 | assert.equal(pinyin2ipa('nĭhăoma'), expectedVal);
8 | });
9 |
10 | it('should convert nĭhăoma mith markNeutral option', () => {
11 | const expectedVal = 'ni3 xau3 ma5';
12 | assert.equal(pinyin2ipa('nĭhăoma', {
13 | markNeutral: true
14 | }), expectedVal);
15 | });
16 |
17 | it('should convert nĭhăoma mith markNeutral option and chao numbers', () => {
18 | const expectedVal = 'ni214 xau214 ma';
19 | assert.equal(pinyin2ipa('nĭhăoma', {
20 | toneMarker: 'chaonumber',
21 | markNeutral: true
22 | }), expectedVal);
23 | });
24 |
25 | it('should convert nĭ hăo ma', () => {
26 | const expectedVal = 'ni3 xau3 ma';
27 | assert.equal(pinyin2ipa('nĭ hăo ma'), expectedVal);
28 | });
29 |
30 | it('should convert nĭhăoma with superscript', () => {
31 | const expectedVal = 'ni³ xau³ ma';
32 | assert.equal(pinyin2ipa('nĭhăoma', {
33 | superscript: true
34 | }), expectedVal);
35 | });
36 |
37 | it('should convert nĭhăoma with sophisticated method and superscript chao numbers', () => {
38 | const expectedVal = 'ni²¹⁴ xɑʊ̯²¹⁴ mɑ';
39 | assert.equal(pinyin2ipa('nĭhăoma', {
40 | method: 'sophisticated',
41 | toneMarker: 'chaonumber',
42 | superscript: true
43 | }), expectedVal);
44 | });
45 |
46 | it('should convert nĭhăoma with sophisticated method and chao letters', () => {
47 | const expectedVal = 'ni˨˩˦ xɑʊ̯˨˩˦ mɑ';
48 | assert.equal(pinyin2ipa('nĭhăoma', {
49 | method: 'sophisticated',
50 | toneMarker: 'chaoletter'
51 | }), expectedVal);
52 | });
53 |
54 | it('should convert ni3hao3ma with superscript numbers', () => {
55 | const expectedVal = 'ni³ xau³ ma';
56 | assert.equal(pinyin2ipa('ni3hao3ma', {
57 | toneMarker: 'number',
58 | superscript: true
59 | }), expectedVal);
60 | });
61 |
62 | it('should convert ni3 hao3 ma with superscript chao numbers', () => {
63 | const expectedVal = 'ni²¹⁴ xau²¹⁴ ma';
64 | assert.equal(pinyin2ipa('ni3 hao3 ma', {
65 | toneMarker: 'chaonumber',
66 | superscript: true
67 | }), expectedVal);
68 | });
69 |
70 | it('should convert dé dè de de5', () => {
71 | const expectedVal = 'tɤ2 tɤ4 tə tə';
72 | assert.equal(pinyin2ipa('dé dè de de5'), expectedVal);
73 | });
74 |
75 | it('should convert dé dè de de5 with markNeutral option', () => {
76 | const expectedVal = 'tɤ2 tɤ4 tə5 tə5';
77 | assert.equal(pinyin2ipa('dé dè de de5', {
78 | markNeutral: true
79 | }), expectedVal);
80 | });
81 |
82 | it('should convert ni3 foo bar baz with filterUnknown', () => {
83 | const expectedVal = 'ni3';
84 | assert.equal(pinyin2ipa('ni3 foo bar baz', {
85 | filterUnknown: true
86 | }), expectedVal);
87 | });
88 |
89 | it('should convert ni3 foo bar baz without filterUnknown', () => {
90 | const expectedVal = 'ni3 *foo* *bar* *baz*';
91 | assert.equal(pinyin2ipa('ni3 foo bar baz', {
92 | filterUnknown: false
93 | }), expectedVal);
94 | });
95 |
96 | it('should convert nĭ\\r\\nhăo\\nma with line breaks', () => {
97 | const expectedVal = 'ni3\nxau3\nma';
98 | assert.equal(pinyin2ipa('nĭ\r\nhăo\nma'), expectedVal);
99 | });
100 | });
101 |
102 | describe('Custom method test', () => {
103 | it('should convert nĭmenhăoma ménhào with custom method', () => {
104 | const expectedVal = 'foo3 bar baz3 bat lorem2 ipsum4';
105 | pinyin2ipa.methods.myCustomMethod = {
106 | ni: 'foo',
107 | men: 'lorem',
108 | men5: 'bar',
109 | hao: 'ipsum',
110 | hao3: 'baz',
111 | ma: 'bat'
112 | };
113 | assert.equal(pinyin2ipa('nĭmenhăoma ménhào', {
114 | method: 'myCustomMethod'
115 | }), expectedVal);
116 | });
117 | });
118 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # pinyin2ipa
2 |
3 | [](https://david-dm.org/Connum/npm-pinyin2ipa) [](https://david-dm.org/Connum/npm-pinyin2ipa?type=dev) [](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/pinyin2ipa)
4 |
5 | Converts Mandarin Chinese Pinyin notation to IPA (International Phonetic Alphabet) notation. Supports different methods of transliteration, by default using an approach by the Beijing Language and Culture University (北京语言大学).
6 |
7 |
8 | # Installation
9 | `npm install pinyin2ipa`
10 |
11 | or use the files in `/dist` or from the [releases](https://github.com/Connum/npm-pinyin2ipa/releases) for direct in-browser usage.
12 |
13 | # Usage and examples
14 | ```js
15 | const pinyin2ipa = require('pinyin2ipa').default
16 | // or
17 | import pinyin2ipa from 'pinyin2ipa'
18 | // or (for usage in a browser environment)
19 |
20 |
21 | // and then it's as simple as
22 | pinyin2ipa("nĭ hăo"); // result: ni3 xau3
23 |
24 | // in addition to diacritics, number notation can also be used,
25 | // with spaces or without
26 | pinyin2ipa("ni3hao3"); // result: ni3 xau3
27 | pinyin2ipa("ni3 hao3"); // result: ni3 xau3
28 |
29 | // to use an alternative built-in method,
30 | // set the "method" option to "sophisticated"
31 | pinyin2ipa("nĭ hăo", {
32 | method: "sophisticated"
33 | }); // result: ni3 xɑʊ̯3
34 |
35 | // In order to define a custom method, extend the object in pinyin2ipa.methods.
36 | // A method is an object whose keys represent the pinyin notation without
37 | // diacritics, optionally followed by a tone number if that tone needs to be
38 | // treated differently. The value represents the IPA transliteration.
39 | // See the built-in methods in src/methods/ for a better understanding.
40 | pinyin2ipa.methods.myCustomMethod = {
41 | // ...
42 | 'den': 'tən',
43 | 'de5': 'tə',
44 | 'de': 'tɤ',
45 | // ...
46 | }
47 | // and then use it like this:
48 | pinyin2ipa('nĭhăoma', {
49 | method: 'myCustomMethod'
50 | })
51 | ```
52 |
53 | For more examples, see `examples/examples.js` or the tests in `test/index.js`.
54 |
55 | ## Options
56 | Options can be passed via an object as the second argument of `pinyin2ipa()` (see code example above).
57 |
58 | | Option Name | Default | Description |
59 | | ------------- | ------------- | ------------- |
60 | | `method` | `"default"` | Either `"default"` or `"sophisticated"`, or a custom method defined via `pinyin2ipa.methods`.
`"default"` is an approach used by the Beijing Language and Culture University (北京语言大学)
`"sophisticated"` uses an alternative method with more diacritics and some different characters to resemble the actual pronunciation even more closely.
For defining custom methods, see the code example above. |
61 | | `toneMarker` | `"number"` | The tone marker to use after each syllable (neutral tone will not be marked at all by default, see `markNeutral` option). Either `"number"`, `"chaonumber"`, or `"chaoletter"`.
`"number"` uses integers from 1 to 4
`"chaonumber"` uses the Chao tone numerals 55, 35, 214, and 51
`"chaoletter"` uses the Chao tone letters ˥, ˧˥, ˨˩˦, and ˥˩
62 | | `markNeutral` | `false` | Whether to mark the neutral tone. Only has an effect if `toneMarker` is `number`.
63 | | `superscript` | `false` | Boolean indicating whether to display numbers as superscript (¹²³⁴⁵) or normal numbers (12345). Only has an effect if the `toneMarker` option is either `"number"` or `"chaonumber"`. |
64 | | `filterUnknown` | `true` | Boolean indicating whether to filter out any unknown syllables. If `false`, unknown syllables will be surrounded by asterisks |
65 |
66 | # Development Commands
67 | - `npm run clean` - Remove `lib/` directory
68 | - `npm test` - Run tests with linting
69 | - `npm test:only` - Run tests without linting
70 | - `npm test:watch` - Re-run tests on file changes
71 | - `npm test:prod` - Run tests with minified code
72 | - `npm run test:examples` - Test examples with node
73 | - `npm run lint` - Run ESlint with airbnb-config
74 | - `npm run build` - Babel will transpile ES6 => ES5 and minify the code, Browserify will create a bundle in `dist/` for in-browser usage.
75 | - `npm run prepublish` - Hook for npm. Do all the checks before publishing the module.
76 |
77 | # License
78 |
79 | MIT © Connum
80 |
81 | based on [flexdinesh/npm-module-boilerplate](https://github.com/flexdinesh/npm-module-boilerplate), MIT © Dinesh Pandiyan
82 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import pinyinSeparate from 'pinyin-separate';
2 | import defaultMethod from './methods/default.json';
3 | import sophisticatedMethod from './methods/sophisticated.json';
4 |
5 | const defaultOptions = {
6 | method: 'default',
7 | toneMarker: 'number',
8 | markNeutral: false,
9 | superscript: false,
10 | filterUnknown: true
11 | };
12 |
13 | const toneReps = {
14 | number: ['1', '2', '3', '4', '5'],
15 | numberSuperscript: ['¹', '²', '³', '⁴', '⁵'],
16 | chaonumber: ['55', '35', '214', '51', ''],
17 | chaonumberSuperscript: ['⁵⁵', '³⁵', '²¹⁴', '⁵¹', ''],
18 | chaoletter: ['˥', '˧˥', '˨˩˦', '˥˩', '']
19 | };
20 |
21 | const pinyinRegEx = /^(((miu|[pm]ou|[bpm](o|e(i|ng?)?|a(ng?|i|o)?|i(e|ng?|a[no])?|u))|(f(ou?|[ae](ng?|i)?|u))|(d(e(i|ng?)|i(a[on]?|u))|[dt](a(i|ng?|o)?|e(i|ng)?|i(a[on]?|e|ng|u)?|o(ng?|u)|u(o|i|an?|n)?))|(neng?|[ln](a(i|ng?|o)?|e(i|ng)?|i(ang|a[on]?|e|ng?|u)?|o(ng?|u)|u(o|i|an?|n)?|ve?))|([ghk](a(i|ng?|o)?|e(i|ng?)?|o(u|ng)|u(a(i|ng?)?|i|n|o)?))|(zh?ei|[cz]h?(e(ng?)?|o(ng?|u)?|ao|u?a(i|ng?)?|u?(o|i|n)?))|(song|shua(i|ng?)?|shei|sh?(a(i|ng?|o)?|en?g?|ou|u(a?n|o|i)?|i))|(r([ae]ng?|i|e|ao|ou|ong|u[oin]|ua?n?))|([jqx](i(a(o|ng?)?|[eu]|ong|ng?)?|u(e|a?n)?))|((a(i|o|ng?)?|ou?|e(i|ng?|r)?))|(w(a(i|ng?)?|o|e(i|ng?)?|u))|y(a(o|ng?)?|e|in?g?|o(u|ng)?|u(e|a?n)?))[0-5]?)+$/i;
22 |
23 | function removeDiacritics(word) {
24 | return word
25 | .replace(/[āáǎăà]/ig, 'a')
26 | .replace(/[ēéěěĕè]/ig, 'e')
27 | .replace(/[īíǐĭì]/ig, 'i')
28 | .replace(/[ōóǒŏò]/ig, 'o')
29 | .replace(/[ūúǔŭù]/ig, 'u')
30 | .replace(/([ǖǘǚǚü̆ǜv̄v́v̆v̌v̀]|[ūúǔŭù]:)/ig, 'ü');
31 | }
32 |
33 | function numberifyTones(wordIn) {
34 | let word = wordIn;
35 | if (/\d$/.test(word)) {
36 | return word;
37 | }
38 |
39 | if (/[āēīōūǖv̄]/.test(word)) {
40 | word += '1';
41 | } else if (/[áéíóúǘv́]/.test(word)) {
42 | word += '2';
43 | } else if (/[ǎăěĕǐĭǒŏǔŭǚǚü̆v̆v̌]/.test(word)) {
44 | word += '3';
45 | } else if (/[àèìòùǜv̀]/.test(word)) {
46 | word += '4';
47 | } else {
48 | word += '5';
49 | }
50 | return removeDiacritics(word);
51 | }
52 |
53 | function isNumberPinYin(wordIn) {
54 | let word = wordIn;
55 | word = word.replace(/\r?\n/g, '');
56 | return pinyinRegEx.test(word);
57 | }
58 |
59 | function isPinYin(wordIn) {
60 | let word = wordIn;
61 | word = removeDiacritics(word.replace(/\r?\n/g, ''));
62 | return pinyinRegEx.test(word);
63 | }
64 |
65 | function pinyinWord2IPA(wordIn, methodTable, toneRep, options) {
66 | let word = wordIn;
67 | if (word === '#~linebreak~#') return '\n';
68 |
69 | if (parseInt(word, 10) === word) {
70 | return word;
71 | }
72 |
73 | if (!isNumberPinYin(word)) {
74 | const splits = pinyinSeparate(word);
75 | const convertedWords = [];
76 | if (splits.length > 1) {
77 | let part = null;
78 | let convertedWord = null;
79 | for (let i = 0; i < splits.length; i++) {
80 | part = splits[i];
81 | convertedWord = pinyinWord2IPA(part, methodTable, toneRep, options);
82 | if (convertedWord.length) {
83 | convertedWords.push(convertedWord);
84 | }
85 | }
86 | return convertedWords.join(' ');
87 | }
88 | word = numberifyTones(word.toLowerCase());
89 | }
90 |
91 | const pureWord = word.replace(/([^\d]+)\d+/g, '$1');
92 | if (!isPinYin(pureWord)) {
93 | return options.filterUnknown ? '' : `*${pureWord}*`;
94 | }
95 |
96 | const toneMatch = word.match(/\d$/);
97 | const toneIndex = (toneMatch ? parseInt(toneMatch[0], 10) : 5) - 1;
98 | const toneMark = toneIndex === 4 && (!options.markNeutral || options.toneMarker !== 'number') ? '' : toneRep[toneIndex];
99 | if (pureWord === '\\n') return '\n';
100 |
101 | let result = '';
102 | if (word === pureWord && methodTable[`${word}5`]) {
103 | result = methodTable[`${word}5`] + toneMark;
104 | } else if (methodTable[word]) {
105 | result = methodTable[word] + toneMark;
106 | } else if (methodTable[pureWord]) {
107 | result = methodTable[pureWord] + toneMark;
108 | } else {
109 | result = options.filterUnknown ? '' : `*${pureWord}*`;
110 | }
111 |
112 | return result;
113 | }
114 |
115 | function pinyin2ipa(pinyIn, optionsArg = defaultOptions) {
116 | let options = optionsArg;
117 | let output = pinyIn;
118 |
119 | if (options !== defaultOptions) {
120 | options = Object.assign({}, defaultOptions, options);
121 | }
122 |
123 | if (options.superscript && options.toneMarker !== 'number' && options.toneMarker !== 'chaonumber') {
124 | options.superscript = false;
125 | }
126 |
127 | const toneRep = toneReps[`${options.toneMarker}${options.superscript ? 'Superscript' : ''}`];
128 |
129 | output = output.replace(/(\d+)([^ ])/g, '$1 $2');
130 | output = output.replace(/\r?\n/g, ' #~linebreak~# ');
131 |
132 | let words = output.split(/[ '".,;:?!*“”\-—$§€()/´`]+/g);
133 | words = words.filter(w => !/^ +$/.test(w));
134 |
135 | const methodTable = pinyin2ipa.methods[options.method];
136 | words = words.map(word => pinyinWord2IPA(word, methodTable, toneRep, options));
137 |
138 | words = words.filter(w => !/^ +$/.test(w));
139 |
140 | return words.join(' ').replace(/ ?(#~linebreak~#|\n) ?/g, '\n').trim();
141 | }
142 |
143 | pinyin2ipa.methods = {
144 | default: defaultMethod,
145 | sophisticated: sophisticatedMethod
146 | };
147 |
148 | export default pinyin2ipa;
149 |
150 | // export { pinyin2ipa };
151 |
--------------------------------------------------------------------------------
/src/methods/sophisticated.json:
--------------------------------------------------------------------------------
1 | {
2 | "an": "an",
3 | "ai": "aɪ̯",
4 | "ei": "eɪ̯",
5 | "fan": "fan",
6 | "fei": "feɪ̯",
7 | "fu": "fu",
8 | "fo": "fu̯ɔ",
9 | "fa": "fɑ",
10 | "fang": "fɑŋ",
11 | "fen": "fən",
12 | "feng": "fəŋ",
13 | "fou": "fɤʊ̯",
14 | "yi": "i",
15 | "yin": "in",
16 | "ying": "iŋ",
17 | "yong": "jʊŋ",
18 | "ye": "iɛ",
19 | "yan": "iɛn",
20 | "ya": "i̯ɑ",
21 | "yang": "i̯ɑŋ",
22 | "yao": "i̯ɑʊ̯",
23 | "you": "i̯ɤʊ̯",
24 | "gan": "kan",
25 | "gai": "kaɪ̯",
26 | "gei": "keɪ̯",
27 | "gu": "ku",
28 | "guan": "ku̯an",
29 | "guai": "ku̯aɪ̯",
30 | "gui": "ku̯eɪ̯",
31 | "gua": "ku̯ɑ",
32 | "guang": "ku̯ɑŋ",
33 | "guo": "ku̯ɔ",
34 | "gun": "ku̯ən",
35 | "ga": "kɑ",
36 | "gang": "kɑŋ",
37 | "gao": "kɑʊ̯",
38 | "gen": "kən",
39 | "geng": "kəŋ",
40 | "gou": "kɤʊ̯",
41 | "ge": "kɯ̯ʌ",
42 | "gong": "kʊŋ",
43 | "kan": "kʰan",
44 | "kai": "kʰaɪ̯",
45 | "kei": "kʰeɪ̯",
46 | "ku": "kʰu",
47 | "kuan": "kʰu̯an",
48 | "kuai": "kʰu̯aɪ̯",
49 | "kui": "kʰu̯eɪ̯",
50 | "kua": "kʰu̯ɑ",
51 | "kuang": "kʰu̯ɑŋ",
52 | "kuo": "kʰu̯ɔ",
53 | "kun": "kʰu̯ən",
54 | "ka": "kʰɑ",
55 | "kang": "kʰɑŋ",
56 | "kao": "kʰɑʊ̯",
57 | "ken": "kʰən",
58 | "keng": "kʰəŋ",
59 | "kou": "kʰɤʊ̯",
60 | "ke": "kʰɯ̯ʌ",
61 | "kong": "kʰʊŋ",
62 | "lan": "lan",
63 | "lai": "laɪ̯",
64 | "lei": "leɪ̯",
65 | "li": "li",
66 | "lin": "lin",
67 | "ling": "liŋ",
68 | "lie": "liɛ",
69 | "lian": "liɛn",
70 | "lia": "li̯ɑ",
71 | "liang": "li̯ɑŋ",
72 | "liao": "li̯ɑʊ̯",
73 | "liu": "li̯ɤʊ̯",
74 | "lu": "lu",
75 | "luan": "lu̯an",
76 | "lo": "lu̯ɔ",
77 | "luo": "lu̯ɔ",
78 | "lun": "lu̯ən",
79 | "lü": "ly",
80 | "lüe": "ly̯œ",
81 | "la": "lɑ",
82 | "lang": "lɑŋ",
83 | "lao": "lɑʊ̯",
84 | "leng": "ləŋ",
85 | "lou": "lɤʊ̯",
86 | "le": "lɯ̯ʌ",
87 | "long": "lʊŋ",
88 | "man": "man",
89 | "mai": "maɪ̯",
90 | "mei": "meɪ̯",
91 | "mi": "mi",
92 | "min": "min",
93 | "ming": "miŋ",
94 | "mie": "miɛ",
95 | "mian": "miɛn",
96 | "miao": "mi̯ɑʊ̯",
97 | "miu": "mi̯ɤʊ̯",
98 | "mu": "mu",
99 | "mo": "mu̯ɔ",
100 | "ma": "mɑ",
101 | "mang": "mɑŋ",
102 | "mao": "mɑʊ̯",
103 | "men": "mən",
104 | "meng": "məŋ",
105 | "mou": "mɤʊ̯",
106 | "me": "mɯ̯ʌ",
107 | "nan": "nan",
108 | "nai": "naɪ̯",
109 | "nei": "neɪ̯",
110 | "ni": "ni",
111 | "nin": "nin",
112 | "ning": "niŋ",
113 | "nie": "niɛ",
114 | "nian": "niɛn",
115 | "niang": "ni̯ɑŋ",
116 | "niao": "ni̯ɑʊ̯",
117 | "niu": "ni̯ɤʊ̯",
118 | "nu": "nu",
119 | "nuan": "nu̯an",
120 | "nuo": "nu̯ɔ",
121 | "nü": "ny",
122 | "nüe": "ny̯œ",
123 | "na": "nɑ",
124 | "nang": "nɑŋ",
125 | "nao": "nɑʊ̯",
126 | "nen": "nən",
127 | "neng": "nəŋ",
128 | "nou": "nɤʊ̯",
129 | "ne": "nɯ̯ʌ",
130 | "nong": "nʊŋ",
131 | "ban": "pan",
132 | "bai": "paɪ̯",
133 | "bei": "peɪ̯",
134 | "bi": "pi",
135 | "bin": "pin",
136 | "bing": "piŋ",
137 | "bie": "piɛ",
138 | "bian": "piɛn",
139 | "biang": "pi̯ɑŋ",
140 | "biao": "pi̯ɑʊ̯",
141 | "bu": "pu",
142 | "bo": "pu̯ɔ",
143 | "ba": "pɑ",
144 | "bang": "pɑŋ",
145 | "bao": "pɑʊ̯",
146 | "ben": "pən",
147 | "beng": "pəŋ",
148 | "pan": "pʰan",
149 | "pai": "pʰaɪ̯",
150 | "pei": "pʰeɪ̯",
151 | "pi": "pʰi",
152 | "pin": "pʰin",
153 | "ping": "pʰiŋ",
154 | "pie": "pʰiɛ",
155 | "pian": "pʰiɛn",
156 | "piao": "pʰi̯ɑʊ̯",
157 | "pu": "pʰu",
158 | "po": "pʰu̯ɔ",
159 | "pa": "pʰɑ",
160 | "pang": "pʰɑŋ",
161 | "pao": "pʰɑʊ̯",
162 | "pen": "pʰən",
163 | "peng": "pʰəŋ",
164 | "pou": "pʰɤʊ̯",
165 | "san": "san",
166 | "sai": "saɪ̯",
167 | "su": "su",
168 | "suan": "su̯an",
169 | "sui": "su̯eɪ̯",
170 | "suo": "su̯ɔ",
171 | "sun": "su̯ən",
172 | "sa": "sɑ",
173 | "sang": "sɑŋ",
174 | "sao": "sɑʊ̯",
175 | "sen": "sən",
176 | "seng": "səŋ",
177 | "sou": "sɤʊ̯",
178 | "se": "sɯ̯ʌ",
179 | "si": "sɿ",
180 | "song": "sʊŋ",
181 | "dan": "tan",
182 | "dai": "taɪ̯",
183 | "dei": "teɪ̯",
184 | "di": "ti",
185 | "ding": "tiŋ",
186 | "die": "tiɛ",
187 | "dian": "tiɛn",
188 | "diao": "ti̯ɑʊ̯",
189 | "diu": "ti̯ɤʊ̯",
190 | "zan": "tsan",
191 | "zai": "tsaɪ̯",
192 | "zei": "tseɪ̯",
193 | "zu": "tsu",
194 | "zuan": "tsu̯an",
195 | "zui": "tsu̯eɪ̯",
196 | "zuo": "tsu̯ɔ",
197 | "zun": "tsu̯ən",
198 | "za": "tsɑ",
199 | "zang": "tsɑŋ",
200 | "zao": "tsɑʊ̯",
201 | "zen": "tsən",
202 | "zeng": "tsəŋ",
203 | "zou": "tsɤʊ̯",
204 | "ze": "tsɯ̯ʌ",
205 | "zi": "tsɿ",
206 | "zong": "tsʊŋ",
207 | "can": "tsʰan",
208 | "cai": "tsʰaɪ̯",
209 | "cei": "tsʰeɪ̯",
210 | "cu": "tsʰu",
211 | "cuan": "tsʰu̯an",
212 | "cui": "tsʰu̯eɪ̯",
213 | "cuo": "tsʰu̯ɔ",
214 | "cun": "tsʰu̯ən",
215 | "ca": "tsʰɑ",
216 | "cang": "tsʰɑŋ",
217 | "cao": "tsʰɑʊ̯",
218 | "cen": "tsʰən",
219 | "ceng": "tsʰəŋ",
220 | "cou": "tsʰɤʊ̯",
221 | "ce": "tsʰɯ̯ʌ",
222 | "ci": "tsʰɿ",
223 | "cong": "tsʰʊŋ",
224 | "du": "tu",
225 | "duan": "tu̯an",
226 | "dui": "tu̯eɪ̯",
227 | "duo": "tu̯ɔ",
228 | "dun": "tu̯ən",
229 | "da": "tɑ",
230 | "dang": "tɑŋ",
231 | "dao": "tɑʊ̯",
232 | "ji": "tɕi",
233 | "jin": "tɕin",
234 | "jing": "tɕiŋ",
235 | "jie": "tɕiɛ",
236 | "jian": "tɕiɛn",
237 | "jia": "tɕi̯ɑ",
238 | "jiang": "tɕi̯ɑŋ",
239 | "jiao": "tɕi̯ɑʊ̯",
240 | "jiu": "tɕi̯ɤʊ̯",
241 | "jiong": "tɕi̯ʊŋ",
242 | "ju": "tɕy",
243 | "jun": "tɕyn",
244 | "jue": "tɕy̯œ",
245 | "juan": "tɕy̯ɛn",
246 | "qi": "tɕʰi",
247 | "qin": "tɕʰin",
248 | "qing": "tɕʰiŋ",
249 | "qie": "tɕʰiɛ",
250 | "qian": "tɕʰiɛn",
251 | "qia": "tɕʰi̯ɑ",
252 | "qiang": "tɕʰi̯ɑŋ",
253 | "qiao": "tɕʰi̯ɑʊ̯",
254 | "qiu": "tɕʰi̯ɤʊ̯",
255 | "qiong": "tɕʰi̯ʊŋ",
256 | "qu": "tɕʰy",
257 | "qun": "tɕʰyn",
258 | "que": "tɕʰy̯œ",
259 | "quan": "tɕʰy̯ɛn",
260 | "den": "tən",
261 | "deng": "təŋ",
262 | "dou": "tɤʊ̯",
263 | "de": "tɯ̯ʌ",
264 | "de5": "tə",
265 | "zhan": "tʂan",
266 | "zhai": "tʂaɪ̯",
267 | "zhei": "tʂeɪ̯",
268 | "zhu": "tʂu",
269 | "zhuan": "tʂu̯an",
270 | "zhuai": "tʂu̯aɪ̯",
271 | "zhui": "tʂu̯eɪ̯",
272 | "zhua": "tʂu̯ɑ",
273 | "zhuo": "tʂu̯ɔ",
274 | "zhun": "tʂu̯ən",
275 | "zha": "tʂɑ",
276 | "zhang": "tʂɑŋ",
277 | "zhao": "tʂɑʊ̯",
278 | "zhen": "tʂən",
279 | "zheng": "tʂəŋ",
280 | "zhou": "tʂɤʊ̯",
281 | "zhe": "tʂɯ̯ʌ",
282 | "zhi": "tʂʅ",
283 | "zhong": "tʂʊŋ",
284 | "chan": "tʂʰan",
285 | "chai": "tʂʰaɪ̯",
286 | "chu": "tʂʰu",
287 | "chuan": "tʂʰu̯an",
288 | "chuai": "tʂʰu̯aɪ̯",
289 | "chui": "tʂʰu̯eɪ̯",
290 | "chua": "tʂʰu̯ɑ",
291 | "chuang": "tʂʰu̯ɑŋ",
292 | "chuo": "tʂʰu̯ɔ",
293 | "chun": "tʂʰu̯ən",
294 | "cha": "tʂʰɑ",
295 | "chang": "tʂʰɑŋ",
296 | "chao": "tʂʰɑʊ̯",
297 | "chen": "tʂʰən",
298 | "cheng": "tʂʰəŋ",
299 | "chou": "tʂʰɤʊ̯",
300 | "che": "tʂʰɯ̯ʌ",
301 | "chi": "tʂʰʅ",
302 | "chong": "tʂʰʊŋ",
303 | "zhuang": "tʂ̯u̯ɑŋ",
304 | "dong": "tʊŋ",
305 | "tan": "tʰan",
306 | "tai": "tʰaɪ̯",
307 | "ti": "tʰi",
308 | "ting": "tʰiŋ",
309 | "tie": "tʰiɛ",
310 | "tian": "tʰiɛn",
311 | "tiao": "tʰi̯ɑʊ̯",
312 | "tu": "tʰu",
313 | "tuan": "tʰu̯an",
314 | "tui": "tʰu̯eɪ̯",
315 | "tuo": "tʰu̯ɔ",
316 | "tun": "tʰu̯ən",
317 | "ta": "tʰɑ",
318 | "tang": "tʰɑŋ",
319 | "tao": "tʰɑʊ̯",
320 | "teng": "tʰəŋ",
321 | "tou": "tʰɤʊ̯",
322 | "te": "tʰɯ̯ʌ",
323 | "tong": "tʰʊŋ",
324 | "wu": "u",
325 | "wan": "u̯an",
326 | "wai": "u̯aɪ̯",
327 | "wei": "u̯eɪ̯",
328 | "wa": "u̯ɑ",
329 | "wang": "u̯ɑŋ",
330 | "wo": "u̯ɔ",
331 | "wen": "u̯ən",
332 | "weng": "u̯əŋ",
333 | "han": "xan",
334 | "hai": "xaɪ̯",
335 | "hei": "xeɪ̯",
336 | "hu": "xu",
337 | "huan": "xu̯an",
338 | "huai": "xu̯aɪ̯",
339 | "hui": "xu̯eɪ̯",
340 | "hua": "xu̯ɑ",
341 | "huang": "xu̯ɑŋ",
342 | "huo": "xu̯ɔ",
343 | "hun": "xu̯ən",
344 | "ha": "xɑ",
345 | "hang": "xɑŋ",
346 | "hao": "xɑʊ̯",
347 | "hen": "xən",
348 | "heng": "xəŋ",
349 | "hou": "xɤʊ̯",
350 | "he": "xɯ̯ʌ",
351 | "hong": "xʊŋ",
352 | "yu": "y",
353 | "yun": "yn",
354 | "yue": "y̯œ",
355 | "yuan": "y̯ɛn",
356 | "a": "ɑ",
357 | "ang": "ɑŋ",
358 | "er": "ɑɻ",
359 | "ao": "ɑʊ̯",
360 | "o": "ɔ",
361 | "xi": "ɕi",
362 | "xin": "ɕin",
363 | "xing": "ɕiŋ",
364 | "xie": "ɕiɛ",
365 | "xian": "ɕiɛn",
366 | "xia": "ɕi̯ɑ",
367 | "xiang": "ɕi̯ɑŋ",
368 | "xiao": "ɕi̯ɑʊ̯",
369 | "xiu": "ɕi̯ɤʊ̯",
370 | "xiong": "ɕi̯ʊŋ",
371 | "xu": "ɕy",
372 | "xun": "ɕyn",
373 | "xue": "ɕy̯œ",
374 | "xuan": "ɕy̯ɛn",
375 | "en": "ən",
376 | "eng": "əŋ",
377 | "ou": "ɤʊ̯",
378 | "e": "ɯ̯ʌ",
379 | "shan": "ʂan",
380 | "shai": "ʂaɪ̯",
381 | "shei": "ʂeɪ̯",
382 | "shu": "ʂu",
383 | "shuan": "ʂu̯an",
384 | "shuai": "ʂu̯aɪ̯",
385 | "shui": "ʂu̯eɪ̯",
386 | "shua": "ʂu̯ɑ",
387 | "shuang": "ʂu̯ɑŋ",
388 | "shuo": "ʂu̯ɔ",
389 | "shun": "ʂu̯ən",
390 | "sha": "ʂɑ",
391 | "shang": "ʂɑŋ",
392 | "shao": "ʂɑʊ̯",
393 | "shen": "ʂən",
394 | "sheng": "ʂəŋ",
395 | "shou": "ʂɤʊ̯",
396 | "she": "ʂɯ̯ʌ",
397 | "shi": "ʂʅ",
398 | "ran": "ʐan",
399 | "ru": "ʐu",
400 | "ruan": "ʐu̯an",
401 | "rui": "ʐu̯eɪ̯",
402 | "rua": "ʐu̯ɑ",
403 | "ruo": "ʐu̯ɔ",
404 | "run": "ʐu̯ən",
405 | "rang": "ʐɑŋ",
406 | "rao": "ʐɑʊ̯",
407 | "ren": "ʐən",
408 | "reng": "ʐəŋ",
409 | "rou": "ʐɤʊ̯",
410 | "re": "ʐɯ̯ʌ",
411 | "ri": "ʐʅ",
412 | "rong": "ʐʊŋ"
413 | }
--------------------------------------------------------------------------------
/src/methods/default.json:
--------------------------------------------------------------------------------
1 | {
2 | "a": "a",
3 | "ê": "ɛ",
4 | "ai": "ai",
5 | "an": "an",
6 | "ang": "aŋ",
7 | "ao": "au",
8 | "bai": "pai",
9 | "bang": "paŋ",
10 | "ban": "pan",
11 | "bao": "pau",
12 | "ba": "pa",
13 | "bei": "pei",
14 | "beng": "pəŋ",
15 | "ben": "pən",
16 | "bian": "piɛn",
17 | "biao": "piau",
18 | "bie": "piɛ",
19 | "bing": "piŋ",
20 | "bin": "pin",
21 | "bi": "pi",
22 | "bo": "po",
23 | "bu": "pu",
24 | "cai": "tsʰai",
25 | "cang": "tsʰaŋ",
26 | "can": "tsʰan",
27 | "cao": "tsʰau",
28 | "ca": "tsʰa",
29 | "cei": "tsʰei",
30 | "ceng": "tsʰəŋ",
31 | "cen": "tsʰən",
32 | "ce5": "tsʰə",
33 | "ce": "tsʰɤ",
34 | "chai": "tʂʰai",
35 | "chang": "tʂʰaŋ",
36 | "chan": "tʂʰan",
37 | "chao": "tʂʰau",
38 | "cha": "tʂʰa",
39 | "cheng": "tʂʰəŋ",
40 | "chen": "tʂʰən",
41 | "che5": "tʂʰə5",
42 | "che": "tʂʰɤ",
43 | "chi": "tʂʰʅ",
44 | "chong": "tʂʰuŋ",
45 | "chou": "tʂʰou",
46 | "chuai": "tʂʰuai",
47 | "chuang": "tʂʰuaŋ",
48 | "chuan": "tʂʰuan",
49 | "chua": "tʂʰua",
50 | "chui": "tʂʰuei",
51 | "chun": "tʂʰuən",
52 | "chuo": "tʂʰuo",
53 | "chu": "tʂʰu",
54 | "ci": "tsʰɿ",
55 | "cong": "tsʰuŋ",
56 | "cou": "tsʰou",
57 | "cuan": "tsʰuan",
58 | "cui": "tsʰuei",
59 | "cun": "tsʰuən",
60 | "cuo": "tsʰuo",
61 | "cu": "tsʰu",
62 | "dai": "tai",
63 | "dang": "taŋ",
64 | "dan": "tan",
65 | "dao": "tau",
66 | "da": "ta",
67 | "dei": "tei",
68 | "deng": "təŋ",
69 | "den": "tən",
70 | "de5": "tə",
71 | "de": "tɤ",
72 | "dian": "tiɛn",
73 | "diao": "tiau",
74 | "dia": "tia",
75 | "die": "tiɛ",
76 | "ding": "tiŋ",
77 | "di": "ti",
78 | "diu": "tiəu",
79 | "dong": "tuŋ",
80 | "dou": "tou",
81 | "duan": "tuan",
82 | "dui": "tuei",
83 | "dun": "tuən",
84 | "duo": "tuo",
85 | "du": "tu",
86 | "e5": "ə",
87 | "e": "ɤ",
88 | "ei": "ei",
89 | "en": "ən",
90 | "eng": "əŋ",
91 | "er": "ər",
92 | "fa": "fa",
93 | "fan": "fan",
94 | "fang": "faŋ",
95 | "fe5": "fə",
96 | "fe": "fɤ",
97 | "fei": "fei",
98 | "fen": "fən",
99 | "feng": "fəŋ",
100 | "fo": "fo",
101 | "fou": "fou",
102 | "fu": "fu",
103 | "gai": "kai",
104 | "ga": "ka",
105 | "gang": "kaŋ",
106 | "gan": "kan",
107 | "gao": "kau",
108 | "gei": "kei",
109 | "ge5": "kə",
110 | "ge": "kɤ",
111 | "geng": "kəŋ",
112 | "gen": "kən",
113 | "gong": "kuŋ",
114 | "gou": "kou",
115 | "guai": "kuai",
116 | "gua": "kua",
117 | "guang": "kuaŋ",
118 | "guan": "kuan",
119 | "gui": "kuei",
120 | "gu": "ku",
121 | "gun": "kuən",
122 | "guo": "kuo",
123 | "hai": "xai",
124 | "hang": "xaŋ",
125 | "han": "xan",
126 | "hao": "xau",
127 | "ha": "xa",
128 | "hei": "xei",
129 | "heng": "xəŋ",
130 | "hen": "xən",
131 | "he5": "xə",
132 | "he": "xɤ",
133 | "hong": "xuŋ",
134 | "hou": "xou",
135 | "huai": "xuai",
136 | "huang": "xuaŋ",
137 | "huan": "xuan",
138 | "hua": "xua",
139 | "hui": "xuei",
140 | "hun": "xuən",
141 | "huo": "xuo",
142 | "hu": "xu",
143 | "jiang": "tɕiɑŋ",
144 | "jian": "tɕiɛn",
145 | "jiao": "tɕiau",
146 | "jia": "tɕia",
147 | "jie": "tɕiɛ",
148 | "jing": "tɕiŋ",
149 | "jin": "tɕin",
150 | "jiong": "tɕyŋ",
151 | "ji": "tɕi",
152 | "jiu": "tɕiəu",
153 | "juan": "tɕyan",
154 | "jue": "tɕyɛ",
155 | "jun": "tɕyn",
156 | "ju": "tɕy",
157 | "kai": "kʰai",
158 | "ka": "kʰa",
159 | "kang": "kʰaŋ",
160 | "kan": "kʰan",
161 | "kao": "kʰau",
162 | "kei": "kʰei",
163 | "ke5": "kʰə",
164 | "ke": "kʰɤ",
165 | "keng": "kʰəŋ",
166 | "ken": "kʰən",
167 | "kong": "kʰuŋ",
168 | "kou": "kʰou",
169 | "kuai": "kʰuai",
170 | "kua": "kʰua",
171 | "kuang": "kʰuaŋ",
172 | "kuan": "kʰuan",
173 | "kui": "kʰuei",
174 | "ku": "kʰu",
175 | "kun": "kʰuən",
176 | "kuo": "kʰuo",
177 | "lai": "lai",
178 | "la": "la",
179 | "lang": "laŋ",
180 | "lan": "lan",
181 | "lüe": "lyɛ",
182 | "lü": "ly",
183 | "lao": "lau",
184 | "lei": "lei",
185 | "le5": "lə",
186 | "le": "lɤ",
187 | "leng": "ləŋ",
188 | "lia": "lia",
189 | "liang": "liɑŋ",
190 | "lian": "liɛn",
191 | "liao": "liau",
192 | "lie": "liɛ",
193 | "li": "li",
194 | "ling": "liŋ",
195 | "lin": "lin",
196 | "liu": "liəu",
197 | "lo": "lo",
198 | "long": "luŋ",
199 | "lou": "lou",
200 | "luan": "luan",
201 | "lu": "lu",
202 | "lun": "luən",
203 | "luo": "luo",
204 | "mai": "mai",
205 | "ma": "ma",
206 | "mang": "maŋ",
207 | "man": "man",
208 | "mao": "mau",
209 | "mei": "mei",
210 | "me5": "mə",
211 | "me": "mɤ",
212 | "meng": "məŋ",
213 | "men": "mən",
214 | "mian": "miɛn",
215 | "miao": "miau",
216 | "mie": "miɛ",
217 | "mi": "mi",
218 | "ming": "miŋ",
219 | "min": "min",
220 | "miu": "miəu",
221 | "mo": "mo",
222 | "mou": "mou",
223 | "mu": "mu",
224 | "nai": "nai",
225 | "na": "na",
226 | "nang": "naŋ",
227 | "nan": "nan",
228 | "nüe": "nyɛ",
229 | "nü": "ny",
230 | "nao": "nau",
231 | "nei": "nei",
232 | "ne5": "nə",
233 | "ne": "nɤ",
234 | "neng": "nəŋ",
235 | "nen": "nən",
236 | "niang": "niɑŋ",
237 | "nian": "niɛn",
238 | "niao": "niau",
239 | "nie": "niɛ",
240 | "ning": "niŋ",
241 | "ni": "ni",
242 | "nin": "nin",
243 | "niu": "niəu",
244 | "nong": "nuŋ",
245 | "nou": "nou",
246 | "nuan": "nuan",
247 | "nun": "nuən",
248 | "nu": "nu",
249 | "nuo": "nuo",
250 | "o": "o",
251 | "ou": "ou",
252 | "pai": "pʰai",
253 | "pang": "pʰaŋ",
254 | "pan": "pʰan",
255 | "pao": "pʰau",
256 | "pa": "pʰa",
257 | "pei": "pʰei",
258 | "peng": "pʰəŋ",
259 | "pen": "pʰən",
260 | "pian": "pʰiɛn",
261 | "piao": "pʰiau",
262 | "pie": "pʰiɛ",
263 | "ping": "pʰiŋ",
264 | "pin": "pʰin",
265 | "pi": "pʰi",
266 | "po": "pʰo",
267 | "pou": "pʰou",
268 | "pu": "pʰu",
269 | "qiang": "tɕʰiɑŋ",
270 | "qian": "tɕʰiɛn",
271 | "qiao": "tɕʰiau",
272 | "qia": "tɕʰia",
273 | "qie": "tɕʰiɛ",
274 | "qing": "tɕʰiŋ",
275 | "qin": "tɕʰin",
276 | "qiong": "tɕʰyŋ",
277 | "qi": "tɕʰi",
278 | "qiu": "tɕʰiəu",
279 | "quan": "tɕʰyan",
280 | "que": "tɕʰyɛ",
281 | "qun": "tɕʰyn",
282 | "qu": "tɕʰy",
283 | "ran": "ʐan",
284 | "rang": "ʐaŋ",
285 | "rao": "ʐau",
286 | "re5": "ʐə",
287 | "re": "ʐɤ",
288 | "ren": "ʐən",
289 | "reng": "ʐəŋ",
290 | "ri": "ʐʅ",
291 | "rong": "ʐuŋ",
292 | "rou": "ʐou",
293 | "rua": "ʐua",
294 | "ruan": "ʐuan",
295 | "ru": "ʐu",
296 | "rui": "ʐuei",
297 | "run": "ʐuən",
298 | "ruo": "ʐuo",
299 | "sai": "sai",
300 | "sang": "saŋ",
301 | "san": "san",
302 | "sao": "sau",
303 | "sa": "sa",
304 | "seng": "səŋ",
305 | "sen": "sən",
306 | "se5": "sə",
307 | "se": "sɤ",
308 | "sha": "ʂa",
309 | "shai": "ʂai",
310 | "shan": "ʂan",
311 | "shang": "ʂaŋ",
312 | "shao": "ʂau",
313 | "she5": "ʂə",
314 | "she": "ʂɤ",
315 | "shei": "ʂei",
316 | "shen": "ʂən",
317 | "sheng": "ʂəŋ",
318 | "shi": "ʂʅ",
319 | "shou": "ʂou",
320 | "shua": "ʂua",
321 | "shuai": "ʂuai",
322 | "shuan": "ʂuan",
323 | "shuang": "ʂuaŋ",
324 | "shu": "ʂu",
325 | "shui": "ʂuei",
326 | "shun": "ʂuən",
327 | "shuo": "ʂuo",
328 | "si": "sɿ",
329 | "song": "suŋ",
330 | "sou": "sou",
331 | "suan": "suan",
332 | "sui": "suei",
333 | "sun": "suən",
334 | "suo": "suo",
335 | "su": "su",
336 | "tai": "tʰai",
337 | "tang": "tʰaŋ",
338 | "tan": "tʰan",
339 | "tao": "tʰau",
340 | "ta": "tʰa",
341 | "teng": "tʰəŋ",
342 | "te5": "tʰə",
343 | "te": "tʰɤ",
344 | "tian": "tʰiɛn",
345 | "tiao": "tʰiau",
346 | "tie": "tʰiɛ",
347 | "ting": "tʰiŋ",
348 | "ti": "tʰi",
349 | "tong": "tʰuŋ",
350 | "tou": "tʰou",
351 | "tuan": "tʰuan",
352 | "tui": "tʰuei",
353 | "tun": "tʰuən",
354 | "tuo": "tʰuo",
355 | "tu": "tʰu",
356 | "wai": "uai",
357 | "wang": "uaŋ",
358 | "wan": "uan",
359 | "wa": "ua",
360 | "wei": "uei",
361 | "weng": "uəŋ",
362 | "wen": "uən",
363 | "wo": "uo",
364 | "wu": "u",
365 | "xia": "ɕia",
366 | "xian": "ɕiɛn",
367 | "xiang": "ɕiɑŋ",
368 | "xiao": "ɕiau",
369 | "xie": "ɕiɛ",
370 | "xi": "ɕi",
371 | "xin": "ɕin",
372 | "xing": "ɕiŋ",
373 | "xiong": "ɕyŋ",
374 | "xiu": "ɕiəu",
375 | "xuan": "ɕyan",
376 | "xue": "ɕyɛ",
377 | "xu": "ɕy",
378 | "xun": "ɕyn",
379 | "ya": "ia",
380 | "yang": "iɑŋ",
381 | "yan": "iɛn",
382 | "yao": "iau",
383 | "ye": "iɛ",
384 | "yi": "i",
385 | "ying": "iŋ",
386 | "yin": "in",
387 | "yong": "yŋ",
388 | "you": "iəu",
389 | "yuan": "yan",
390 | "yue": "yɛ",
391 | "yun": "yn",
392 | "yu": "y",
393 | "zai": "tsai",
394 | "zang": "tsaŋ",
395 | "zan": "tsan",
396 | "zao": "tsau",
397 | "za": "tsa",
398 | "zei": "tsei",
399 | "zeng": "tsəŋ",
400 | "zen": "tsən",
401 | "ze5": "tsə",
402 | "ze": "tsɤ",
403 | "zhai": "tʂai",
404 | "zhang": "tʂaŋ",
405 | "zhan": "tʂan",
406 | "zhao": "tʂau",
407 | "zha": "tʂa",
408 | "zhei": "tʂei",
409 | "zheng": "tʂəŋ",
410 | "zhen": "tʂən",
411 | "zhe5": "tʂə",
412 | "zhe": "tʂɤ",
413 | "zhi": "tʂʅ",
414 | "zhong": "tʂuŋ",
415 | "zhou": "tʂou",
416 | "zhuai": "tʂuai",
417 | "zhuang": "tʂuaŋ",
418 | "zhuan": "tʂuan",
419 | "zhua": "tʂua",
420 | "zhui": "tʂuei",
421 | "zhun": "tʂuən",
422 | "zhuo": "tʂuo",
423 | "zhu": "tʂu",
424 | "zi": "tsɿ",
425 | "zong": "tsuŋ",
426 | "zou": "tsou",
427 | "zuan": "tsuan",
428 | "zui": "tsuei",
429 | "zun": "tsuən",
430 | "zuo": "tsuo",
431 | "zu": "tsu"
432 | }
--------------------------------------------------------------------------------
/dist/pinyin2ipa.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * pinyin2ipa v1.0.4 (July 19th 2022)
3 | * Converts Mandarin Chinese pinyin notation to IPA (international phonetic alphabet) notation
4 | *
5 | * https://github.com/Connum/npm-pinyin2ipa#readme
6 | *
7 | * @author Connum
8 | * @license MIT
9 | */
10 | (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.pinyin2ipa = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i4||p>1?separate(e).split(" ").forEach(function(e){(g=e.match(new RegExp("("+tones+")","g")))&&(p=g.length),e.length>4||p>1?separate(e).split(" ").forEach(function(e){r.push(e.trim())}):r.push(e.trim())}):r.push(e.trim())}),r};
15 |
16 | },{}],3:[function(require,module,exports){
17 | "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _separatePinyinInSyllables=require("./helpers/separate-pinyin-in-syllables"),_separatePinyinInSyllables2=_interopRequireDefault(_separatePinyinInSyllables);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var defaultOptions={byNbsp:!1},pinyinSeparate=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:defaultOptions;return t!==defaultOptions&&(t=Object.assign({},defaultOptions,t)),(0,_separatePinyinInSyllables2.default)(e,t.byNbsp)};exports.default=pinyinSeparate,module.exports=exports.default;
18 |
19 | },{"./helpers/separate-pinyin-in-syllables":2}]},{},[1])(1)
20 | });
21 |
--------------------------------------------------------------------------------
/dist/pinyin2ipa.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * pinyin2ipa v1.0.4 (July 19th 2022)
3 | * Converts Mandarin Chinese pinyin notation to IPA (international phonetic alphabet) notation
4 | *
5 | * https://github.com/Connum/npm-pinyin2ipa#readme
6 | *
7 | * @author Connum
8 | * @license MIT
9 | */
10 | (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.pinyin2ipa = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 1) {
97 | var part = null;
98 | var convertedWord = null;
99 | for (var i = 0; i < splits.length; i++) {
100 | part = splits[i];
101 | convertedWord = pinyinWord2IPA(part, methodTable, toneRep, options);
102 | if (convertedWord.length) {
103 | convertedWords.push(convertedWord);
104 | }
105 | }
106 | return convertedWords.join(' ');
107 | }
108 | word = numberifyTones(word.toLowerCase());
109 | }
110 |
111 | var pureWord = word.replace(/([^\d]+)\d+/g, '$1');
112 | if (!isPinYin(pureWord)) {
113 | return options.filterUnknown ? '' : '*' + pureWord + '*';
114 | }
115 |
116 | var toneMatch = word.match(/\d$/);
117 | var toneIndex = (toneMatch ? parseInt(toneMatch[0], 10) : 5) - 1;
118 | var toneMark = toneIndex === 4 && (!options.markNeutral || options.toneMarker !== 'number') ? '' : toneRep[toneIndex];
119 | if (pureWord === '\\n') return '\n';
120 |
121 | var result = '';
122 | if (word === pureWord && methodTable[word + '5']) {
123 | result = methodTable[word + '5'] + toneMark;
124 | } else if (methodTable[word]) {
125 | result = methodTable[word] + toneMark;
126 | } else if (methodTable[pureWord]) {
127 | result = methodTable[pureWord] + toneMark;
128 | } else {
129 | result = options.filterUnknown ? '' : '*' + pureWord + '*';
130 | }
131 |
132 | return result;
133 | }
134 |
135 | function pinyin2ipa(pinyIn) {
136 | var optionsArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
137 |
138 | var options = optionsArg;
139 | var output = pinyIn;
140 |
141 | if (options !== defaultOptions) {
142 | options = Object.assign({}, defaultOptions, options);
143 | }
144 |
145 | if (options.superscript && options.toneMarker !== 'number' && options.toneMarker !== 'chaonumber') {
146 | options.superscript = false;
147 | }
148 |
149 | var toneRep = toneReps['' + options.toneMarker + (options.superscript ? 'Superscript' : '')];
150 |
151 | output = output.replace(/(\d+)([^ ])/g, '$1 $2');
152 | output = output.replace(/\r?\n/g, ' #~linebreak~# ');
153 |
154 | var words = output.split(/[ '".,;:?!*“”\-—$§€()/´`]+/g);
155 | words = words.filter(function (w) {
156 | return !/^ +$/.test(w);
157 | });
158 |
159 | var methodTable = pinyin2ipa.methods[options.method];
160 | words = words.map(function (word) {
161 | return pinyinWord2IPA(word, methodTable, toneRep, options);
162 | });
163 |
164 | words = words.filter(function (w) {
165 | return !/^ +$/.test(w);
166 | });
167 |
168 | return words.join(' ').replace(/ ?(#~linebreak~#|\n) ?/g, '\n').trim();
169 | }
170 |
171 | pinyin2ipa.methods = {
172 | default: _default2.default,
173 | sophisticated: _sophisticated2.default
174 | };
175 |
176 | exports.default = pinyin2ipa;
177 |
178 | // export { pinyin2ipa };
179 |
180 | module.exports = exports.default;
181 | },{"./methods/default.json":2,"./methods/sophisticated.json":3,"pinyin-separate":5}],2:[function(require,module,exports){
182 | module.exports={
183 | "a": "a",
184 | "ê": "ɛ",
185 | "ai": "ai",
186 | "an": "an",
187 | "ang": "aŋ",
188 | "ao": "au",
189 | "bai": "pai",
190 | "bang": "paŋ",
191 | "ban": "pan",
192 | "bao": "pau",
193 | "ba": "pa",
194 | "bei": "pei",
195 | "beng": "pəŋ",
196 | "ben": "pən",
197 | "bian": "piɛn",
198 | "biao": "piau",
199 | "bie": "piɛ",
200 | "bing": "piŋ",
201 | "bin": "pin",
202 | "bi": "pi",
203 | "bo": "po",
204 | "bu": "pu",
205 | "cai": "tsʰai",
206 | "cang": "tsʰaŋ",
207 | "can": "tsʰan",
208 | "cao": "tsʰau",
209 | "ca": "tsʰa",
210 | "cei": "tsʰei",
211 | "ceng": "tsʰəŋ",
212 | "cen": "tsʰən",
213 | "ce5": "tsʰə",
214 | "ce": "tsʰɤ",
215 | "chai": "tʂʰai",
216 | "chang": "tʂʰaŋ",
217 | "chan": "tʂʰan",
218 | "chao": "tʂʰau",
219 | "cha": "tʂʰa",
220 | "cheng": "tʂʰəŋ",
221 | "chen": "tʂʰən",
222 | "che5": "tʂʰə5",
223 | "che": "tʂʰɤ",
224 | "chi": "tʂʰʅ",
225 | "chong": "tʂʰuŋ",
226 | "chou": "tʂʰou",
227 | "chuai": "tʂʰuai",
228 | "chuang": "tʂʰuaŋ",
229 | "chuan": "tʂʰuan",
230 | "chua": "tʂʰua",
231 | "chui": "tʂʰuei",
232 | "chun": "tʂʰuən",
233 | "chuo": "tʂʰuo",
234 | "chu": "tʂʰu",
235 | "ci": "tsʰɿ",
236 | "cong": "tsʰuŋ",
237 | "cou": "tsʰou",
238 | "cuan": "tsʰuan",
239 | "cui": "tsʰuei",
240 | "cun": "tsʰuən",
241 | "cuo": "tsʰuo",
242 | "cu": "tsʰu",
243 | "dai": "tai",
244 | "dang": "taŋ",
245 | "dan": "tan",
246 | "dao": "tau",
247 | "da": "ta",
248 | "dei": "tei",
249 | "deng": "təŋ",
250 | "den": "tən",
251 | "de5": "tə",
252 | "de": "tɤ",
253 | "dian": "tiɛn",
254 | "diao": "tiau",
255 | "dia": "tia",
256 | "die": "tiɛ",
257 | "ding": "tiŋ",
258 | "di": "ti",
259 | "diu": "tiəu",
260 | "dong": "tuŋ",
261 | "dou": "tou",
262 | "duan": "tuan",
263 | "dui": "tuei",
264 | "dun": "tuən",
265 | "duo": "tuo",
266 | "du": "tu",
267 | "e5": "ə",
268 | "e": "ɤ",
269 | "ei": "ei",
270 | "en": "ən",
271 | "eng": "əŋ",
272 | "er": "ər",
273 | "fa": "fa",
274 | "fan": "fan",
275 | "fang": "faŋ",
276 | "fe5": "fə",
277 | "fe": "fɤ",
278 | "fei": "fei",
279 | "fen": "fən",
280 | "feng": "fəŋ",
281 | "fo": "fo",
282 | "fou": "fou",
283 | "fu": "fu",
284 | "gai": "kai",
285 | "ga": "ka",
286 | "gang": "kaŋ",
287 | "gan": "kan",
288 | "gao": "kau",
289 | "gei": "kei",
290 | "ge5": "kə",
291 | "ge": "kɤ",
292 | "geng": "kəŋ",
293 | "gen": "kən",
294 | "gong": "kuŋ",
295 | "gou": "kou",
296 | "guai": "kuai",
297 | "gua": "kua",
298 | "guang": "kuaŋ",
299 | "guan": "kuan",
300 | "gui": "kuei",
301 | "gu": "ku",
302 | "gun": "kuən",
303 | "guo": "kuo",
304 | "hai": "xai",
305 | "hang": "xaŋ",
306 | "han": "xan",
307 | "hao": "xau",
308 | "ha": "xa",
309 | "hei": "xei",
310 | "heng": "xəŋ",
311 | "hen": "xən",
312 | "he5": "xə",
313 | "he": "xɤ",
314 | "hong": "xuŋ",
315 | "hou": "xou",
316 | "huai": "xuai",
317 | "huang": "xuaŋ",
318 | "huan": "xuan",
319 | "hua": "xua",
320 | "hui": "xuei",
321 | "hun": "xuən",
322 | "huo": "xuo",
323 | "hu": "xu",
324 | "jiang": "tɕiɑŋ",
325 | "jian": "tɕiɛn",
326 | "jiao": "tɕiau",
327 | "jia": "tɕia",
328 | "jie": "tɕiɛ",
329 | "jing": "tɕiŋ",
330 | "jin": "tɕin",
331 | "jiong": "tɕyŋ",
332 | "ji": "tɕi",
333 | "jiu": "tɕiəu",
334 | "juan": "tɕyan",
335 | "jue": "tɕyɛ",
336 | "jun": "tɕyn",
337 | "ju": "tɕy",
338 | "kai": "kʰai",
339 | "ka": "kʰa",
340 | "kang": "kʰaŋ",
341 | "kan": "kʰan",
342 | "kao": "kʰau",
343 | "kei": "kʰei",
344 | "ke5": "kʰə",
345 | "ke": "kʰɤ",
346 | "keng": "kʰəŋ",
347 | "ken": "kʰən",
348 | "kong": "kʰuŋ",
349 | "kou": "kʰou",
350 | "kuai": "kʰuai",
351 | "kua": "kʰua",
352 | "kuang": "kʰuaŋ",
353 | "kuan": "kʰuan",
354 | "kui": "kʰuei",
355 | "ku": "kʰu",
356 | "kun": "kʰuən",
357 | "kuo": "kʰuo",
358 | "lai": "lai",
359 | "la": "la",
360 | "lang": "laŋ",
361 | "lan": "lan",
362 | "lüe": "lyɛ",
363 | "lü": "ly",
364 | "lao": "lau",
365 | "lei": "lei",
366 | "le5": "lə",
367 | "le": "lɤ",
368 | "leng": "ləŋ",
369 | "lia": "lia",
370 | "liang": "liɑŋ",
371 | "lian": "liɛn",
372 | "liao": "liau",
373 | "lie": "liɛ",
374 | "li": "li",
375 | "ling": "liŋ",
376 | "lin": "lin",
377 | "liu": "liəu",
378 | "lo": "lo",
379 | "long": "luŋ",
380 | "lou": "lou",
381 | "luan": "luan",
382 | "lu": "lu",
383 | "lun": "luən",
384 | "luo": "luo",
385 | "mai": "mai",
386 | "ma": "ma",
387 | "mang": "maŋ",
388 | "man": "man",
389 | "mao": "mau",
390 | "mei": "mei",
391 | "me5": "mə",
392 | "me": "mɤ",
393 | "meng": "məŋ",
394 | "men": "mən",
395 | "mian": "miɛn",
396 | "miao": "miau",
397 | "mie": "miɛ",
398 | "mi": "mi",
399 | "ming": "miŋ",
400 | "min": "min",
401 | "miu": "miəu",
402 | "mo": "mo",
403 | "mou": "mou",
404 | "mu": "mu",
405 | "nai": "nai",
406 | "na": "na",
407 | "nang": "naŋ",
408 | "nan": "nan",
409 | "nüe": "nyɛ",
410 | "nü": "ny",
411 | "nao": "nau",
412 | "nei": "nei",
413 | "ne5": "nə",
414 | "ne": "nɤ",
415 | "neng": "nəŋ",
416 | "nen": "nən",
417 | "niang": "niɑŋ",
418 | "nian": "niɛn",
419 | "niao": "niau",
420 | "nie": "niɛ",
421 | "ning": "niŋ",
422 | "ni": "ni",
423 | "nin": "nin",
424 | "niu": "niəu",
425 | "nong": "nuŋ",
426 | "nou": "nou",
427 | "nuan": "nuan",
428 | "nun": "nuən",
429 | "nu": "nu",
430 | "nuo": "nuo",
431 | "o": "o",
432 | "ou": "ou",
433 | "pai": "pʰai",
434 | "pang": "pʰaŋ",
435 | "pan": "pʰan",
436 | "pao": "pʰau",
437 | "pa": "pʰa",
438 | "pei": "pʰei",
439 | "peng": "pʰəŋ",
440 | "pen": "pʰən",
441 | "pian": "pʰiɛn",
442 | "piao": "pʰiau",
443 | "pie": "pʰiɛ",
444 | "ping": "pʰiŋ",
445 | "pin": "pʰin",
446 | "pi": "pʰi",
447 | "po": "pʰo",
448 | "pou": "pʰou",
449 | "pu": "pʰu",
450 | "qiang": "tɕʰiɑŋ",
451 | "qian": "tɕʰiɛn",
452 | "qiao": "tɕʰiau",
453 | "qia": "tɕʰia",
454 | "qie": "tɕʰiɛ",
455 | "qing": "tɕʰiŋ",
456 | "qin": "tɕʰin",
457 | "qiong": "tɕʰyŋ",
458 | "qi": "tɕʰi",
459 | "qiu": "tɕʰiəu",
460 | "quan": "tɕʰyan",
461 | "que": "tɕʰyɛ",
462 | "qun": "tɕʰyn",
463 | "qu": "tɕʰy",
464 | "ran": "ʐan",
465 | "rang": "ʐaŋ",
466 | "rao": "ʐau",
467 | "re5": "ʐə",
468 | "re": "ʐɤ",
469 | "ren": "ʐən",
470 | "reng": "ʐəŋ",
471 | "ri": "ʐʅ",
472 | "rong": "ʐuŋ",
473 | "rou": "ʐou",
474 | "rua": "ʐua",
475 | "ruan": "ʐuan",
476 | "ru": "ʐu",
477 | "rui": "ʐuei",
478 | "run": "ʐuən",
479 | "ruo": "ʐuo",
480 | "sai": "sai",
481 | "sang": "saŋ",
482 | "san": "san",
483 | "sao": "sau",
484 | "sa": "sa",
485 | "seng": "səŋ",
486 | "sen": "sən",
487 | "se5": "sə",
488 | "se": "sɤ",
489 | "sha": "ʂa",
490 | "shai": "ʂai",
491 | "shan": "ʂan",
492 | "shang": "ʂaŋ",
493 | "shao": "ʂau",
494 | "she5": "ʂə",
495 | "she": "ʂɤ",
496 | "shei": "ʂei",
497 | "shen": "ʂən",
498 | "sheng": "ʂəŋ",
499 | "shi": "ʂʅ",
500 | "shou": "ʂou",
501 | "shua": "ʂua",
502 | "shuai": "ʂuai",
503 | "shuan": "ʂuan",
504 | "shuang": "ʂuaŋ",
505 | "shu": "ʂu",
506 | "shui": "ʂuei",
507 | "shun": "ʂuən",
508 | "shuo": "ʂuo",
509 | "si": "sɿ",
510 | "song": "suŋ",
511 | "sou": "sou",
512 | "suan": "suan",
513 | "sui": "suei",
514 | "sun": "suən",
515 | "suo": "suo",
516 | "su": "su",
517 | "tai": "tʰai",
518 | "tang": "tʰaŋ",
519 | "tan": "tʰan",
520 | "tao": "tʰau",
521 | "ta": "tʰa",
522 | "teng": "tʰəŋ",
523 | "te5": "tʰə",
524 | "te": "tʰɤ",
525 | "tian": "tʰiɛn",
526 | "tiao": "tʰiau",
527 | "tie": "tʰiɛ",
528 | "ting": "tʰiŋ",
529 | "ti": "tʰi",
530 | "tong": "tʰuŋ",
531 | "tou": "tʰou",
532 | "tuan": "tʰuan",
533 | "tui": "tʰuei",
534 | "tun": "tʰuən",
535 | "tuo": "tʰuo",
536 | "tu": "tʰu",
537 | "wai": "uai",
538 | "wang": "uaŋ",
539 | "wan": "uan",
540 | "wa": "ua",
541 | "wei": "uei",
542 | "weng": "uəŋ",
543 | "wen": "uən",
544 | "wo": "uo",
545 | "wu": "u",
546 | "xia": "ɕia",
547 | "xian": "ɕiɛn",
548 | "xiang": "ɕiɑŋ",
549 | "xiao": "ɕiau",
550 | "xie": "ɕiɛ",
551 | "xi": "ɕi",
552 | "xin": "ɕin",
553 | "xing": "ɕiŋ",
554 | "xiong": "ɕyŋ",
555 | "xiu": "ɕiəu",
556 | "xuan": "ɕyan",
557 | "xue": "ɕyɛ",
558 | "xu": "ɕy",
559 | "xun": "ɕyn",
560 | "ya": "ia",
561 | "yang": "iɑŋ",
562 | "yan": "iɛn",
563 | "yao": "iau",
564 | "ye": "iɛ",
565 | "yi": "i",
566 | "ying": "iŋ",
567 | "yin": "in",
568 | "yong": "yŋ",
569 | "you": "iəu",
570 | "yuan": "yan",
571 | "yue": "yɛ",
572 | "yun": "yn",
573 | "yu": "y",
574 | "zai": "tsai",
575 | "zang": "tsaŋ",
576 | "zan": "tsan",
577 | "zao": "tsau",
578 | "za": "tsa",
579 | "zei": "tsei",
580 | "zeng": "tsəŋ",
581 | "zen": "tsən",
582 | "ze5": "tsə",
583 | "ze": "tsɤ",
584 | "zhai": "tʂai",
585 | "zhang": "tʂaŋ",
586 | "zhan": "tʂan",
587 | "zhao": "tʂau",
588 | "zha": "tʂa",
589 | "zhei": "tʂei",
590 | "zheng": "tʂəŋ",
591 | "zhen": "tʂən",
592 | "zhe5": "tʂə",
593 | "zhe": "tʂɤ",
594 | "zhi": "tʂʅ",
595 | "zhong": "tʂuŋ",
596 | "zhou": "tʂou",
597 | "zhuai": "tʂuai",
598 | "zhuang": "tʂuaŋ",
599 | "zhuan": "tʂuan",
600 | "zhua": "tʂua",
601 | "zhui": "tʂuei",
602 | "zhun": "tʂuən",
603 | "zhuo": "tʂuo",
604 | "zhu": "tʂu",
605 | "zi": "tsɿ",
606 | "zong": "tsuŋ",
607 | "zou": "tsou",
608 | "zuan": "tsuan",
609 | "zui": "tsuei",
610 | "zun": "tsuən",
611 | "zuo": "tsuo",
612 | "zu": "tsu"
613 | }
614 | },{}],3:[function(require,module,exports){
615 | module.exports={
616 | "an": "an",
617 | "ai": "aɪ̯",
618 | "ei": "eɪ̯",
619 | "fan": "fan",
620 | "fei": "feɪ̯",
621 | "fu": "fu",
622 | "fo": "fu̯ɔ",
623 | "fa": "fɑ",
624 | "fang": "fɑŋ",
625 | "fen": "fən",
626 | "feng": "fəŋ",
627 | "fou": "fɤʊ̯",
628 | "yi": "i",
629 | "yin": "in",
630 | "ying": "iŋ",
631 | "yong": "jʊŋ",
632 | "ye": "iɛ",
633 | "yan": "iɛn",
634 | "ya": "i̯ɑ",
635 | "yang": "i̯ɑŋ",
636 | "yao": "i̯ɑʊ̯",
637 | "you": "i̯ɤʊ̯",
638 | "gan": "kan",
639 | "gai": "kaɪ̯",
640 | "gei": "keɪ̯",
641 | "gu": "ku",
642 | "guan": "ku̯an",
643 | "guai": "ku̯aɪ̯",
644 | "gui": "ku̯eɪ̯",
645 | "gua": "ku̯ɑ",
646 | "guang": "ku̯ɑŋ",
647 | "guo": "ku̯ɔ",
648 | "gun": "ku̯ən",
649 | "ga": "kɑ",
650 | "gang": "kɑŋ",
651 | "gao": "kɑʊ̯",
652 | "gen": "kən",
653 | "geng": "kəŋ",
654 | "gou": "kɤʊ̯",
655 | "ge": "kɯ̯ʌ",
656 | "gong": "kʊŋ",
657 | "kan": "kʰan",
658 | "kai": "kʰaɪ̯",
659 | "kei": "kʰeɪ̯",
660 | "ku": "kʰu",
661 | "kuan": "kʰu̯an",
662 | "kuai": "kʰu̯aɪ̯",
663 | "kui": "kʰu̯eɪ̯",
664 | "kua": "kʰu̯ɑ",
665 | "kuang": "kʰu̯ɑŋ",
666 | "kuo": "kʰu̯ɔ",
667 | "kun": "kʰu̯ən",
668 | "ka": "kʰɑ",
669 | "kang": "kʰɑŋ",
670 | "kao": "kʰɑʊ̯",
671 | "ken": "kʰən",
672 | "keng": "kʰəŋ",
673 | "kou": "kʰɤʊ̯",
674 | "ke": "kʰɯ̯ʌ",
675 | "kong": "kʰʊŋ",
676 | "lan": "lan",
677 | "lai": "laɪ̯",
678 | "lei": "leɪ̯",
679 | "li": "li",
680 | "lin": "lin",
681 | "ling": "liŋ",
682 | "lie": "liɛ",
683 | "lian": "liɛn",
684 | "lia": "li̯ɑ",
685 | "liang": "li̯ɑŋ",
686 | "liao": "li̯ɑʊ̯",
687 | "liu": "li̯ɤʊ̯",
688 | "lu": "lu",
689 | "luan": "lu̯an",
690 | "lo": "lu̯ɔ",
691 | "luo": "lu̯ɔ",
692 | "lun": "lu̯ən",
693 | "lü": "ly",
694 | "lüe": "ly̯œ",
695 | "la": "lɑ",
696 | "lang": "lɑŋ",
697 | "lao": "lɑʊ̯",
698 | "leng": "ləŋ",
699 | "lou": "lɤʊ̯",
700 | "le": "lɯ̯ʌ",
701 | "long": "lʊŋ",
702 | "man": "man",
703 | "mai": "maɪ̯",
704 | "mei": "meɪ̯",
705 | "mi": "mi",
706 | "min": "min",
707 | "ming": "miŋ",
708 | "mie": "miɛ",
709 | "mian": "miɛn",
710 | "miao": "mi̯ɑʊ̯",
711 | "miu": "mi̯ɤʊ̯",
712 | "mu": "mu",
713 | "mo": "mu̯ɔ",
714 | "ma": "mɑ",
715 | "mang": "mɑŋ",
716 | "mao": "mɑʊ̯",
717 | "men": "mən",
718 | "meng": "məŋ",
719 | "mou": "mɤʊ̯",
720 | "me": "mɯ̯ʌ",
721 | "nan": "nan",
722 | "nai": "naɪ̯",
723 | "nei": "neɪ̯",
724 | "ni": "ni",
725 | "nin": "nin",
726 | "ning": "niŋ",
727 | "nie": "niɛ",
728 | "nian": "niɛn",
729 | "niang": "ni̯ɑŋ",
730 | "niao": "ni̯ɑʊ̯",
731 | "niu": "ni̯ɤʊ̯",
732 | "nu": "nu",
733 | "nuan": "nu̯an",
734 | "nuo": "nu̯ɔ",
735 | "nü": "ny",
736 | "nüe": "ny̯œ",
737 | "na": "nɑ",
738 | "nang": "nɑŋ",
739 | "nao": "nɑʊ̯",
740 | "nen": "nən",
741 | "neng": "nəŋ",
742 | "nou": "nɤʊ̯",
743 | "ne": "nɯ̯ʌ",
744 | "nong": "nʊŋ",
745 | "ban": "pan",
746 | "bai": "paɪ̯",
747 | "bei": "peɪ̯",
748 | "bi": "pi",
749 | "bin": "pin",
750 | "bing": "piŋ",
751 | "bie": "piɛ",
752 | "bian": "piɛn",
753 | "biang": "pi̯ɑŋ",
754 | "biao": "pi̯ɑʊ̯",
755 | "bu": "pu",
756 | "bo": "pu̯ɔ",
757 | "ba": "pɑ",
758 | "bang": "pɑŋ",
759 | "bao": "pɑʊ̯",
760 | "ben": "pən",
761 | "beng": "pəŋ",
762 | "pan": "pʰan",
763 | "pai": "pʰaɪ̯",
764 | "pei": "pʰeɪ̯",
765 | "pi": "pʰi",
766 | "pin": "pʰin",
767 | "ping": "pʰiŋ",
768 | "pie": "pʰiɛ",
769 | "pian": "pʰiɛn",
770 | "piao": "pʰi̯ɑʊ̯",
771 | "pu": "pʰu",
772 | "po": "pʰu̯ɔ",
773 | "pa": "pʰɑ",
774 | "pang": "pʰɑŋ",
775 | "pao": "pʰɑʊ̯",
776 | "pen": "pʰən",
777 | "peng": "pʰəŋ",
778 | "pou": "pʰɤʊ̯",
779 | "san": "san",
780 | "sai": "saɪ̯",
781 | "su": "su",
782 | "suan": "su̯an",
783 | "sui": "su̯eɪ̯",
784 | "suo": "su̯ɔ",
785 | "sun": "su̯ən",
786 | "sa": "sɑ",
787 | "sang": "sɑŋ",
788 | "sao": "sɑʊ̯",
789 | "sen": "sən",
790 | "seng": "səŋ",
791 | "sou": "sɤʊ̯",
792 | "se": "sɯ̯ʌ",
793 | "si": "sɿ",
794 | "song": "sʊŋ",
795 | "dan": "tan",
796 | "dai": "taɪ̯",
797 | "dei": "teɪ̯",
798 | "di": "ti",
799 | "ding": "tiŋ",
800 | "die": "tiɛ",
801 | "dian": "tiɛn",
802 | "diao": "ti̯ɑʊ̯",
803 | "diu": "ti̯ɤʊ̯",
804 | "zan": "tsan",
805 | "zai": "tsaɪ̯",
806 | "zei": "tseɪ̯",
807 | "zu": "tsu",
808 | "zuan": "tsu̯an",
809 | "zui": "tsu̯eɪ̯",
810 | "zuo": "tsu̯ɔ",
811 | "zun": "tsu̯ən",
812 | "za": "tsɑ",
813 | "zang": "tsɑŋ",
814 | "zao": "tsɑʊ̯",
815 | "zen": "tsən",
816 | "zeng": "tsəŋ",
817 | "zou": "tsɤʊ̯",
818 | "ze": "tsɯ̯ʌ",
819 | "zi": "tsɿ",
820 | "zong": "tsʊŋ",
821 | "can": "tsʰan",
822 | "cai": "tsʰaɪ̯",
823 | "cei": "tsʰeɪ̯",
824 | "cu": "tsʰu",
825 | "cuan": "tsʰu̯an",
826 | "cui": "tsʰu̯eɪ̯",
827 | "cuo": "tsʰu̯ɔ",
828 | "cun": "tsʰu̯ən",
829 | "ca": "tsʰɑ",
830 | "cang": "tsʰɑŋ",
831 | "cao": "tsʰɑʊ̯",
832 | "cen": "tsʰən",
833 | "ceng": "tsʰəŋ",
834 | "cou": "tsʰɤʊ̯",
835 | "ce": "tsʰɯ̯ʌ",
836 | "ci": "tsʰɿ",
837 | "cong": "tsʰʊŋ",
838 | "du": "tu",
839 | "duan": "tu̯an",
840 | "dui": "tu̯eɪ̯",
841 | "duo": "tu̯ɔ",
842 | "dun": "tu̯ən",
843 | "da": "tɑ",
844 | "dang": "tɑŋ",
845 | "dao": "tɑʊ̯",
846 | "ji": "tɕi",
847 | "jin": "tɕin",
848 | "jing": "tɕiŋ",
849 | "jie": "tɕiɛ",
850 | "jian": "tɕiɛn",
851 | "jia": "tɕi̯ɑ",
852 | "jiang": "tɕi̯ɑŋ",
853 | "jiao": "tɕi̯ɑʊ̯",
854 | "jiu": "tɕi̯ɤʊ̯",
855 | "jiong": "tɕi̯ʊŋ",
856 | "ju": "tɕy",
857 | "jun": "tɕyn",
858 | "jue": "tɕy̯œ",
859 | "juan": "tɕy̯ɛn",
860 | "qi": "tɕʰi",
861 | "qin": "tɕʰin",
862 | "qing": "tɕʰiŋ",
863 | "qie": "tɕʰiɛ",
864 | "qian": "tɕʰiɛn",
865 | "qia": "tɕʰi̯ɑ",
866 | "qiang": "tɕʰi̯ɑŋ",
867 | "qiao": "tɕʰi̯ɑʊ̯",
868 | "qiu": "tɕʰi̯ɤʊ̯",
869 | "qiong": "tɕʰi̯ʊŋ",
870 | "qu": "tɕʰy",
871 | "qun": "tɕʰyn",
872 | "que": "tɕʰy̯œ",
873 | "quan": "tɕʰy̯ɛn",
874 | "den": "tən",
875 | "deng": "təŋ",
876 | "dou": "tɤʊ̯",
877 | "de": "tɯ̯ʌ",
878 | "de5": "tə",
879 | "zhan": "tʂan",
880 | "zhai": "tʂaɪ̯",
881 | "zhei": "tʂeɪ̯",
882 | "zhu": "tʂu",
883 | "zhuan": "tʂu̯an",
884 | "zhuai": "tʂu̯aɪ̯",
885 | "zhui": "tʂu̯eɪ̯",
886 | "zhua": "tʂu̯ɑ",
887 | "zhuo": "tʂu̯ɔ",
888 | "zhun": "tʂu̯ən",
889 | "zha": "tʂɑ",
890 | "zhang": "tʂɑŋ",
891 | "zhao": "tʂɑʊ̯",
892 | "zhen": "tʂən",
893 | "zheng": "tʂəŋ",
894 | "zhou": "tʂɤʊ̯",
895 | "zhe": "tʂɯ̯ʌ",
896 | "zhi": "tʂʅ",
897 | "zhong": "tʂʊŋ",
898 | "chan": "tʂʰan",
899 | "chai": "tʂʰaɪ̯",
900 | "chu": "tʂʰu",
901 | "chuan": "tʂʰu̯an",
902 | "chuai": "tʂʰu̯aɪ̯",
903 | "chui": "tʂʰu̯eɪ̯",
904 | "chua": "tʂʰu̯ɑ",
905 | "chuang": "tʂʰu̯ɑŋ",
906 | "chuo": "tʂʰu̯ɔ",
907 | "chun": "tʂʰu̯ən",
908 | "cha": "tʂʰɑ",
909 | "chang": "tʂʰɑŋ",
910 | "chao": "tʂʰɑʊ̯",
911 | "chen": "tʂʰən",
912 | "cheng": "tʂʰəŋ",
913 | "chou": "tʂʰɤʊ̯",
914 | "che": "tʂʰɯ̯ʌ",
915 | "chi": "tʂʰʅ",
916 | "chong": "tʂʰʊŋ",
917 | "zhuang": "tʂ̯u̯ɑŋ",
918 | "dong": "tʊŋ",
919 | "tan": "tʰan",
920 | "tai": "tʰaɪ̯",
921 | "ti": "tʰi",
922 | "ting": "tʰiŋ",
923 | "tie": "tʰiɛ",
924 | "tian": "tʰiɛn",
925 | "tiao": "tʰi̯ɑʊ̯",
926 | "tu": "tʰu",
927 | "tuan": "tʰu̯an",
928 | "tui": "tʰu̯eɪ̯",
929 | "tuo": "tʰu̯ɔ",
930 | "tun": "tʰu̯ən",
931 | "ta": "tʰɑ",
932 | "tang": "tʰɑŋ",
933 | "tao": "tʰɑʊ̯",
934 | "teng": "tʰəŋ",
935 | "tou": "tʰɤʊ̯",
936 | "te": "tʰɯ̯ʌ",
937 | "tong": "tʰʊŋ",
938 | "wu": "u",
939 | "wan": "u̯an",
940 | "wai": "u̯aɪ̯",
941 | "wei": "u̯eɪ̯",
942 | "wa": "u̯ɑ",
943 | "wang": "u̯ɑŋ",
944 | "wo": "u̯ɔ",
945 | "wen": "u̯ən",
946 | "weng": "u̯əŋ",
947 | "han": "xan",
948 | "hai": "xaɪ̯",
949 | "hei": "xeɪ̯",
950 | "hu": "xu",
951 | "huan": "xu̯an",
952 | "huai": "xu̯aɪ̯",
953 | "hui": "xu̯eɪ̯",
954 | "hua": "xu̯ɑ",
955 | "huang": "xu̯ɑŋ",
956 | "huo": "xu̯ɔ",
957 | "hun": "xu̯ən",
958 | "ha": "xɑ",
959 | "hang": "xɑŋ",
960 | "hao": "xɑʊ̯",
961 | "hen": "xən",
962 | "heng": "xəŋ",
963 | "hou": "xɤʊ̯",
964 | "he": "xɯ̯ʌ",
965 | "hong": "xʊŋ",
966 | "yu": "y",
967 | "yun": "yn",
968 | "yue": "y̯œ",
969 | "yuan": "y̯ɛn",
970 | "a": "ɑ",
971 | "ang": "ɑŋ",
972 | "er": "ɑɻ",
973 | "ao": "ɑʊ̯",
974 | "o": "ɔ",
975 | "xi": "ɕi",
976 | "xin": "ɕin",
977 | "xing": "ɕiŋ",
978 | "xie": "ɕiɛ",
979 | "xian": "ɕiɛn",
980 | "xia": "ɕi̯ɑ",
981 | "xiang": "ɕi̯ɑŋ",
982 | "xiao": "ɕi̯ɑʊ̯",
983 | "xiu": "ɕi̯ɤʊ̯",
984 | "xiong": "ɕi̯ʊŋ",
985 | "xu": "ɕy",
986 | "xun": "ɕyn",
987 | "xue": "ɕy̯œ",
988 | "xuan": "ɕy̯ɛn",
989 | "en": "ən",
990 | "eng": "əŋ",
991 | "ou": "ɤʊ̯",
992 | "e": "ɯ̯ʌ",
993 | "shan": "ʂan",
994 | "shai": "ʂaɪ̯",
995 | "shei": "ʂeɪ̯",
996 | "shu": "ʂu",
997 | "shuan": "ʂu̯an",
998 | "shuai": "ʂu̯aɪ̯",
999 | "shui": "ʂu̯eɪ̯",
1000 | "shua": "ʂu̯ɑ",
1001 | "shuang": "ʂu̯ɑŋ",
1002 | "shuo": "ʂu̯ɔ",
1003 | "shun": "ʂu̯ən",
1004 | "sha": "ʂɑ",
1005 | "shang": "ʂɑŋ",
1006 | "shao": "ʂɑʊ̯",
1007 | "shen": "ʂən",
1008 | "sheng": "ʂəŋ",
1009 | "shou": "ʂɤʊ̯",
1010 | "she": "ʂɯ̯ʌ",
1011 | "shi": "ʂʅ",
1012 | "ran": "ʐan",
1013 | "ru": "ʐu",
1014 | "ruan": "ʐu̯an",
1015 | "rui": "ʐu̯eɪ̯",
1016 | "rua": "ʐu̯ɑ",
1017 | "ruo": "ʐu̯ɔ",
1018 | "run": "ʐu̯ən",
1019 | "rang": "ʐɑŋ",
1020 | "rao": "ʐɑʊ̯",
1021 | "ren": "ʐən",
1022 | "reng": "ʐəŋ",
1023 | "rou": "ʐɤʊ̯",
1024 | "re": "ʐɯ̯ʌ",
1025 | "ri": "ʐʅ",
1026 | "rong": "ʐʊŋ"
1027 | }
1028 | },{}],4:[function(require,module,exports){
1029 | 'use strict';
1030 |
1031 | // @ts-check
1032 |
1033 | var vowels = 'aāáǎăàeēéěĕèiīíǐĭìoōóǒŏòuūúǔŭùüǖǘǚǚü̆ǜvv̄v́v̆v̌v̀';
1034 | var tones = 'ā|á|ǎ|ă|à|ē|é|ě|ĕ|è|ī|í|ǐ|ĭ|ì|ō|ó|ǒ|ŏ|ò|ū|ú|ǔ|ŭ|ù|ǖ|ǘ|ǚ|ǚ|ü̆|ǜ|v̄|v́|v̆|v̌|v̀';
1035 | var initials = 'b|p|m|f|d|t|n|l|g|k|h|j|q|x|zh|ch|sh|r|z|c|s';
1036 | function separate(pinyin) {
1037 | return pinyin.replace(/'/g, ' ') // single quote used for separation
1038 | .replace(new RegExp('(' + tones + ')(' + tones + ')', 'gi'), '$1 $2') // split two consecutive tones
1039 | .replace(new RegExp('([' + vowels + '])([^' + vowels + 'nr])', 'gi'), '$1 $2') // This line does most of the work
1040 | .replace(new RegExp('(\\w)([csz]h)', 'gi'), '$1 $2') // double-consonant initials
1041 | .replace(new RegExp('([' + vowels + ']{2}(ng? )?)([^\\snr])', 'gi'), '$1 $3') // double-vowel finals
1042 | .replace(new RegExp('([' + vowels + ']{2})(n[' + vowels + '])', 'gi'), '$1 $2') // double-vowel followed by n initial
1043 | .replace(new RegExp('(n)([^' + vowels + 'vg])', 'gi'), '$1 $2') // cleans up most n compounds
1044 | .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
1045 | .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
1046 | .replace(new RegExp('((a|\u0101|\xE1|\u01CE|\u0103|\xE0)o)(' + initials + ')', 'gi'), '$1 $3') // fix syllable ending in ao followed by another syllable
1047 | .replace(new RegExp('((o|\u014D|\xF3|\u01D2|\u014F|\xF2)u)(' + initials + ')', 'gi'), '$1 $3') // fix syllable ending in ou followed by another syllable
1048 | .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
1049 | .replace(new RegExp('([' + vowels + 'v])([^' + vowels + '\\w\\s])([' + vowels + 'v])', 'gi'), '$1 $2$3') // assumes correct Pinyin (i.e., no missing apostrophes)
1050 | .replace(new RegExp('([' + vowels + 'v])(n)(g)([' + vowels + 'v])', 'gi'), '$1$2 $3$4') // assumes correct Pinyin, i.e. changan = chan + gan
1051 | .replace(new RegExp('([gr])([^' + vowels + '])', 'gi'), '$1 $2') // fixes -ng and -r finals not followed by vowels
1052 | .replace(new RegExp('([^eēéěĕè\\w\\s])(r)', 'gi'), '$1 $2') // r an initial, except in er
1053 | .replace(new RegExp('([^\\w\\s])([eēéěĕè]r)', 'gi'), '$1 $2') // er
1054 | .replace(/\s{2,}/g, ' ') // remove double-spaces
1055 | ;
1056 | }
1057 |
1058 | module.exports = function separatePinyinInSyllables(pinyin, separateBySpaces) {
1059 | if (!pinyin) {
1060 | return [];
1061 | }
1062 |
1063 | if (separateBySpaces) {
1064 | return pinyin.split(String.fromCharCode(160));
1065 | }
1066 |
1067 | var pinyinSeparated = separate(pinyin).split(' ');
1068 | var newPinyin = [];
1069 |
1070 | pinyinSeparated.forEach(function (p, i) {
1071 | var totalTones = 1;
1072 | var pregMatch = p.match(new RegExp('(' + tones + ')', 'g'));
1073 | if (pregMatch) {
1074 | totalTones = pregMatch.length;
1075 | }
1076 |
1077 | if (p.length > 4 || totalTones > 1) {
1078 | separate(p).split(' ').forEach(function (newP) {
1079 | pregMatch = newP.match(new RegExp('(' + tones + ')', 'g'));
1080 | if (pregMatch) {
1081 | totalTones = pregMatch.length;
1082 | }
1083 |
1084 | if (newP.length > 4 || totalTones > 1) {
1085 | separate(newP).split(' ').forEach(function (newP2) {
1086 | newPinyin.push(newP2.trim());
1087 | });
1088 | } else {
1089 | newPinyin.push(newP.trim());
1090 | }
1091 | });
1092 | } else {
1093 | newPinyin.push(p.trim());
1094 | }
1095 | });
1096 |
1097 | return newPinyin;
1098 | };
1099 | },{}],5:[function(require,module,exports){
1100 | 'use strict';
1101 |
1102 | Object.defineProperty(exports, "__esModule", {
1103 | value: true
1104 | });
1105 |
1106 | var _separatePinyinInSyllables = require('./helpers/separate-pinyin-in-syllables');
1107 |
1108 | var _separatePinyinInSyllables2 = _interopRequireDefault(_separatePinyinInSyllables);
1109 |
1110 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1111 |
1112 | var defaultOptions = {
1113 | byNbsp: false
1114 | };
1115 |
1116 | var pinyinSeparate = function pinyinSeparate(pinyIn) {
1117 | var optionsArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
1118 |
1119 | var options = optionsArg;
1120 | if (options !== defaultOptions) {
1121 | options = Object.assign({}, defaultOptions, options);
1122 | }
1123 |
1124 | return (0, _separatePinyinInSyllables2.default)(pinyIn, options.byNbsp);
1125 | };
1126 |
1127 | exports.default = pinyinSeparate;
1128 |
1129 | // export { pinyinSeparate };
1130 |
1131 | module.exports = exports.default;
1132 | },{"./helpers/separate-pinyin-in-syllables":4}]},{},[1])(1)
1133 | });
1134 |
--------------------------------------------------------------------------------