taraskevizer 9.2.3 → 9.3.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/bin.js +3 -3
- package/dist/dict/alphabets/arabic.d.ts +1 -1
- package/dist/dict/alphabets/arabic.js +55 -52
- package/dist/dict/alphabets/cyrillic.d.ts +2 -2
- package/dist/dict/alphabets/cyrillic.js +3 -2
- package/dist/dict/alphabets/latin.d.ts +4 -4
- package/dist/dict/alphabets/latin.js +109 -112
- package/dist/dict/alphabets/types.d.ts +3 -3
- package/dist/dict/iawords.d.ts +1 -1
- package/dist/dict/iawords.js +3 -3
- package/dist/dict/lib.d.ts +5 -9
- package/dist/dict/lib.js +7 -15
- package/dist/dict/phonetic.d.ts +1 -1
- package/dist/dict/phonetic.js +5 -4
- package/dist/dict/softening.d.ts +2 -2
- package/dist/dict/softening.js +13 -13
- package/dist/dict/types.d.ts +6 -8
- package/dist/dict/wordlist.d.ts +1 -2
- package/dist/dict/wordlist.js +1414 -1413
- package/dist/lib/after-tarask.d.ts +1 -2
- package/dist/lib/after-tarask.js +3 -2
- package/dist/lib/debug.d.ts +3 -0
- package/dist/lib/debug.js +16 -0
- package/dist/lib/index.d.ts +1 -2
- package/dist/lib/index.js +1 -2
- package/dist/lib/mutating-step.d.ts +4 -4
- package/dist/lib/mutating-step.js +2 -2
- package/dist/lib/replace-g.js +1 -1
- package/dist/lib/soften.js +3 -4
- package/dist/lib/types.d.ts +5 -0
- package/dist/pipelines.d.ts +1 -1
- package/dist/steps/apply-g.js +5 -9
- package/dist/steps/apply-variations.d.ts +1 -1
- package/dist/steps/convert-alphabet.d.ts +2 -2
- package/dist/steps/convert-alphabet.js +7 -3
- package/dist/steps/finalize.d.ts +3 -3
- package/dist/steps/i-to-j.js +3 -3
- package/dist/steps/iotacize-ji.d.ts +1 -1
- package/dist/steps/iotacize-ji.js +8 -7
- package/dist/steps/phonetize.d.ts +1 -1
- package/dist/steps/phonetize.js +2 -3
- package/dist/steps/prepare.d.ts +1 -1
- package/dist/steps/resolve-syntax.js +5 -5
- package/dist/steps/store-splitted-abc-converted-orig.js +2 -2
- package/dist/steps/taraskevize.d.ts +1 -1
- package/dist/steps/taraskevize.js +2 -2
- package/dist/steps/to-lower-case.d.ts +1 -1
- package/dist/steps/types.d.ts +1 -1
- package/dist/tarask.js +3 -3
- package/package.json +10 -5
- package/dist/lib/replace-with-dict.d.ts +0 -2
- package/dist/lib/replace-with-dict.js +0 -7
- package/dist/lib/tools.debug.d.ts +0 -3
- package/dist/lib/tools.debug.js +0 -17
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const endZSoftenAndNiaBiaz: Dict;
|
|
1
|
+
export declare const endZSoftenAndNiaBiaz: import("../dict").CallableDict;
|
package/dist/lib/after-tarask.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { callableDict } from '../dict/lib.js';
|
|
2
|
+
export const endZSoftenAndNiaBiaz = callableDict([
|
|
2
3
|
// / не (?=
|
|
3
4
|
// {зычны}*{сымбаль}{націск}
|
|
4
5
|
// |{зычны}*{галосны}{зычны}*{канец слова}
|
|
@@ -19,4 +20,4 @@ export const endZSoftenAndNiaBiaz = [
|
|
|
19
20
|
|
|
20
21
|
[/ б[ея]з(?= і\S*[ая]ў|ну )/g, ' бязь'],
|
|
21
22
|
[/ (?:пра|цера)?з(?= і\S*[ая]ў|ну )/g, '$&ь'],
|
|
22
|
-
];
|
|
23
|
+
]);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const prefix = '[debug]';
|
|
2
|
+
export const dict = (dict, regex) => {
|
|
3
|
+
const fn = (text) => fn.value.reduce((acc, item) => {
|
|
4
|
+
if (regex.test(text)) {
|
|
5
|
+
console.log(prefix, 'replaceWithDict:', item);
|
|
6
|
+
process.exit(1);
|
|
7
|
+
}
|
|
8
|
+
return acc.replace(item[0], item[1]);
|
|
9
|
+
}, text);
|
|
10
|
+
fn.value = dict.value;
|
|
11
|
+
return fn;
|
|
12
|
+
};
|
|
13
|
+
export const log = (...msgs) => {
|
|
14
|
+
console.log(prefix, ...msgs);
|
|
15
|
+
return msgs[0];
|
|
16
|
+
};
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export * from './after-tarask';
|
|
2
2
|
export * from './highlight-diff';
|
|
3
3
|
export * from './replace-g';
|
|
4
|
-
export * from './replace-with-dict';
|
|
5
4
|
export * from './restore-case';
|
|
6
5
|
export * from './mutating-step';
|
|
7
6
|
export * from './soften';
|
|
8
|
-
export {
|
|
7
|
+
export { callableDict as dict, copyDict } from './../dict/lib';
|
|
9
8
|
export type * from './types';
|
package/dist/lib/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export * from './after-tarask.js';
|
|
2
2
|
export * from './highlight-diff.js';
|
|
3
3
|
export * from './replace-g.js';
|
|
4
|
-
export * from './replace-with-dict.js';
|
|
5
4
|
export * from './restore-case.js';
|
|
6
5
|
export * from './mutating-step.js';
|
|
7
6
|
export * from './soften.js';
|
|
8
|
-
export {
|
|
7
|
+
export { callableDict as dict, copyDict } from './../dict/lib.js';
|
|
@@ -12,10 +12,10 @@ import type { TaraskStep } from '../steps/types';
|
|
|
12
12
|
* ({ text, storage: { wrapText } }) => wrapText(text.trim())
|
|
13
13
|
* );
|
|
14
14
|
* // is equivalent to
|
|
15
|
-
* const trimStep: TaraskStep<TextWrapperStorage> = (
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* const trimStep: TaraskStep<TextWrapperStorage> = (ctx) => {
|
|
16
|
+
* ctx.text = options.storage.wrapText(
|
|
17
|
+
* ctx.text.trim()
|
|
18
18
|
* );
|
|
19
19
|
* };
|
|
20
20
|
*/
|
|
21
|
-
export declare const mutatingStep: <T extends object =
|
|
21
|
+
export declare const mutatingStep: <T extends object = object>(callback: (...args: Parameters<TaraskStep<T>>) => string) => TaraskStep<T>;
|
package/dist/lib/replace-g.js
CHANGED
package/dist/lib/soften.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { noSoften, softeners } from '../dict/softening.js';
|
|
2
|
-
import { replaceWithDict } from './replace-with-dict.js';
|
|
3
2
|
export const soften = (text) => {
|
|
4
|
-
text =
|
|
3
|
+
text = noSoften(text);
|
|
5
4
|
do {
|
|
6
|
-
text =
|
|
7
|
-
} while (softeners.some((
|
|
5
|
+
text = softeners(text);
|
|
6
|
+
} while (softeners.value.some(({ 0: pattern }) => pattern.test(text)));
|
|
8
7
|
return text.replace(/\ue0ff/g, '');
|
|
9
8
|
};
|
package/dist/lib/types.d.ts
CHANGED
package/dist/pipelines.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export declare const abc: (TaraskStep<import("./steps").SpecialSyntaxStorage> |
|
|
|
39
39
|
*
|
|
40
40
|
* Used by {@link tar} and {@link phonetic}.
|
|
41
41
|
*
|
|
42
|
-
* @param subPipeline - Steps used instead of [{@link
|
|
42
|
+
* @param subPipeline - Steps used instead of [{@link steps.taraskevize}].
|
|
43
43
|
*/
|
|
44
44
|
export declare const _createPipeline: (subPipeline: Pipeline) => (TaraskStep<import("./steps").SplittedTextStorage> | TaraskStep<import("./steps").SpecialSyntaxStorage> | TaraskStep<import("./steps").WhiteSpaceStorage> | TaraskStep<import("./steps").TrimStorage>)[];
|
|
45
45
|
/**
|
package/dist/steps/apply-g.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { replaceG } from '../lib/index.js';
|
|
2
2
|
import { alphabets, gobj } from '../dict/index.js';
|
|
3
|
-
export const applyG = (
|
|
4
|
-
const { abc, g, wrapperDict } =
|
|
5
|
-
const
|
|
6
|
-
if (abc === alphabets.cyrillic && (
|
|
7
|
-
|
|
8
|
-
? g
|
|
9
|
-
? colorize('$&')
|
|
10
|
-
: ($0) => colorize(gobj[$0])
|
|
11
|
-
: ($0) => gobj[$0])(options.text);
|
|
3
|
+
export const applyG = (ctx) => {
|
|
4
|
+
const { abc, g, wrapperDict } = ctx.cfg;
|
|
5
|
+
const wrap = wrapperDict?.letterH;
|
|
6
|
+
if (abc === alphabets.cyrillic && (wrap || !g))
|
|
7
|
+
ctx.text = replaceG(wrap ? (g ? wrap('$&') : ($0) => wrap(gobj[$0])) : ($0) => gobj[$0])(ctx.text);
|
|
12
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const applyVariations: import("./types").TaraskStep<
|
|
1
|
+
export declare const applyVariations: import("./types").TaraskStep<object>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const convertAlphabet: import("./types").TaraskStep<
|
|
2
|
-
export declare const convertAlphabetLowerCase: import("./types").TaraskStep<
|
|
1
|
+
export declare const convertAlphabet: import("./types").TaraskStep<object>;
|
|
2
|
+
export declare const convertAlphabetLowerCase: import("./types").TaraskStep<object>;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import { mutatingStep
|
|
2
|
-
|
|
3
|
-
export const
|
|
1
|
+
import { mutatingStep } from '../lib/index.js';
|
|
2
|
+
import * as debug from '../lib/debug.js';
|
|
3
|
+
export const convertAlphabet = mutatingStep(({ text, cfg: { abc: { upper, lower }, }, }) => {
|
|
4
|
+
text = lower(text);
|
|
5
|
+
return upper ? debug.dict(upper, /K/)(text) : text;
|
|
6
|
+
});
|
|
7
|
+
export const convertAlphabetLowerCase = mutatingStep(({ text, cfg: { abc: { lower }, }, }) => lower(text));
|
package/dist/steps/finalize.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param newLine - The string to replace new lines with.
|
|
3
|
-
*
|
|
4
2
|
* Reverse the changes made in the {@link prepare} step
|
|
5
3
|
* and replace new lines with the passed string.
|
|
6
4
|
*
|
|
@@ -8,6 +6,8 @@
|
|
|
8
6
|
* `(` from `(`,
|
|
9
7
|
* ` ` from ` `,
|
|
10
8
|
*
|
|
9
|
+
* Replaces new lines with the `newLine` config value.
|
|
10
|
+
*
|
|
11
11
|
* Removes spaces around punctuation marks and digits.
|
|
12
12
|
*/
|
|
13
|
-
export declare const finalize: import("./types").TaraskStep<
|
|
13
|
+
export declare const finalize: import("./types").TaraskStep<object>;
|
package/dist/steps/i-to-j.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { alphabets } from '../dict/index.js';
|
|
2
2
|
const toJ = (shortU) => 'й ' + (shortU ? 'у' : '');
|
|
3
|
-
export const replaceIbyJ = (
|
|
4
|
-
const { abc, j } =
|
|
3
|
+
export const replaceIbyJ = (ctx) => {
|
|
4
|
+
const { abc, j } = ctx.cfg;
|
|
5
5
|
if (j !== 'never' && abc !== alphabets.latinJi)
|
|
6
|
-
|
|
6
|
+
ctx.text = ctx.text.replace(/(?<=[аеёіоуыэюя] )і (ў?)/g, j === 'always'
|
|
7
7
|
? (_$0, $1) => toJ($1)
|
|
8
8
|
: ($0, $1) => (Math.random() >= 0.5 ? toJ($1) : $0));
|
|
9
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const iotacizeJi: import("./types").TaraskStep<
|
|
1
|
+
export declare const iotacizeJi: import("./types").TaraskStep<object>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { iwords } from '../dict/index.js';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
[/([аеёіоуыэюя\u0301] )і
|
|
6
|
-
[/([аеёіоуыэюя\u0301]
|
|
7
|
-
[
|
|
2
|
+
import { regexG } from '../dict/lib.js';
|
|
3
|
+
import { dict, mutatingStep } from '../lib/index.js';
|
|
4
|
+
const iDict = dict([
|
|
5
|
+
[/([аеёіоуыэюя\u0301] )і ў/g, '$1й у'],
|
|
6
|
+
[/([аеёіоуыэюя\u0301] )і /g, '$1й '],
|
|
7
|
+
[/([аеёіоуыэюя\u0301] ?)і/g, '$1йі'],
|
|
8
|
+
[regexG(` і(?=${iwords})`), ' йі'],
|
|
8
9
|
]);
|
|
9
|
-
export const iotacizeJi = mutatingStep(({ text }) =>
|
|
10
|
+
export const iotacizeJi = mutatingStep(({ text }) => iDict(text));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const phonetize: import("./types").TaraskStep<
|
|
1
|
+
export declare const phonetize: import("./types").TaraskStep<object>;
|
package/dist/steps/phonetize.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { iaWords, phonetic } from '../dict/index.js';
|
|
2
|
-
import { endZSoftenAndNiaBiaz, mutatingStep,
|
|
3
|
-
const
|
|
4
|
-
export const phonetize = mutatingStep(({ text }) => replaceWithDict(replaceWithDict(soften(text), dict), endZSoftenAndNiaBiaz));
|
|
2
|
+
import { endZSoftenAndNiaBiaz, mutatingStep, soften } from '../lib/index.js';
|
|
3
|
+
export const phonetize = mutatingStep(({ text }) => endZSoftenAndNiaBiaz(phonetic(iaWords(soften(text)))));
|
package/dist/steps/prepare.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { restoreCase,
|
|
1
|
+
import { restoreCase, mutatingStep } from '../lib/index.js';
|
|
2
2
|
const NOFIX_CHAR = ' \ue0fe ';
|
|
3
3
|
const NOFIX_REGEX = new RegExp(NOFIX_CHAR, 'g');
|
|
4
4
|
|
|
5
|
-
export const applyNoFix = (
|
|
6
|
-
const { noFixArr } =
|
|
5
|
+
export const applyNoFix = (ctx) => {
|
|
6
|
+
const { noFixArr } = ctx.storage;
|
|
7
7
|
if (noFixArr.length) {
|
|
8
8
|
noFixArr.reverse();
|
|
9
|
-
|
|
9
|
+
ctx.text = ctx.text.replace(NOFIX_REGEX, () => noFixArr.pop());
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export const resolveSpecialSyntax = mutatingStep(({ text, storage, cfg: { doEscapeCapitalized, abc, leftAngleBracket } }) => {
|
|
14
14
|
const noFixArr = (storage.noFixArr = []);
|
|
15
|
-
const convertAlphavet = (abcOnlyText, abc) => restoreCase(
|
|
15
|
+
const convertAlphavet = (abcOnlyText, abc) => restoreCase(abc.lower(abcOnlyText.toLowerCase()).split(' '), abcOnlyText.split(' ')).join(' ');
|
|
16
16
|
const escapeCapsIfNeeded = (text) => doEscapeCapitalized
|
|
17
17
|
? text.replace(/(?!<=\p{Lu} )\p{Lu}{2}[\p{Lu} ]*(?!= \p{Lu})/gu, ($0) => {
|
|
18
18
|
noFixArr.push(convertAlphavet($0, abc));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { replaceWithDict } from '../lib/index.js';
|
|
2
1
|
export const storeSplittedAbcConvertedOrig = ({ cfg: { abc: { lower, upper }, }, text, storage, }) => {
|
|
3
|
-
|
|
2
|
+
text = lower(text);
|
|
3
|
+
storage.origArr = (upper ? upper(text) : text).split(' ');
|
|
4
4
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const taraskevize: import("./types").TaraskStep<
|
|
1
|
+
export declare const taraskevize: import("./types").TaraskStep<object>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { wordlist } from '../dict/index.js';
|
|
2
|
-
import { endZSoftenAndNiaBiaz, mutatingStep,
|
|
3
|
-
export const taraskevize = mutatingStep(({ text }) =>
|
|
2
|
+
import { endZSoftenAndNiaBiaz, mutatingStep, soften } from '../lib/index.js';
|
|
3
|
+
export const taraskevize = mutatingStep(({ text }) => endZSoftenAndNiaBiaz(soften(wordlist(text))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const toLowerCase: import("./types").TaraskStep<
|
|
1
|
+
export declare const toLowerCase: import("./types").TaraskStep<object>;
|
package/dist/steps/types.d.ts
CHANGED
package/dist/tarask.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TaraskConfig } from './config.js';
|
|
2
2
|
|
|
3
3
|
export const tarask = (text, pipeline, cfg = new TaraskConfig()) => {
|
|
4
|
-
const
|
|
4
|
+
const ctx = { text, cfg, storage: {} };
|
|
5
5
|
for (const step of pipeline)
|
|
6
|
-
step(
|
|
7
|
-
return
|
|
6
|
+
step(ctx);
|
|
7
|
+
return ctx.text;
|
|
8
8
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "taraskevizer",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.0",
|
|
4
4
|
"author": "GooseOb",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,12 +10,16 @@
|
|
|
10
10
|
"module": "dist/index.js",
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@digitak/esrun": "^3.2.26",
|
|
13
|
-
"@
|
|
14
|
-
"
|
|
13
|
+
"@eslint/js": "^9.13.0",
|
|
14
|
+
"@types/node": "^20.16.12",
|
|
15
|
+
"bun-types": "^1.1.31",
|
|
16
|
+
"eslint": "^9.13.0",
|
|
17
|
+
"globals": "^15.11.0",
|
|
15
18
|
"husky": "^9.1.6",
|
|
16
19
|
"prettier": "^3.3.3",
|
|
17
|
-
"typedoc": "^0.26.
|
|
18
|
-
"typescript": "^5.6.3"
|
|
20
|
+
"typedoc": "^0.26.10",
|
|
21
|
+
"typescript": "^5.6.3",
|
|
22
|
+
"typescript-eslint": "^8.11.0"
|
|
19
23
|
},
|
|
20
24
|
"bin": {
|
|
21
25
|
"tarask": "dist/bin.js"
|
|
@@ -38,6 +42,7 @@
|
|
|
38
42
|
"scripts": {
|
|
39
43
|
"build": "bun ./build.ts",
|
|
40
44
|
"prettier": "prettier --write .",
|
|
45
|
+
"lint": "eslint .",
|
|
41
46
|
"dev": "esrun --watch=src/*,test/* --send-code-mode=temporaryFile test",
|
|
42
47
|
"dev:bun": "bun test --watch",
|
|
43
48
|
"test": "esrun --send-code-mode=temporaryFile test",
|
package/dist/lib/tools.debug.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export const replaceWithDict = (text, dict, regex) => {
|
|
2
|
-
for (const item of dict) {
|
|
3
|
-
const [pattern, result] = item;
|
|
4
|
-
text = text.replace(pattern,
|
|
5
|
-
//@ts-ignore
|
|
6
|
-
result);
|
|
7
|
-
if (regex.test(text)) {
|
|
8
|
-
log('replaceWithDict:', item);
|
|
9
|
-
process.exit(1);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return text;
|
|
13
|
-
};
|
|
14
|
-
export const log = (...msgs) => {
|
|
15
|
-
console.log('[debug]', ...msgs);
|
|
16
|
-
return msgs[0];
|
|
17
|
-
};
|