simple-ime 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/simple-ime.cjs +5 -5
- package/dist/simple-ime.es.js +799 -713
- package/dist/simple-ime.global.js +5 -5
- package/dist/simple-ime.umd.js +5 -5
- package/dist/src/engine/corrector.d.ts +5 -0
- package/dist/src/engine/dict.d.ts +6 -0
- package/dist/src/engine/fuzzy.d.ts +10 -0
- package/dist/src/engine/index.d.ts +6 -10
- package/dist/src/engine/pinyin.d.ts +15 -3
- package/dist/src/ime/dom.d.ts +1 -1
- package/dist/src/types.d.ts +5 -0
- package/dist/tests/corrector.test.d.ts +1 -0
- package/dist/tests/fuzzy.test.d.ts +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function nearSwapCorrector(s: string, pinyinSet: Set<string>): string[];
|
|
2
|
+
export declare function calcDamerauLevenshteinDistance(s1: string, s2: string): number;
|
|
3
|
+
export declare function damerauLevenshteinDistanceCorrector(s: string, pinyinSet: Set<string>, threshold: number): string[];
|
|
4
|
+
export declare function calcLevenshteinDistance(s1: string, s2: string): number;
|
|
5
|
+
export declare function levenshteinDistanceCorrector(s: string, pinyinSet: Set<string>, threshold: number): string[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DictWord, PinyinSyllables } from '../types';
|
|
2
|
+
import { PTrie } from 'dawg-lookup';
|
|
3
|
+
|
|
4
|
+
export declare const trie: PTrie;
|
|
5
|
+
/**
|
|
6
|
+
* @example inputs nh and returns nihao
|
|
7
|
+
*/
|
|
8
|
+
export declare function getFuzzyMatchedSyllable(w: string): PinyinSyllables;
|
|
9
|
+
export declare function getFuzzyMatchedPinyin(segments: string[]): PinyinSyllables[];
|
|
10
|
+
export declare function getFuzzyMatchedWords(segments: string[]): DictWord[];
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { Candidate } from '../types';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
f: number;
|
|
3
|
+
interface LookUpOptions {
|
|
4
|
+
limit: number;
|
|
5
|
+
corrected?: string[];
|
|
7
6
|
}
|
|
8
|
-
export declare
|
|
9
|
-
export declare const trie: any;
|
|
10
|
-
export declare function getWordsFormDict(pinyin: string): DictWord[];
|
|
11
|
-
export declare function mergeSegments(segments: string[], start?: number, end?: number): {
|
|
7
|
+
export declare function mergeSegments(segments: string[], start: number, end: number, corrected?: string[]): {
|
|
12
8
|
pinyin: string;
|
|
13
9
|
text: string;
|
|
14
10
|
};
|
|
15
|
-
export declare function backwardLookupCandidates(segments: string[], end: number,
|
|
16
|
-
export declare function forwardLookupCandidates(segments: string[], end: number,
|
|
11
|
+
export declare function backwardLookupCandidates(segments: string[], end: number, opts: LookUpOptions): Candidate[];
|
|
12
|
+
export declare function forwardLookupCandidates(segments: string[], end: number, opts: LookUpOptions): Candidate[];
|
|
17
13
|
export declare function requestCandidates(text: string, category?: number): {
|
|
18
14
|
segments: string[];
|
|
19
15
|
candidates: Candidate[];
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
+
import { PinyinSyllables } from '../types';
|
|
2
|
+
|
|
1
3
|
export declare const pinyinSet: Set<string>;
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function appendSyllables(ans: PinyinSyllables[], compAns: PinyinSyllables[]): PinyinSyllables[];
|
|
5
|
+
export declare function splitSyllablesExhaustive(text: string): PinyinSyllables[];
|
|
6
|
+
export declare function splitSyllablesByExistPinyin(text: string, callback?: (quotes: string, collector?: PinyinSyllables, indexes?: number[]) => void): PinyinSyllables;
|
|
7
|
+
export declare function splitSyllablesByExistPinyinWithCorrector(text: string): {
|
|
8
|
+
result: PinyinSyllables;
|
|
9
|
+
corrected: PinyinSyllables;
|
|
10
|
+
};
|
|
11
|
+
export declare function split(text: string, options?: {
|
|
12
|
+
useCorrector: boolean;
|
|
13
|
+
}): {
|
|
14
|
+
result: PinyinSyllables;
|
|
15
|
+
corrected?: PinyinSyllables;
|
|
16
|
+
};
|
package/dist/src/ime/dom.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function isEditableElement(element:
|
|
1
|
+
export declare function isEditableElement(element: Element): boolean;
|
|
2
2
|
export declare function updateContent(element: Element, str: string): false | undefined;
|
package/dist/src/types.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "simple-ime",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"description": "A simple browser tool to use Chinese Pinyin Input Method (IME).",
|
|
6
6
|
"author": "nieyuyao <nieyuyao0826@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"test": "vitest",
|
|
24
24
|
"compressDict": "ts-node --esm ./scripts/compress-dict.ts",
|
|
25
25
|
"splitDict": "ts-node --esm ./scripts/split-dict.ts && npm run compressDict",
|
|
26
|
+
"genPackedTrie": "ts-node --esm ./scripts/gen-packed-trie.ts",
|
|
26
27
|
"lint": "eslint -c ./eslint.config.mjs",
|
|
27
28
|
"lint:fix": "eslint -c ./eslint.config.mjs --fix",
|
|
28
29
|
"release": "bash ./release.sh"
|