Sync all projects
This commit is contained in:
+85678
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+85670
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+53
@@ -0,0 +1,53 @@
|
||||
import { ENUM_PINYIN_MODE, ENUM_PINYIN_STYLE } from "./constant";
|
||||
import type { IPinyinAllOptions, IPinyinOptions, IPinyinSegment, IPinyin } from "./declare";
|
||||
export default class PinyinBase {
|
||||
STYLE_TONE: ENUM_PINYIN_STYLE;
|
||||
STYLE_TONE2: ENUM_PINYIN_STYLE;
|
||||
STYLE_TO3NE: ENUM_PINYIN_STYLE;
|
||||
STYLE_NORMAL: ENUM_PINYIN_STYLE;
|
||||
STYLE_INITIALS: ENUM_PINYIN_STYLE;
|
||||
STYLE_FIRST_LETTER: ENUM_PINYIN_STYLE;
|
||||
STYLE_PASSPORT: ENUM_PINYIN_STYLE;
|
||||
MODE_NORMAL: ENUM_PINYIN_MODE;
|
||||
MODE_SURNAME: ENUM_PINYIN_MODE;
|
||||
/**
|
||||
* 拼音转换入口。
|
||||
*/
|
||||
pinyin(hans: string, options?: IPinyinOptions): string[][];
|
||||
/**
|
||||
* 不使用分词算法的拼音转换。
|
||||
*/
|
||||
normal_pinyin(hans: string, options: IPinyinAllOptions): string[][];
|
||||
/**
|
||||
* 单字拼音转换。
|
||||
* @param {String} han, 单个汉字
|
||||
* @return {Array} 返回拼音列表,多音字会有多个拼音项。
|
||||
*/
|
||||
single_pinyin(han: string, options: IPinyinAllOptions): string[];
|
||||
segment(hans: string, segmentType?: IPinyinSegment): string[];
|
||||
/**
|
||||
* 将文本分词,并转换成拼音。
|
||||
*/
|
||||
segment_pinyin(hans: string, options: IPinyinAllOptions): string[][];
|
||||
/**
|
||||
* 词语注音
|
||||
* @param {String} phrases, 指定的词组。
|
||||
* @param {Object} options, 选项。
|
||||
* @return {Array}
|
||||
*/
|
||||
phrases_pinyin(phrases: string, options: IPinyinAllOptions): string[][];
|
||||
groupPhrases(phrases: string[][]): string[];
|
||||
surname_pinyin(hans: string, options: IPinyinAllOptions): string[][];
|
||||
compound_surname(hans: string, options: IPinyinAllOptions): string[][];
|
||||
single_surname(hans: string, options: IPinyinAllOptions): string[][];
|
||||
/**
|
||||
* 比较两个汉字转成拼音后的排序顺序,可以用作默认的拼音排序算法。
|
||||
*
|
||||
* @param {String} hanA 汉字字符串 A。
|
||||
* @return {String} hanB 汉字字符串 B。
|
||||
* @return {Number} 返回 -1,0,或 1。
|
||||
*/
|
||||
compare(hanA: string, hanB: string): number;
|
||||
compact(pys: string[][]): string[][];
|
||||
}
|
||||
export declare function getPinyinInstance(py: PinyinBase): IPinyin;
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import type { IPinyinAllOptions } from "./declare";
|
||||
export declare enum ENUM_PINYIN_STYLE {
|
||||
NORMAL = 0,
|
||||
TONE = 1,
|
||||
TONE2 = 2,
|
||||
TO3NE = 5,
|
||||
INITIALS = 3,
|
||||
FIRST_LETTER = 4,
|
||||
PASSPORT = 6
|
||||
}
|
||||
export declare enum ENUM_PINYIN_MODE {
|
||||
NORMAL = 0,
|
||||
SURNAME = 1
|
||||
}
|
||||
export declare const DEFAULT_OPTIONS: IPinyinAllOptions;
|
||||
export declare const PHONETIC_SYMBOL: Record<string, string>;
|
||||
export declare const INITIALS: string[];
|
||||
export declare const FINALS: string[];
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
declare const _default: Record<string, string[][]>;
|
||||
export default _default;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
declare const dict: Record<number, string>;
|
||||
export default dict;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
declare const phrases_dict: Record<string, string[][]>;
|
||||
export default phrases_dict;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
declare const _default: Record<string, string[][]>;
|
||||
export default _default;
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
import { ENUM_PINYIN_STYLE, ENUM_PINYIN_MODE } from "./constant";
|
||||
export interface IPinyin {
|
||||
(han: string, options?: IPinyinOptions): string[][];
|
||||
compare: (a: string, b: string) => number;
|
||||
compact: (arr: string[][]) => string[][];
|
||||
STYLE_TONE: ENUM_PINYIN_STYLE;
|
||||
STYLE_TONE2: ENUM_PINYIN_STYLE;
|
||||
STYLE_TO3NE: ENUM_PINYIN_STYLE;
|
||||
STYLE_NORMAL: ENUM_PINYIN_STYLE;
|
||||
STYLE_INITIALS: ENUM_PINYIN_STYLE;
|
||||
STYLE_FIRST_LETTER: ENUM_PINYIN_STYLE;
|
||||
STYLE_PASSPORT: ENUM_PINYIN_STYLE;
|
||||
MODE_NORMAL: ENUM_PINYIN_MODE;
|
||||
MODE_SURNAME: ENUM_PINYIN_MODE;
|
||||
}
|
||||
export type IPinyinStyle = ENUM_PINYIN_STYLE | "normal" | "tone" | "tone2" | "to3ne" | "initials" | "first_letter" | "passport" | // 推荐使用小写,和输出的拼音一致
|
||||
"NORMAL" | "TONE" | "TONE2" | "TO3NE" | "INITIALS" | "FIRST_LETTER" | "PASSPORT" | // 方便老版本迁移
|
||||
0 | 1 | 2 | 5 | 3 | 4;
|
||||
export type IPinyinMode = ENUM_PINYIN_MODE | "normal" | "surname" | "NORMAL" | "SURNAME";
|
||||
export type IPinyinSegment = "nodejieba" | "segmentit" | "@node-rs/jieba" | "Intl.Segmenter";
|
||||
export interface IPinyinAllOptions {
|
||||
style: ENUM_PINYIN_STYLE;
|
||||
mode: ENUM_PINYIN_MODE;
|
||||
segment?: IPinyinSegment;
|
||||
heteronym: boolean;
|
||||
group: boolean;
|
||||
compact: boolean;
|
||||
}
|
||||
export interface IPinyinOptions {
|
||||
style?: IPinyinStyle;
|
||||
mode?: IPinyinMode;
|
||||
segment?: IPinyinSegment | boolean;
|
||||
heteronym?: boolean;
|
||||
group?: boolean;
|
||||
compact?: boolean;
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import { ENUM_PINYIN_STYLE } from "./constant";
|
||||
/**
|
||||
* 格式化拼音风格。
|
||||
*
|
||||
* @param {string} pinyin TONE 风格的拼音。
|
||||
* @param {ENUM_PINYIN_STYLE} style 目标转换的拼音风格。
|
||||
* @return {string} 转换后的拼音。
|
||||
*/
|
||||
export declare function toFixed(pinyin: string, style: ENUM_PINYIN_STYLE): string;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
declare const phonetic_symbol: Record<string, string>;
|
||||
export default phonetic_symbol;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import PinyinBase from "./PinyinBase";
|
||||
export declare class Pinyin extends PinyinBase {
|
||||
}
|
||||
export declare const pinyin: import("./declare").IPinyin;
|
||||
export default pinyin;
|
||||
export declare const compare: (a: string, b: string) => number;
|
||||
export { compact } from "./util";
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import PinyinBase from "./PinyinBase";
|
||||
import type { IPinyinSegment } from "./declare";
|
||||
export declare class Pinyin extends PinyinBase {
|
||||
segment(hans: string, segmentType?: IPinyinSegment): string[];
|
||||
}
|
||||
export declare const pinyin: import("./declare").IPinyin;
|
||||
export default pinyin;
|
||||
export declare const compare: (a: string, b: string) => number;
|
||||
export { compact } from "./util";
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import type { IPinyinSegment } from "./declare";
|
||||
/**
|
||||
* TODO: 分词并带词性信息,需要调整 segment_pinyin 方法。
|
||||
* 分词并标注词性。
|
||||
*/
|
||||
export declare function segment(hans: string, segment?: IPinyinSegment): string[];
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import type { IPinyinSegment } from "./declare";
|
||||
/**
|
||||
* TODO: 分词并带词性信息,需要调整 segment_pinyin 方法。
|
||||
* 分词并标注词性。
|
||||
*/
|
||||
export declare function segment(hans: string, segment?: IPinyinSegment): string[];
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
import type { IPinyinAllOptions, IPinyinOptions, IPinyinStyle, IPinyinMode } from "./declare";
|
||||
import { ENUM_PINYIN_STYLE, ENUM_PINYIN_MODE } from "./constant";
|
||||
export declare function hasKey(obj: any, key: string): boolean;
|
||||
export declare function convertPinyinStyle(style?: IPinyinStyle): ENUM_PINYIN_STYLE;
|
||||
export declare function convertPinyinMode(mode?: IPinyinMode): ENUM_PINYIN_MODE;
|
||||
export declare function convertUserOptions(options?: IPinyinOptions): IPinyinAllOptions;
|
||||
/**
|
||||
* 组合 2 个拼音数组。
|
||||
* @param {string[]} a1 第一个数组,形如 ["zhāo", "cháo"]
|
||||
* @param {string[]} a2 字符串型数组。形如 ["yáng"]
|
||||
* @return {string[]} 组合后的一维数组,如上可得 ["zhāoyáng", "cháoyáng"]
|
||||
*/
|
||||
export declare function combo2array(a1: string[], a2: string[]): string[];
|
||||
/**
|
||||
* 合并二维元祖。
|
||||
* @param {string[][]} arr 二维元祖 [["zhāo", "cháo"], ["yáng"], ["dōng"], ["shēng"]]
|
||||
* @return {string[]} 返回二维字符串组合数组。形如
|
||||
* [
|
||||
* ["zhāoyáng"], ["dōng"], ["shēng"],
|
||||
* ["cháoyáng"], ["dōng"], ["shēng"]
|
||||
* ]
|
||||
*/
|
||||
export declare function combo(arr: string[][]): string[];
|
||||
/**
|
||||
* 组合两个拼音数组,形成一个新的二维数组
|
||||
* @param {string[]|string[][]} arr1 eg: ["hai", "huan"]
|
||||
* @param {string[]} arr2 eg: ["qian"]
|
||||
* @returns {string[][]} 组合后的二维数组,eg: [ ["hai", "qian"], ["huan", "qian"] ]
|
||||
*/
|
||||
export declare function compact2array(a1: string[] | string[][], a2: string[]): string[][];
|
||||
export declare function compact(arr: string[][]): string[][];
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
import { ENUM_PINYIN_MODE, ENUM_PINYIN_STYLE } from "./constant";
|
||||
import type { IPinyinAllOptions, IPinyinOptions, IPinyinSegment, IPinyin } from "./declare";
|
||||
export default class PinyinBase {
|
||||
STYLE_TONE: ENUM_PINYIN_STYLE;
|
||||
STYLE_TONE2: ENUM_PINYIN_STYLE;
|
||||
STYLE_TO3NE: ENUM_PINYIN_STYLE;
|
||||
STYLE_NORMAL: ENUM_PINYIN_STYLE;
|
||||
STYLE_INITIALS: ENUM_PINYIN_STYLE;
|
||||
STYLE_FIRST_LETTER: ENUM_PINYIN_STYLE;
|
||||
STYLE_PASSPORT: ENUM_PINYIN_STYLE;
|
||||
MODE_NORMAL: ENUM_PINYIN_MODE;
|
||||
MODE_SURNAME: ENUM_PINYIN_MODE;
|
||||
/**
|
||||
* 拼音转换入口。
|
||||
*/
|
||||
pinyin(hans: string, options?: IPinyinOptions): string[][];
|
||||
/**
|
||||
* 不使用分词算法的拼音转换。
|
||||
*/
|
||||
normal_pinyin(hans: string, options: IPinyinAllOptions): string[][];
|
||||
/**
|
||||
* 单字拼音转换。
|
||||
* @param {String} han, 单个汉字
|
||||
* @return {Array} 返回拼音列表,多音字会有多个拼音项。
|
||||
*/
|
||||
single_pinyin(han: string, options: IPinyinAllOptions): string[];
|
||||
segment(hans: string, segmentType?: IPinyinSegment): string[];
|
||||
/**
|
||||
* 将文本分词,并转换成拼音。
|
||||
*/
|
||||
segment_pinyin(hans: string, options: IPinyinAllOptions): string[][];
|
||||
/**
|
||||
* 词语注音
|
||||
* @param {String} phrases, 指定的词组。
|
||||
* @param {Object} options, 选项。
|
||||
* @return {Array}
|
||||
*/
|
||||
phrases_pinyin(phrases: string, options: IPinyinAllOptions): string[][];
|
||||
groupPhrases(phrases: string[][]): string[];
|
||||
surname_pinyin(hans: string, options: IPinyinAllOptions): string[][];
|
||||
compound_surname(hans: string, options: IPinyinAllOptions): string[][];
|
||||
single_surname(hans: string, options: IPinyinAllOptions): string[][];
|
||||
/**
|
||||
* 比较两个汉字转成拼音后的排序顺序,可以用作默认的拼音排序算法。
|
||||
*
|
||||
* @param {String} hanA 汉字字符串 A。
|
||||
* @return {String} hanB 汉字字符串 B。
|
||||
* @return {Number} 返回 -1,0,或 1。
|
||||
*/
|
||||
compare(hanA: string, hanB: string): number;
|
||||
compact(pys: string[][]): string[][];
|
||||
}
|
||||
export declare function getPinyinInstance(py: PinyinBase): IPinyin;
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import type { IPinyinAllOptions } from "./declare";
|
||||
export declare enum ENUM_PINYIN_STYLE {
|
||||
NORMAL = 0,
|
||||
TONE = 1,
|
||||
TONE2 = 2,
|
||||
TO3NE = 5,
|
||||
INITIALS = 3,
|
||||
FIRST_LETTER = 4,
|
||||
PASSPORT = 6
|
||||
}
|
||||
export declare enum ENUM_PINYIN_MODE {
|
||||
NORMAL = 0,
|
||||
SURNAME = 1
|
||||
}
|
||||
export declare const DEFAULT_OPTIONS: IPinyinAllOptions;
|
||||
export declare const PHONETIC_SYMBOL: Record<string, string>;
|
||||
export declare const INITIALS: string[];
|
||||
export declare const FINALS: string[];
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
declare const _default: Record<string, string[][]>;
|
||||
export default _default;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
declare const dict: Record<number, string>;
|
||||
export default dict;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
declare const phrases_dict: Record<string, string[][]>;
|
||||
export default phrases_dict;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
declare const _default: Record<string, string[][]>;
|
||||
export default _default;
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
import { ENUM_PINYIN_STYLE, ENUM_PINYIN_MODE } from "./constant";
|
||||
export interface IPinyin {
|
||||
(han: string, options?: IPinyinOptions): string[][];
|
||||
compare: (a: string, b: string) => number;
|
||||
compact: (arr: string[][]) => string[][];
|
||||
STYLE_TONE: ENUM_PINYIN_STYLE;
|
||||
STYLE_TONE2: ENUM_PINYIN_STYLE;
|
||||
STYLE_TO3NE: ENUM_PINYIN_STYLE;
|
||||
STYLE_NORMAL: ENUM_PINYIN_STYLE;
|
||||
STYLE_INITIALS: ENUM_PINYIN_STYLE;
|
||||
STYLE_FIRST_LETTER: ENUM_PINYIN_STYLE;
|
||||
STYLE_PASSPORT: ENUM_PINYIN_STYLE;
|
||||
MODE_NORMAL: ENUM_PINYIN_MODE;
|
||||
MODE_SURNAME: ENUM_PINYIN_MODE;
|
||||
}
|
||||
export type IPinyinStyle = ENUM_PINYIN_STYLE | "normal" | "tone" | "tone2" | "to3ne" | "initials" | "first_letter" | "passport" | // 推荐使用小写,和输出的拼音一致
|
||||
"NORMAL" | "TONE" | "TONE2" | "TO3NE" | "INITIALS" | "FIRST_LETTER" | "PASSPORT" | // 方便老版本迁移
|
||||
0 | 1 | 2 | 5 | 3 | 4;
|
||||
export type IPinyinMode = ENUM_PINYIN_MODE | "normal" | "surname" | "NORMAL" | "SURNAME";
|
||||
export type IPinyinSegment = "nodejieba" | "segmentit" | "@node-rs/jieba" | "Intl.Segmenter";
|
||||
export interface IPinyinAllOptions {
|
||||
style: ENUM_PINYIN_STYLE;
|
||||
mode: ENUM_PINYIN_MODE;
|
||||
segment?: IPinyinSegment;
|
||||
heteronym: boolean;
|
||||
group: boolean;
|
||||
compact: boolean;
|
||||
}
|
||||
export interface IPinyinOptions {
|
||||
style?: IPinyinStyle;
|
||||
mode?: IPinyinMode;
|
||||
segment?: IPinyinSegment | boolean;
|
||||
heteronym?: boolean;
|
||||
group?: boolean;
|
||||
compact?: boolean;
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import { ENUM_PINYIN_STYLE } from "./constant";
|
||||
/**
|
||||
* 格式化拼音风格。
|
||||
*
|
||||
* @param {string} pinyin TONE 风格的拼音。
|
||||
* @param {ENUM_PINYIN_STYLE} style 目标转换的拼音风格。
|
||||
* @return {string} 转换后的拼音。
|
||||
*/
|
||||
export declare function toFixed(pinyin: string, style: ENUM_PINYIN_STYLE): string;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
declare const phonetic_symbol: Record<string, string>;
|
||||
export default phonetic_symbol;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import PinyinBase from "./PinyinBase";
|
||||
export declare class Pinyin extends PinyinBase {
|
||||
}
|
||||
export declare const pinyin: import("./declare").IPinyin;
|
||||
export default pinyin;
|
||||
export declare const compare: (a: string, b: string) => number;
|
||||
export { compact } from "./util";
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import PinyinBase from "./PinyinBase";
|
||||
import type { IPinyinSegment } from "./declare";
|
||||
export declare class Pinyin extends PinyinBase {
|
||||
segment(hans: string, segmentType?: IPinyinSegment): string[];
|
||||
}
|
||||
export declare const pinyin: import("./declare").IPinyin;
|
||||
export default pinyin;
|
||||
export declare const compare: (a: string, b: string) => number;
|
||||
export { compact } from "./util";
|
||||
+85615
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+6
@@ -0,0 +1,6 @@
|
||||
import type { IPinyinSegment } from "./declare";
|
||||
/**
|
||||
* TODO: 分词并带词性信息,需要调整 segment_pinyin 方法。
|
||||
* 分词并标注词性。
|
||||
*/
|
||||
export declare function segment(hans: string, segment?: IPinyinSegment): string[];
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import type { IPinyinSegment } from "./declare";
|
||||
/**
|
||||
* TODO: 分词并带词性信息,需要调整 segment_pinyin 方法。
|
||||
* 分词并标注词性。
|
||||
*/
|
||||
export declare function segment(hans: string, segment?: IPinyinSegment): string[];
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
import type { IPinyinAllOptions, IPinyinOptions, IPinyinStyle, IPinyinMode } from "./declare";
|
||||
import { ENUM_PINYIN_STYLE, ENUM_PINYIN_MODE } from "./constant";
|
||||
export declare function hasKey(obj: any, key: string): boolean;
|
||||
export declare function convertPinyinStyle(style?: IPinyinStyle): ENUM_PINYIN_STYLE;
|
||||
export declare function convertPinyinMode(mode?: IPinyinMode): ENUM_PINYIN_MODE;
|
||||
export declare function convertUserOptions(options?: IPinyinOptions): IPinyinAllOptions;
|
||||
/**
|
||||
* 组合 2 个拼音数组。
|
||||
* @param {string[]} a1 第一个数组,形如 ["zhāo", "cháo"]
|
||||
* @param {string[]} a2 字符串型数组。形如 ["yáng"]
|
||||
* @return {string[]} 组合后的一维数组,如上可得 ["zhāoyáng", "cháoyáng"]
|
||||
*/
|
||||
export declare function combo2array(a1: string[], a2: string[]): string[];
|
||||
/**
|
||||
* 合并二维元祖。
|
||||
* @param {string[][]} arr 二维元祖 [["zhāo", "cháo"], ["yáng"], ["dōng"], ["shēng"]]
|
||||
* @return {string[]} 返回二维字符串组合数组。形如
|
||||
* [
|
||||
* ["zhāoyáng"], ["dōng"], ["shēng"],
|
||||
* ["cháoyáng"], ["dōng"], ["shēng"]
|
||||
* ]
|
||||
*/
|
||||
export declare function combo(arr: string[][]): string[];
|
||||
/**
|
||||
* 组合两个拼音数组,形成一个新的二维数组
|
||||
* @param {string[]|string[][]} arr1 eg: ["hai", "huan"]
|
||||
* @param {string[]} arr2 eg: ["qian"]
|
||||
* @returns {string[][]} 组合后的二维数组,eg: [ ["hai", "qian"], ["huan", "qian"] ]
|
||||
*/
|
||||
export declare function compact2array(a1: string[] | string[][], a2: string[]): string[][];
|
||||
export declare function compact(arr: string[][]): string[][];
|
||||
Reference in New Issue
Block a user