mirror of
https://gitee.com/onvia/ccc-tnt-psd2ui
synced 2026-04-02 19:33:08 +00:00
增加中文转拼音
This commit is contained in:
21
npm-packages/win32-v2.4.x/pinyin-pro/LICENSE
Normal file
21
npm-packages/win32-v2.4.x/pinyin-pro/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022-present zh-lx
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
194
npm-packages/win32-v2.4.x/pinyin-pro/README.md
Normal file
194
npm-packages/win32-v2.4.x/pinyin-pro/README.md
Normal file
@@ -0,0 +1,194 @@
|
||||
[](https://github.com/zh-lx/pinyin-pro)
|
||||
|
||||
[](https://www.npmjs.com/package/pinyin-pro)
|
||||
[](https://github.com/zh-lx/pinyin-pro)
|
||||
[](https://travis-ci.com/github/zh-lx/pinyin-pro)
|
||||
[](https://npmcharts.com/compare/pinyin-pro?minimal=true)
|
||||
[](https://coveralls.io/github/zh-lx/pinyin-pro?branch=main)
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
[](https://github.com/zh-lx/pinyin-pro)
|
||||
|
||||
### 📖 介绍
|
||||
|
||||
`pinyin-pro` 是一个专业的 js 汉字拼音转换库,功能丰富、准确率高、性能优异。
|
||||
|
||||
[中文文档](https://pinyin-pro.cn) | [English Docs](https://pinyin-pro.cn/en) | [在线运行](https://pinyin-pro.cn/run/run)
|
||||
|
||||
### 🎨 特色功能
|
||||
|
||||
- 支持拼音/声母/韵母/首字母/音调/全部信息
|
||||
- 支持人名姓氏模式
|
||||
- 支持文本和拼音匹配
|
||||
- 支持自定义拼音
|
||||
- 支持获取带拼音汉字的 HTML 字符串
|
||||
- 支持获取汉字的所有拼音
|
||||
- 极致的性能和极高的拼音识别准确率
|
||||
|
||||
### 🔨 安装
|
||||
|
||||
npm 安装
|
||||
|
||||
```html
|
||||
npm install pinyin-pro
|
||||
```
|
||||
|
||||
浏览器引入
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/pinyin-pro"></script>
|
||||
```
|
||||
|
||||
### 💡 使用示例
|
||||
|
||||
全部功能的使用说明文档请查看[在线文档](https://pinyin-pro.cn/use/pinyin)
|
||||
|
||||
- 获取拼音,更多功能请查看[pinyin API](https://pinyin-pro.cn/use/pinyin)
|
||||
|
||||
```js
|
||||
import { pinyin } from 'pinyin-pro';
|
||||
|
||||
// 获取字符串格式拼音
|
||||
pinyin('汉语拼音'); // 'hàn yǔ pīn yīn'
|
||||
|
||||
// 获取数组格式拼音
|
||||
pinyin('汉语拼音', { type: 'array' }); // ["hàn", "yǔ", "pīn", "yīn"]
|
||||
|
||||
// 获取不带音调数组格式拼音
|
||||
pinyin('汉语拼音', { toneType: 'none' }); // "han yu pin yin"
|
||||
|
||||
// 获取不带音调数组格式拼音
|
||||
pinyin('汉语拼音', { toneType: 'none', type: 'array' }); // ["han", "yu", "pin", "yin"]
|
||||
|
||||
// 音调以数组形式显示
|
||||
pinyin('汉语拼音', { toneType: 'num' }); // "han4 yu3 pin1 yin1"
|
||||
|
||||
// 自动识别多音字
|
||||
pinyin('睡着了'); // "shuì zháo le"
|
||||
```
|
||||
|
||||
- 文本和拼音匹配,更多匹配规则请查看[match API](https://pinyin-pro.cn/use/match)
|
||||
|
||||
```js
|
||||
import { match } from 'pinyin-pro';
|
||||
|
||||
// 支持首字母匹配
|
||||
match('中文拼音', 'zwp'); // [0, 1, 2]
|
||||
|
||||
// 支持全拼匹配
|
||||
match('中文拼音', 'zhongwenpin'); // [0, 1, 2]
|
||||
|
||||
// 支持混合匹配
|
||||
match('中文拼音', 'zhongwp'); // [0, 1, 2]
|
||||
```
|
||||
|
||||
- 获取带汉字拼音的 HTML 字符串,更多配置请查看[html API](https://pinyin-pro.cn/use/html)
|
||||
|
||||
```js
|
||||
import { html } from 'pinyin-pro';
|
||||
|
||||
// 带拼音汉字的 HTML 字符串
|
||||
html('汉语拼音');
|
||||
/*
|
||||
<span class="py-result-item">
|
||||
<ruby>
|
||||
<span class="py-chinese-item">汉</span>
|
||||
<rp>(</rp>
|
||||
<rt class="py-pinyin-item">hàn</rt>
|
||||
<rp>)</rp>
|
||||
</ruby>
|
||||
</span>
|
||||
<span class="py-result-item">
|
||||
<ruby>
|
||||
<span class="py-chinese-item">语</span>
|
||||
<rp>(</rp>
|
||||
<rt class="py-pinyin-item">yǔ</rt>
|
||||
<rp>)</rp>
|
||||
</ruby>
|
||||
</span>
|
||||
*/
|
||||
```
|
||||
|
||||
上述结果浏览器中预览效果如下:
|
||||
<span class="py-result-item">
|
||||
<ruby>
|
||||
<span class="py-chinese-item">汉</span>
|
||||
<rp>(</rp>
|
||||
<rt class="py-pinyin-item">hàn</rt>
|
||||
<rp>)</rp>
|
||||
</ruby>
|
||||
</span>
|
||||
<span class="py-result-item">
|
||||
<ruby>
|
||||
<span class="py-chinese-item">语</span>
|
||||
<rp>(</rp>
|
||||
<rt class="py-pinyin-item">yǔ</rt>
|
||||
<rp>)</rp>
|
||||
</ruby>
|
||||
</span>
|
||||
|
||||
### 🏆 竞品对比
|
||||
|
||||
以下是 `pinyin-pro`、`pinyin` 及 `@napi-rs/pinyin` 包对于汉字转换的速度及准确率对比,可以看到 `pinyin-pro` 在各方面都全面领先。
|
||||
|
||||
- 准确率测试数据: [accuracy](https://github.com/zh-lx/pinyin-pro/blob/main/benchmark/accuracy.js)
|
||||
- 性能测试数据:[speed](https://github.com/zh-lx/pinyin-pro/blob/main/benchmark/speed.js)
|
||||
<table>
|
||||
<tr>
|
||||
<th colspan="2">对比项</th>
|
||||
<th>pinyin</th>
|
||||
<th>@napi-rs/pinyin</th>
|
||||
<th>pinyin-pro</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="2" colspan="2">准确率</td>
|
||||
<td>😕 Node 版: 97.844%</td>
|
||||
<td rowspan="2">😕 97.433%</td>
|
||||
<td rowspan="2">🤩 99.744%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>😕 Web 版: 94.507% </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="3">性能</td>
|
||||
<td>5k字转换耗时</td>
|
||||
<td>🐢 749.111ms</td>
|
||||
<td>🚲 200.877ms</td>
|
||||
<td>🚀 5.958ms</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1w字转换耗时</td>
|
||||
<td>🐢 795.904ms</td>
|
||||
<td>🚲 206.5ms</td>
|
||||
<td>🚀 15.260ms</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>100w字转换耗时</td>
|
||||
<td>⛔ 内存溢出转换失败</td>
|
||||
<td>🚀 638.888ms</td>
|
||||
<td>🚀 607.131ms</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="2">兼容性</td>
|
||||
<td>Web 环境</td>
|
||||
<td>✔️ 支持</td>
|
||||
<td>❌ 不支持</td>
|
||||
<td>✔️ 支持</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Node 环境</td>
|
||||
<td>✔️ 支持</td>
|
||||
<td>✔️ 支持</td>
|
||||
<td>✔️ 支持</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
### 📠 反馈
|
||||
|
||||
使用遇到问题或者需要功能支持欢迎提 issue。
|
||||
|
||||
技术交流欢迎加 pinyin-pro 用户群 或者微信:
|
||||
|
||||
<div style="display: flex;">
|
||||
<img src="https://user-images.githubusercontent.com/73059627/226233976-5dbb9daa-6620-4d16-a2b0-359055dcafe1.png" width="200" >
|
||||
<img src="https://user-images.githubusercontent.com/73059627/226233691-848b2a40-f1a9-414e-a80f-3fc6c6209eb1.png" width="200" >
|
||||
</div>
|
||||
1
npm-packages/win32-v2.4.x/pinyin-pro/dist/index.js
vendored
Normal file
1
npm-packages/win32-v2.4.x/pinyin-pro/dist/index.js
vendored
Normal file
File diff suppressed because one or more lines are too long
12631
npm-packages/win32-v2.4.x/pinyin-pro/dist/index.mjs
vendored
Normal file
12631
npm-packages/win32-v2.4.x/pinyin-pro/dist/index.mjs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
82
npm-packages/win32-v2.4.x/pinyin-pro/package.json
Normal file
82
npm-packages/win32-v2.4.x/pinyin-pro/package.json
Normal file
@@ -0,0 +1,82 @@
|
||||
{
|
||||
"name": "pinyin-pro",
|
||||
"version": "3.16.0",
|
||||
"description": "准确率和性能最优异的汉字转拼音库。获取中文拼音、韵母、声母、声调、首字母,支持拼音匹配",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"typings": "./types/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"build": "rollup -c && rollup -c rollup.esm.config.js",
|
||||
"commit": "git-cz",
|
||||
"coverage": "istanbul cover _mocha -- -R spec --timeout 15000 --recursive",
|
||||
"coverage:check": "istanbul check-coverage",
|
||||
"cover": "istanbul cover --report lcov node_modules/mocha/bin/_mocha -- -R spec test/*.js",
|
||||
"cover:local": "istanbul cover --report=html node_modules/mocha/bin/_mocha -- -R spec test/*.js",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/zh-lx/pinyin-pro.git"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"types"
|
||||
],
|
||||
"keywords": [
|
||||
"拼音",
|
||||
"pinyin",
|
||||
"汉字",
|
||||
"中文",
|
||||
"首字母",
|
||||
"韵母",
|
||||
"声母",
|
||||
"音调"
|
||||
],
|
||||
"author": "zh-lx",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/zh-lx/pinyin-pro/issues"
|
||||
},
|
||||
"homepage": "https://pinyin-pro.cn",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./types/index.d.ts",
|
||||
"default": "./dist/index.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./types/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^11.0.0",
|
||||
"@commitlint/config-conventional": "^11.0.0",
|
||||
"@rollup/plugin-commonjs": "^17.1.0",
|
||||
"@rollup/plugin-json": "^4.1.0",
|
||||
"@rollup/plugin-node-resolve": "^11.2.0",
|
||||
"@types/jest": "^26.0.20",
|
||||
"@typescript-eslint/eslint-plugin": "^4.26.0",
|
||||
"@typescript-eslint/parser": "^4.26.0",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"chai": "^4.3.4",
|
||||
"commitizen": "^4.2.2",
|
||||
"coveralls": "^3.1.0",
|
||||
"eslint": "^7.22.0",
|
||||
"istanbul": "^0.4.5",
|
||||
"mocha": "^8.3.2",
|
||||
"rollup": "2.60.0",
|
||||
"rollup-plugin-alias": "^2.2.0",
|
||||
"rollup-plugin-cleanup": "^3.2.1",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"rollup-plugin-typescript2": "^0.34.1",
|
||||
"typescript": "^4.2.3"
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "node_modules/cz-conventional-changelog"
|
||||
}
|
||||
}
|
||||
}
|
||||
33
npm-packages/win32-v2.4.x/pinyin-pro/types/common/ac.d.ts
vendored
Normal file
33
npm-packages/win32-v2.4.x/pinyin-pro/types/common/ac.d.ts
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @description: AC 自动机
|
||||
*/
|
||||
export interface Pattern {
|
||||
zh: string;
|
||||
pinyin: string;
|
||||
priority: number;
|
||||
length: number;
|
||||
}
|
||||
interface MatchPattern extends Pattern {
|
||||
index: number;
|
||||
}
|
||||
declare class TrieNode {
|
||||
children: Map<string, TrieNode>;
|
||||
fail: TrieNode | null;
|
||||
isEnd: boolean;
|
||||
pattern: Pattern | null;
|
||||
constructor();
|
||||
}
|
||||
export declare class AC {
|
||||
root: TrieNode;
|
||||
constructor();
|
||||
buildTrie(patterns: Pattern[]): void;
|
||||
rebuildTrie(patterns: Pattern[]): void;
|
||||
buildFailPointer(): void;
|
||||
search(text: string): MatchPattern[];
|
||||
filter(patterns: MatchPattern[]): MatchPattern[];
|
||||
}
|
||||
export declare const PatternsNormal: Pattern[];
|
||||
export declare const PatternsSurname: Pattern[];
|
||||
export declare const ACNormal: AC;
|
||||
export declare const ACSurname: AC;
|
||||
export {};
|
||||
2
npm-packages/win32-v2.4.x/pinyin-pro/types/common/constant.d.ts
vendored
Normal file
2
npm-packages/win32-v2.4.x/pinyin-pro/types/common/constant.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export declare const DoubleUnicodePrefixReg: RegExp;
|
||||
export declare const DoubleUnicodeSuffixReg: RegExp;
|
||||
9
npm-packages/win32-v2.4.x/pinyin-pro/types/common/type.d.ts
vendored
Normal file
9
npm-packages/win32-v2.4.x/pinyin-pro/types/common/type.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export interface SingleWordResult {
|
||||
origin: string;
|
||||
originPinyin: string;
|
||||
result: string;
|
||||
isZh: boolean;
|
||||
delete?: boolean;
|
||||
}
|
||||
export declare type ToneType = 'symbol' | 'num' | 'none';
|
||||
export declare type PinyinMode = 'normal' | 'surname';
|
||||
3
npm-packages/win32-v2.4.x/pinyin-pro/types/common/utils.d.ts
vendored
Normal file
3
npm-packages/win32-v2.4.x/pinyin-pro/types/common/utils.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare function getStringLength(string: string): number;
|
||||
export declare function getSplittedWord(string: string): string[];
|
||||
export declare function isZhChar(char: string): boolean;
|
||||
11
npm-packages/win32-v2.4.x/pinyin-pro/types/core/custom/index.d.ts
vendored
Normal file
11
npm-packages/win32-v2.4.x/pinyin-pro/types/core/custom/index.d.ts
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @description: 用户自定义拼音
|
||||
* @param {{ [key: string]: string }} config 用户自定义的拼音映射(支持汉字、词语、句子的映射),若匹配到该映射,优先将汉字转换为该映射
|
||||
*/
|
||||
export declare function customPinyin(config?: {
|
||||
[key: string]: string;
|
||||
}): void;
|
||||
export declare const getCustomDict: () => {
|
||||
[key: string]: string;
|
||||
};
|
||||
export declare function hasCustomConfig(): boolean;
|
||||
34
npm-packages/win32-v2.4.x/pinyin-pro/types/core/html/index.d.ts
vendored
Normal file
34
npm-packages/win32-v2.4.x/pinyin-pro/types/core/html/index.d.ts
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
interface HtmlOptions {
|
||||
/**
|
||||
* @description html 结果中每个字+拼音外层 span 标签的类名。默认为 py-result-item
|
||||
*/
|
||||
resultClass?: string;
|
||||
/**
|
||||
* @description html 结果中拼音 rt 标签的类名。默认为 py-pinyin-item
|
||||
*/
|
||||
pinyinClass?: string;
|
||||
/**
|
||||
* @description html 结果中汉字 span 标签的类名。默认为 py-chinese-item
|
||||
*/
|
||||
chineseClass?: string;
|
||||
/**
|
||||
* @description 是否用 span 标签包装非汉字字符的结果。默认为 false。建议输入的文本为纯文本时可以设置为 true;输入文本本身为 html 富文本字符串设置为 false
|
||||
*/
|
||||
wrapNonChinese?: boolean;
|
||||
/**
|
||||
* @description html 非汉字字符外层 span 标签的类名,仅当 wrapNonChinese 为 true 时生效。默认为 py-non-chinese-item
|
||||
*/
|
||||
nonChineseClass?: string;
|
||||
/**
|
||||
* @description 拼音上是否标注音调
|
||||
*/
|
||||
toneType?: 'symbol' | 'num' | 'none';
|
||||
}
|
||||
/**
|
||||
* @description: 获取带拼音汉字的 html 字符串
|
||||
* @param {string} text 要转换的字符串
|
||||
* @param {HtmlOptions=} options html 中标签类名相关配置
|
||||
* @return {string} 带汉字的拼音字符串
|
||||
*/
|
||||
export declare const html: (text: string, options?: HtmlOptions | undefined) => string;
|
||||
export {};
|
||||
27
npm-packages/win32-v2.4.x/pinyin-pro/types/core/match/index.d.ts
vendored
Normal file
27
npm-packages/win32-v2.4.x/pinyin-pro/types/core/match/index.d.ts
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
interface MatchOptions {
|
||||
/**
|
||||
* @description 每个汉字和拼音需要遵从的匹配精度
|
||||
*/
|
||||
precision?: 'first' | 'start' | 'every' | 'any';
|
||||
/**
|
||||
* @description 匹配的汉字下标是否为连续的才算匹配成功
|
||||
*/
|
||||
continuous?: boolean;
|
||||
/**
|
||||
* @description 匹配时对于空格的处理
|
||||
*/
|
||||
space?: 'ignore' | 'preserve';
|
||||
/**
|
||||
* @description 最后一个字的匹配精度
|
||||
*/
|
||||
lastPrecision?: 'first' | 'start' | 'every' | 'any';
|
||||
}
|
||||
/**
|
||||
* @description: 检测汉语字符串和拼音是否匹配
|
||||
* @param {string} text 汉语字符串
|
||||
* @param {string} pinyin 拼音,支持各种缩写形式
|
||||
* @param {MatchOptions=} options 配置项
|
||||
* @return {Array | null} 若匹配成功,返回 text 中匹配成功的下标数组;若匹配失败,返回 null
|
||||
*/
|
||||
export declare const match: (text: string, pinyin: string, options?: MatchOptions | undefined) => any;
|
||||
export {};
|
||||
60
npm-packages/win32-v2.4.x/pinyin-pro/types/core/pinyin/handle.d.ts
vendored
Normal file
60
npm-packages/win32-v2.4.x/pinyin-pro/types/core/pinyin/handle.d.ts
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
import type { SingleWordResult, PinyinMode } from '../../common/type';
|
||||
export declare const getPinyin: (word: string, list: SingleWordResult[], mode: 'normal' | 'surname') => SingleWordResult[];
|
||||
/**
|
||||
* @description: 将带音调符号拼音转换为不带音调拼音
|
||||
* @param {string} pinyin
|
||||
* @return {string}
|
||||
*/
|
||||
declare type GetPinyinWithoutTone = (pinyin: string) => string;
|
||||
declare const getPinyinWithoutTone: GetPinyinWithoutTone;
|
||||
/**
|
||||
* @description: 获取单字符的多音拼音
|
||||
* @param {string} word
|
||||
* @return {WordResult[]}
|
||||
*/
|
||||
declare type GetMultiplePinyin = (word: string, mode?: PinyinMode) => SingleWordResult[];
|
||||
declare const getMultiplePinyin: GetMultiplePinyin;
|
||||
/**
|
||||
* @description: 获取拼音的声母和韵母
|
||||
* @param {string} pinyin
|
||||
* @return {*}
|
||||
*/
|
||||
declare type GetInitialAndFinal = (pinyin: string) => {
|
||||
final: string;
|
||||
initial: string;
|
||||
};
|
||||
declare const getInitialAndFinal: GetInitialAndFinal;
|
||||
/**
|
||||
* @description: 获取韵母的韵头、韵腹和韵尾
|
||||
* @param {string} pinyin
|
||||
* @return {*}
|
||||
*/
|
||||
declare type GetFinalParts = (pinyin: string) => {
|
||||
head: string;
|
||||
body: string;
|
||||
tail: string;
|
||||
};
|
||||
declare const getFinalParts: GetFinalParts;
|
||||
/**
|
||||
* @description: 将带音调符号拼音转换为带音调数字
|
||||
* @param {string} pinyin
|
||||
* @return {string}
|
||||
*/
|
||||
declare type GetNumOfTone = (pinyin: string) => string;
|
||||
declare const getNumOfTone: GetNumOfTone;
|
||||
/**
|
||||
* @description: 将带音调符号拼音转换为带音调数字拼音
|
||||
* @param {string} pinyin
|
||||
* @param {string} originPinyin
|
||||
* @return {string}
|
||||
*/
|
||||
declare type GetPinyinWithNum = (pinyin: string, originPinyin: string) => string;
|
||||
declare const getPinyinWithNum: GetPinyinWithNum;
|
||||
/**
|
||||
* @description: 获取拼音的首字母
|
||||
* @param {string} pinyin
|
||||
* @return {string}
|
||||
*/
|
||||
declare type GetFirstLetter = (pinyin: string) => string;
|
||||
declare const getFirstLetter: GetFirstLetter;
|
||||
export { getPinyinWithoutTone, getInitialAndFinal, getMultiplePinyin, getNumOfTone, getPinyinWithNum, getFirstLetter, getFinalParts, };
|
||||
130
npm-packages/win32-v2.4.x/pinyin-pro/types/core/pinyin/index.d.ts
vendored
Normal file
130
npm-packages/win32-v2.4.x/pinyin-pro/types/core/pinyin/index.d.ts
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
interface BasicOptions {
|
||||
/**
|
||||
* @description 返回的拼音音调类型
|
||||
* @value symbol:在字母上加音调 (默认值)
|
||||
* @value num:以数字格式展示音调,并跟在拼音后面
|
||||
* @value none:不展示音调
|
||||
*/
|
||||
toneType?: 'symbol' | 'num' | 'none';
|
||||
/**
|
||||
* @description 返回的拼音格式类型
|
||||
* @value pinyin:返回完整拼音 (默认值)
|
||||
* @value initial:返回声母
|
||||
* @value final:返回韵母
|
||||
* @value num:返回音调对应的数字
|
||||
* @value first:返回首字母
|
||||
* @value finalHead:返回韵头(介音)
|
||||
* @value finalBody:返回韵腹
|
||||
* @value finalTail:返回韵尾
|
||||
*/
|
||||
pattern?: 'pinyin' | 'initial' | 'final' | 'num' | 'first' | 'finalHead' | 'finalBody' | 'finalTail';
|
||||
/**
|
||||
* @description 是否返回单个汉字的所有多音,仅针对输入的 word 为单个汉字生效
|
||||
* @value false:返回最常用的一个拼音 (默认值)
|
||||
* @value true:返回所有读音
|
||||
*/
|
||||
multiple?: boolean;
|
||||
/**
|
||||
* @description 优先的拼音匹配模式
|
||||
* @value normal:正常匹配模式 (默认值)
|
||||
* @value surname:姓氏模式,遇到姓氏表中的汉字时,优先匹配姓氏读音
|
||||
*/
|
||||
mode?: 'normal' | 'surname';
|
||||
/**
|
||||
* @description 是否移除非汉字字符(推荐使用 removeNonZh: removed 代替)
|
||||
* @value false:返回结果保留非汉字字符 (默认值)
|
||||
* @value true:返回结果移除非汉字字符
|
||||
*/
|
||||
removeNonZh?: boolean;
|
||||
/**
|
||||
* @description 非汉字字符的间距格式
|
||||
* @value spaced:连续非汉字字符之间用空格隔开 (默认值)
|
||||
* @value consecutive:连续非汉字字符无间距
|
||||
* @value removed:返回结果移除非汉字字符
|
||||
*/
|
||||
nonZh?: 'spaced' | 'consecutive' | 'removed';
|
||||
/**
|
||||
* @description 对于 ü 的返回是否转换成 v(仅在 toneType: none 启用时生效)
|
||||
* @value false:返回值中保留 ü (默认值)
|
||||
* @value true:返回值中 ü 转换成 v
|
||||
*/
|
||||
v?: boolean;
|
||||
}
|
||||
interface AllData {
|
||||
origin: string;
|
||||
pinyin: string;
|
||||
initial: string;
|
||||
final: string;
|
||||
num: number;
|
||||
first: string;
|
||||
finalHead: string;
|
||||
finalBody: string;
|
||||
finalTail: string;
|
||||
isZh: boolean;
|
||||
}
|
||||
interface OptionsReturnString extends BasicOptions {
|
||||
/**
|
||||
* @description 返回结果的格式
|
||||
* @value string:以字符串格式返回,拼音之间用空格隔开 (默认值)
|
||||
* @value array:以数组格式返回
|
||||
* @value array: 返回全部信息数组
|
||||
*/
|
||||
type?: 'string';
|
||||
/**
|
||||
* @description 拼音之间的分隔符,默认为空格,仅在 type 为 'string' 时生效
|
||||
*/
|
||||
separator?: string;
|
||||
}
|
||||
interface OptionsReturnArray extends BasicOptions {
|
||||
/**
|
||||
* @description 返回结果的格式
|
||||
* @value string:以字符串格式返回,拼音之间用空格隔开 (默认值)
|
||||
* @value array:以数组格式返回
|
||||
* @value array: 返回全部信息数组
|
||||
*/
|
||||
type: 'array';
|
||||
}
|
||||
interface OptionsReturnAll extends BasicOptions {
|
||||
/**
|
||||
* @description 返回结果的格式
|
||||
* @value string:以字符串格式返回,拼音之间用空格隔开 (默认值)
|
||||
* @value array:以数组格式返回
|
||||
* @value array: 返回全部信息数组
|
||||
*/
|
||||
type: 'all';
|
||||
}
|
||||
export interface CompleteOptions extends BasicOptions {
|
||||
/**
|
||||
* @description 返回结果的格式
|
||||
* @value string:以字符串格式返回,拼音之间用空格隔开 (默认值)
|
||||
* @value array:以数组格式返回
|
||||
* @value array: 返回全部信息数组
|
||||
*/
|
||||
type?: 'string' | 'array' | 'all';
|
||||
/**
|
||||
* @description 拼音之间的分隔符,默认为空格,仅在 type 为 'string' 时生效
|
||||
*/
|
||||
separator?: string;
|
||||
}
|
||||
/**
|
||||
* @description: 获取汉语字符串的拼音
|
||||
* @param {string} word 要转换的汉语字符串
|
||||
* @param {OptionsReturnString=} options 配置项
|
||||
* @return {string | string[] | AllData[]} options.type 为 string 时,返回字符串,中间用空格隔开;为 array 时,返回拼音字符串数组;为 all 时返回全部信息的数组
|
||||
*/
|
||||
declare function pinyin(word: string, options?: OptionsReturnString): string;
|
||||
/**
|
||||
* @description: 获取汉语字符串的拼音
|
||||
* @param {string} word 要转换的汉语字符串
|
||||
* @param {OptionsReturnArray=} options 配置项
|
||||
* @return {string | string[] | AllData[]} options.type 为 string 时,返回字符串,中间用空格隔开;为 array 时,返回拼音字符串数组;为 all 时返回全部信息的数组
|
||||
*/
|
||||
declare function pinyin(word: string, options?: OptionsReturnArray): string[];
|
||||
/**
|
||||
* @description: 获取汉语字符串的拼音
|
||||
* @param {string} word 要转换的汉语字符串
|
||||
* @param {OptionsReturnAll=} options 配置项
|
||||
* @return {string | string[] | AllData[]} options.type 为 string 时,返回字符串,中间用空格隔开;为 array 时,返回拼音字符串数组;为 all 时返回全部信息的数组
|
||||
*/
|
||||
declare function pinyin(word: string, options?: OptionsReturnAll): AllData[];
|
||||
export { pinyin };
|
||||
21
npm-packages/win32-v2.4.x/pinyin-pro/types/core/pinyin/middlewares.d.ts
vendored
Normal file
21
npm-packages/win32-v2.4.x/pinyin-pro/types/core/pinyin/middlewares.d.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import type { SingleWordResult } from '../../common/type';
|
||||
import { CompleteOptions } from './index';
|
||||
export declare const validateType: (word: unknown) => boolean;
|
||||
export declare const middleWareNonZh: (list: SingleWordResult[], options: CompleteOptions) => SingleWordResult[];
|
||||
export declare const middlewareMultiple: (word: string, options: CompleteOptions) => SingleWordResult[] | false;
|
||||
export declare const middlewarePattern: (list: SingleWordResult[], options: CompleteOptions) => void;
|
||||
export declare const middlewareToneType: (list: SingleWordResult[], options: CompleteOptions) => void;
|
||||
export declare const middlewareV: (list: SingleWordResult[], options: CompleteOptions) => void;
|
||||
export declare const middlewareType: (list: SingleWordResult[], options: CompleteOptions, word: string) => string | string[] | {
|
||||
origin: string;
|
||||
pinyin: string;
|
||||
initial: string;
|
||||
final: string;
|
||||
first: string;
|
||||
finalHead: string;
|
||||
finalBody: string;
|
||||
finalTail: string;
|
||||
num: number;
|
||||
isZh: boolean;
|
||||
}[];
|
||||
export declare const middlewareDoubleUnicode: (list: SingleWordResult[]) => SingleWordResult[];
|
||||
117
npm-packages/win32-v2.4.x/pinyin-pro/types/core/polyphonic/index.d.ts
vendored
Normal file
117
npm-packages/win32-v2.4.x/pinyin-pro/types/core/polyphonic/index.d.ts
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
import type { SingleWordResult } from '../../common/type';
|
||||
interface BasicOptions {
|
||||
/**
|
||||
* @description 返回的拼音音调类型
|
||||
* @value symbol:在字母上加音调 (默认值)
|
||||
* @value num:以数字格式展示音调,并跟在拼音后面
|
||||
* @value none:不展示音调
|
||||
*/
|
||||
toneType?: 'symbol' | 'num' | 'none';
|
||||
/**
|
||||
* @description 返回的拼音格式类型
|
||||
* @value pinyin:返回完整拼音 (默认值)
|
||||
* @value initial:返回声母
|
||||
* @value final:返回韵母
|
||||
* @value num:返回音调对应的数字
|
||||
* @value first:返回首字母
|
||||
* @value finalHead:返回韵头(介音)
|
||||
* @value finalBody:返回韵腹
|
||||
* @value finalTail:返回韵尾
|
||||
*/
|
||||
pattern?: 'pinyin' | 'initial' | 'final' | 'num' | 'first' | 'finalHead' | 'finalBody' | 'finalTail';
|
||||
/**
|
||||
* @description 对于 ü 的返回是否转换成 v(仅在 toneType: none 启用时生效)
|
||||
* @value false:返回值中保留 ü (默认值)
|
||||
* @value true:返回值中 ü 转换成 v
|
||||
*/
|
||||
v?: boolean;
|
||||
/**
|
||||
* @description 非汉字字符的间距格式
|
||||
* @value spaced:连续非汉字字符之间用空格隔开 (默认值)
|
||||
* @value consecutive:连续非汉字字符无间距
|
||||
* @value removed:返回结果移除非汉字字符
|
||||
*/
|
||||
nonZh?: 'spaced' | 'consecutive' | 'removed';
|
||||
}
|
||||
interface AllData {
|
||||
origin: string;
|
||||
pinyin: string;
|
||||
initial: string;
|
||||
final: string;
|
||||
num: number;
|
||||
first: string;
|
||||
finalHead: string;
|
||||
finalBody: string;
|
||||
finalTail: string;
|
||||
isZh: boolean;
|
||||
}
|
||||
interface OptionsReturnString extends BasicOptions {
|
||||
/**
|
||||
* @description 返回结果的格式
|
||||
* @value string:以字符串格式返回,拼音之间用空格隔开 (默认值)
|
||||
* @value array:以数组格式返回
|
||||
* @value array: 返回全部信息数组
|
||||
*/
|
||||
type?: 'string';
|
||||
}
|
||||
interface OptionsReturnArray extends BasicOptions {
|
||||
/**
|
||||
* @description 返回结果的格式
|
||||
* @value string:以字符串格式返回,拼音之间用空格隔开 (默认值)
|
||||
* @value array:以数组格式返回
|
||||
* @value array: 返回全部信息数组
|
||||
*/
|
||||
type: 'array';
|
||||
}
|
||||
interface OptionsReturnAll extends BasicOptions {
|
||||
/**
|
||||
* @description 返回结果的格式
|
||||
* @value string:以字符串格式返回,拼音之间用空格隔开 (默认值)
|
||||
* @value array:以数组格式返回
|
||||
* @value array: 返回全部信息数组
|
||||
*/
|
||||
type: 'all';
|
||||
}
|
||||
export interface CompleteOptions extends BasicOptions {
|
||||
/**
|
||||
* @description 返回结果的格式
|
||||
* @value string:以字符串格式返回,拼音之间用空格隔开 (默认值)
|
||||
* @value array:以数组格式返回
|
||||
* @value array: 返回全部信息数组
|
||||
*/
|
||||
type?: 'string' | 'array' | 'all';
|
||||
}
|
||||
/**
|
||||
* @description: 获取每个汉字的所有读音
|
||||
* @param {string} text 要转换的汉语字符串
|
||||
* @param {OptionsReturnString=} options 配置项
|
||||
* @return {string[] | string[][] | AllData[][]} options.type 为 string 时,返回字符串数组,中间用空格隔开;为 array 时,返回二维拼音字符串数组;为 all 时返回二维全部信息的数组
|
||||
*/
|
||||
declare function polyphonic(text: string, options?: OptionsReturnString): string[];
|
||||
/**
|
||||
* @description: 获取每个汉字的所有读音
|
||||
* @param {string} text 要转换的汉语字符串
|
||||
* @param {OptionsReturnArray=} options 配置项
|
||||
* @return {string[] | string[][] | AllData[][]} options.type 为 string 时,返回字符串数组,中间用空格隔开;为 array 时,返回二维拼音字符串数组;为 all 时返回二维全部信息的数组
|
||||
*/
|
||||
declare function polyphonic(text: string, options?: OptionsReturnArray): string[][];
|
||||
/**
|
||||
* @description: 获取每个汉字的所有读音
|
||||
* @param {string} text 要转换的汉语字符串
|
||||
* @param {OptionsReturnAll=} options 配置项
|
||||
* @return {string[] | string[][] | AllData[][]} options.type 为 string 时,返回字符串数组,中间用空格隔开;为 array 时,返回二维拼音字符串数组;为 all 时返回二维全部信息的数组
|
||||
*/
|
||||
declare function polyphonic(text: string, options?: OptionsReturnAll): AllData[][];
|
||||
export declare const handleType: (list: SingleWordResult[], options: CompleteOptions) => string | string[] | {
|
||||
origin: string;
|
||||
pinyin: string;
|
||||
initial: string;
|
||||
final: string;
|
||||
first: string;
|
||||
finalHead: string;
|
||||
finalBody: string;
|
||||
finalTail: string;
|
||||
num: number;
|
||||
isZh: boolean;
|
||||
}[];
|
||||
export { polyphonic };
|
||||
3
npm-packages/win32-v2.4.x/pinyin-pro/types/data/dict1-pinyin.d.ts
vendored
Normal file
3
npm-packages/win32-v2.4.x/pinyin-pro/types/data/dict1-pinyin.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare const DICT1: {
|
||||
[prop: string]: string;
|
||||
};
|
||||
2
npm-packages/win32-v2.4.x/pinyin-pro/types/data/dict1.d.ts
vendored
Normal file
2
npm-packages/win32-v2.4.x/pinyin-pro/types/data/dict1.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare const DICT1: string[];
|
||||
export default DICT1;
|
||||
6
npm-packages/win32-v2.4.x/pinyin-pro/types/data/dict2.d.ts
vendored
Normal file
6
npm-packages/win32-v2.4.x/pinyin-pro/types/data/dict2.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { Pattern } from '@/common/ac';
|
||||
declare const DICT2: {
|
||||
[prop: string]: string;
|
||||
};
|
||||
export default DICT2;
|
||||
export declare const Pattern2: Pattern[];
|
||||
6
npm-packages/win32-v2.4.x/pinyin-pro/types/data/dict3.d.ts
vendored
Normal file
6
npm-packages/win32-v2.4.x/pinyin-pro/types/data/dict3.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { Pattern } from '@/common/ac';
|
||||
declare const DICT3: {
|
||||
[prop: string]: string;
|
||||
};
|
||||
export default DICT3;
|
||||
export declare const Pattern3: Pattern[];
|
||||
6
npm-packages/win32-v2.4.x/pinyin-pro/types/data/dict4.d.ts
vendored
Normal file
6
npm-packages/win32-v2.4.x/pinyin-pro/types/data/dict4.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { Pattern } from '@/common/ac';
|
||||
declare const DICT4: {
|
||||
[prop: string]: string;
|
||||
};
|
||||
export default DICT4;
|
||||
export declare const Pattern4: Pattern[];
|
||||
6
npm-packages/win32-v2.4.x/pinyin-pro/types/data/dict5.d.ts
vendored
Normal file
6
npm-packages/win32-v2.4.x/pinyin-pro/types/data/dict5.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { Pattern } from '@/common/ac';
|
||||
declare const DICT5: {
|
||||
[prop: string]: string;
|
||||
};
|
||||
export default DICT5;
|
||||
export declare const Pattern5: Pattern[];
|
||||
26
npm-packages/win32-v2.4.x/pinyin-pro/types/data/special.d.ts
vendored
Normal file
26
npm-packages/win32-v2.4.x/pinyin-pro/types/data/special.d.ts
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
export declare const InitialList: string[];
|
||||
export declare const SpecialInitialList: string[];
|
||||
export declare const SpecialFinalList: string[];
|
||||
export declare const SpecialFinalMap: {
|
||||
uān: string;
|
||||
uán: string;
|
||||
uǎn: string;
|
||||
uàn: string;
|
||||
uan: string;
|
||||
uē: string;
|
||||
ué: string;
|
||||
uě: string;
|
||||
uè: string;
|
||||
ue: string;
|
||||
ūn: string;
|
||||
ún: string;
|
||||
ǔn: string;
|
||||
ùn: string;
|
||||
un: string;
|
||||
ū: string;
|
||||
ú: string;
|
||||
ǔ: string;
|
||||
ù: string;
|
||||
u: string;
|
||||
};
|
||||
export declare const doubleFinalList: string[];
|
||||
6
npm-packages/win32-v2.4.x/pinyin-pro/types/data/surname.d.ts
vendored
Normal file
6
npm-packages/win32-v2.4.x/pinyin-pro/types/data/surname.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { Pattern } from '@/common/ac';
|
||||
declare const Surnames: {
|
||||
[key: string]: string;
|
||||
};
|
||||
export default Surnames;
|
||||
export declare const PatternSurname: Pattern[];
|
||||
5
npm-packages/win32-v2.4.x/pinyin-pro/types/index.d.ts
vendored
Normal file
5
npm-packages/win32-v2.4.x/pinyin-pro/types/index.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export { pinyin } from './core/pinyin';
|
||||
export { customPinyin } from './core/custom';
|
||||
export { match } from './core/match';
|
||||
export { html } from './core/html';
|
||||
export { polyphonic } from './core/polyphonic';
|
||||
Reference in New Issue
Block a user