-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from zh-lx/release-3.18.6
release: 3.18.6
- Loading branch information
Showing
24 changed files
with
558 additions
and
551 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
/** | ||
* @description: AC 自动机 | ||
*/ | ||
export interface Pattern { | ||
zh: string; | ||
pinyin: string; | ||
priority: number; | ||
length: number; | ||
isSurname?: boolean; | ||
} | ||
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; | ||
reset(): void; | ||
buildFailPointer(): void; | ||
search(text: string, isSurname?: boolean): MatchPattern[]; | ||
filter(patterns: MatchPattern[], isSurname?: boolean): MatchPattern[]; | ||
} | ||
export declare const PatternsNormal: Pattern[]; | ||
export declare const ACNormal: AC; | ||
export {}; | ||
/** | ||
* @description: AC 自动机 | ||
*/ | ||
export interface Pattern { | ||
zh: string; | ||
pinyin: string; | ||
priority: number; | ||
length: number; | ||
isSurname?: boolean; | ||
} | ||
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; | ||
reset(): void; | ||
buildFailPointer(): void; | ||
search(text: string, isSurname?: boolean): MatchPattern[]; | ||
filter(patterns: MatchPattern[], isSurname?: boolean): MatchPattern[]; | ||
} | ||
export declare const PatternsNormal: Pattern[]; | ||
export declare const ACNormal: AC; | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export declare const DoubleUnicodePrefixReg: RegExp; | ||
export declare const DoubleUnicodeSuffixReg: RegExp; | ||
export declare const DoubleUnicodePrefixReg: RegExp; | ||
export declare const DoubleUnicodeSuffixReg: RegExp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +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'; | ||
export interface SingleWordResult { | ||
origin: string; | ||
originPinyin: string; | ||
result: string; | ||
isZh: boolean; | ||
delete?: boolean; | ||
} | ||
export type ToneType = 'symbol' | 'num' | 'none'; | ||
export type PinyinMode = 'normal' | 'surname'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export declare function getStringLength(string: string): number; | ||
export declare function getSplittedWord(string: string): string[]; | ||
export declare function isZhChar(char: string): boolean; | ||
export declare function getStringLength(string: string): number; | ||
export declare function getSplittedWord(string: string): string[]; | ||
export declare function isZhChar(char: string): boolean; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
declare type ConvertFormat = 'numToSymbol' | 'symbolToNum' | 'toneNone'; | ||
interface ConvertOptions { | ||
/** | ||
* @description 拼音之间的分隔符,默认为空格,convert方法会以该分隔符分割拼音进行转换 | ||
*/ | ||
separator?: string; | ||
/** | ||
* @description 转换的格式, 默认为 numToSymbol | ||
* @example numToSymbol: pin yin -> pīn yīn | ||
* @example symbolToNum: pīn yīn -> pin yin | ||
* @example toneNone: pīn yīn -> pin yin | ||
*/ | ||
format?: ConvertFormat; | ||
} | ||
/** | ||
* @description: 拼音格式转换。pin yin -> pīn yīn 或 pīn yīn -> pin yin 或 pīn yīn -> pin yin | ||
* @param {string} pinyin 要转换的拼音字符串或者拼音字符串数组 | ||
* @param {ConvertOptions=} options 配置项 | ||
* @return {string} 转换后的拼音字符串或者拼音字符串数组 | ||
*/ | ||
declare function convert(pinyin: string, options?: ConvertOptions): string; | ||
/** | ||
* @description: 拼音格式转换。pin yin -> pīn yīn 或 pīn yīn -> pin yin 或 pīn yīn -> pin yin | ||
* @param {string[]} pinyin 要转换的拼音字符串或者拼音字符串数组 | ||
* @param {ConvertOptions=} options 配置项 | ||
* @return {string[]} 转换后的拼音字符串或者拼音字符串数组 | ||
*/ | ||
declare function convert(pinyin: string[], options?: ConvertOptions): string[]; | ||
export { convert }; | ||
type ConvertFormat = 'numToSymbol' | 'symbolToNum' | 'toneNone'; | ||
interface ConvertOptions { | ||
/** | ||
* @description 拼音之间的分隔符,默认为空格,convert方法会以该分隔符分割拼音进行转换 | ||
*/ | ||
separator?: string; | ||
/** | ||
* @description 转换的格式, 默认为 numToSymbol | ||
* @example numToSymbol: pin1 yin1 -> pīn yīn | ||
* @example symbolToNum: pīn yīn -> pin1 yin1 | ||
* @example toneNone: pīn yīn -> pin yin | ||
*/ | ||
format?: ConvertFormat; | ||
} | ||
/** | ||
* @description: 拼音格式转换。pin1 yin1 -> pīn yīn 或 pīn yīn -> pin1 yin1 或 pīn yīn -> pin yin | ||
* @param {string} pinyin 要转换的拼音字符串或者拼音字符串数组 | ||
* @param {ConvertOptions=} options 配置项 | ||
* @return {string} 转换后的拼音字符串或者拼音字符串数组 | ||
*/ | ||
declare function convert(pinyin: string, options?: ConvertOptions): string; | ||
/** | ||
* @description: 拼音格式转换。pin1 yin1 -> pīn yīn 或 pīn yīn -> pin1 yin1 或 pīn yīn -> pin yin | ||
* @param {string[]} pinyin 要转换的拼音字符串或者拼音字符串数组 | ||
* @param {ConvertOptions=} options 配置项 | ||
* @return {string[]} 转换后的拼音字符串或者拼音字符串数组 | ||
*/ | ||
declare function convert(pinyin: string[], options?: ConvertOptions): string[]; | ||
export { convert }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +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; | ||
/** | ||
* @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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +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 {}; | ||
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) => string; | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
interface MatchOptions { | ||
/** | ||
* @description 每个汉字和拼音需要遵从的匹配精度 | ||
*/ | ||
precision?: 'first' | 'start' | 'every' | 'any'; | ||
/** | ||
* @description 匹配的汉字下标是否为连续的才算匹配成功 | ||
*/ | ||
continuous?: boolean; | ||
/** | ||
* @description 匹配时对于空格的处理 | ||
*/ | ||
space?: 'ignore' | 'preserve'; | ||
/** | ||
* @description 最后一个字的匹配精度 | ||
*/ | ||
lastPrecision?: 'first' | 'start' | 'every' | 'any'; | ||
/** | ||
* @description 是否大小写不敏感 | ||
*/ | ||
insensitive?: boolean; | ||
} | ||
/** | ||
* @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 {}; | ||
interface MatchOptions { | ||
/** | ||
* @description 每个汉字和拼音需要遵从的匹配精度 | ||
*/ | ||
precision?: 'first' | 'start' | 'every' | 'any'; | ||
/** | ||
* @description 匹配的汉字下标是否为连续的才算匹配成功 | ||
*/ | ||
continuous?: boolean; | ||
/** | ||
* @description 匹配时对于空格的处理 | ||
*/ | ||
space?: 'ignore' | 'preserve'; | ||
/** | ||
* @description 最后一个字的匹配精度 | ||
*/ | ||
lastPrecision?: 'first' | 'start' | 'every' | 'any'; | ||
/** | ||
* @description 是否大小写不敏感 | ||
*/ | ||
insensitive?: boolean; | ||
} | ||
/** | ||
* @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) => any; | ||
export {}; |
Oops, something went wrong.