bindu 1.0.2 → 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/ChangeLog +13 -0
- package/README.md +3 -1
- package/lib/bindu.js +21 -7
- package/lib/sandhi/apply-dirgha/index.js +43 -0
- package/lib/sandhi/apply-guna/index.js +47 -0
- package/lib/sandhi/apply-yan/index.js +66 -0
- package/lib/sandhi/index.js +9 -0
- package/package.json +1 -1
- package/lib/plugins/apply-vriddhi/index.js +0 -31
package/ChangeLog
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
2025.12.08, v1.2.0
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- a95fbe5 bindu: apply-yarn: report: iko yaṇaci
|
|
5
|
+
|
|
6
|
+
feature:
|
|
7
|
+
- d51a2dd bindu: sandhi: apply-guna: add
|
|
8
|
+
|
|
9
|
+
2025.12.07, v1.1.0
|
|
10
|
+
|
|
11
|
+
feature:
|
|
12
|
+
- 0623c50 bindu: add sandhi: dirgha, yan
|
|
13
|
+
|
|
1
14
|
2025.12.07, v1.0.2
|
|
2
15
|
|
|
3
16
|
fix:
|
package/README.md
CHANGED
|
@@ -39,7 +39,9 @@ places[0].message;
|
|
|
39
39
|
|
|
40
40
|
## Rules
|
|
41
41
|
|
|
42
|
-
- ✅
|
|
42
|
+
- ✅[`sandhi/apply-dirgha`](https://putout.cloudcmd.io/#/gist/0ad8154614be489ae50931109618100a/5ce86f7344b37fd40afeb229e6cb1f668d4f92fd): [अकः सवर्णे दीर्घः](https://www.learnsanskrit.org/vyakarana/sounds/ac-sandhi/?utm_source=chatgpt.com#:~:text=a%20new%20rule%3A-,%E0%A4%85%E0%A4%95%E0%A4%83%20%E0%A4%B8%E0%A4%B5%E0%A4%B0%E0%A5%8D%E0%A4%A3%E0%A5%87%20%E0%A4%A6%E0%A5%80%E0%A4%B0%E0%A5%8D%E0%A4%98%E0%A4%83%E0%A5%A4%20%E0%A5%AC.%E0%A5%A7.%E0%A5%A7%E0%A5%A6%E0%A5%A7,-aka%E1%B8%A5%20savar%E1%B9%87e%20d%C4%ABrgha%E1%B8%A5);
|
|
43
|
+
- ✅[`sandhi/apply-yan`](https://putout.cloudcmd.io/#/gist/3091528d3d3eb095032fbec200599df0/c4dcefa2d29fd85f9d3d768b6eaf6934fd5a3fbb): [इको यणचि](https://www.learnsanskrit.org/vyakarana/sounds/vidhi-rules);
|
|
44
|
+
- ✅[`sandhi/apply-guna`](https://putout.cloudcmd.io/#/gist/c057229cbbedf356c1d317022141f8ca/dea60bda78c84f12aef77a9e08bc17274d66c65e): [आद्गुणः](https://www.learnsanskrit.org/panini/vowel/?utm_source=chatgpt.com#:~:text=in%20ayav%C4%81y%C4%81v.-,6.1.87,-%E0%A4%86%E0%A4%A6%E0%A5%8D%E0%A4%97%E0%A5%81%E0%A4%A3%E0%A4%83);
|
|
43
45
|
|
|
44
46
|
## License
|
|
45
47
|
|
package/lib/bindu.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import putout from 'putout';
|
|
2
2
|
import Sanscript from '@indic-transliteration/sanscript';
|
|
3
|
-
import * as
|
|
3
|
+
import * as sandhi from './sandhi/index.js';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const toDevanagari = (a) => Sanscript.t(a, '
|
|
5
|
+
export const toSLP1 = (a) => Sanscript.t(a, 'devanagari', 'slp1');
|
|
6
|
+
export const toDevanagari = (a) => Sanscript.t(a, 'slp1', 'devanagari');
|
|
7
7
|
|
|
8
|
-
export const bindu = (text,
|
|
9
|
-
const
|
|
8
|
+
export const bindu = (text, overrides = {}) => {
|
|
9
|
+
const {fix = true, type} = overrides;
|
|
10
|
+
const source = toSLP1(text)
|
|
11
|
+
.replaceAll(' ', ',')
|
|
12
|
+
.replaceAll('|', '_');
|
|
13
|
+
|
|
10
14
|
const {code, places} = putout(source, {
|
|
11
15
|
fix,
|
|
12
16
|
plugins: [
|
|
13
|
-
['
|
|
17
|
+
['sandhi', sandhi],
|
|
14
18
|
],
|
|
15
19
|
});
|
|
16
20
|
|
|
@@ -18,8 +22,18 @@ export const bindu = (text, {fix = true} = {}) => {
|
|
|
18
22
|
.replaceAll(/[,;()]/g, '')
|
|
19
23
|
.slice(0, -1);
|
|
20
24
|
|
|
25
|
+
if (type === 'slp1')
|
|
26
|
+
return {
|
|
27
|
+
code: convertDashToDanda(cleanText),
|
|
28
|
+
places,
|
|
29
|
+
};
|
|
30
|
+
|
|
21
31
|
return {
|
|
22
|
-
code: toDevanagari(cleanText),
|
|
32
|
+
code: convertDashToDanda(toDevanagari(cleanText)),
|
|
23
33
|
places,
|
|
24
34
|
};
|
|
25
35
|
};
|
|
36
|
+
|
|
37
|
+
const convertDashToDanda = (a) => {
|
|
38
|
+
return a.replaceAll('_', '|');
|
|
39
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {operator} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {remove} = operator;
|
|
4
|
+
|
|
5
|
+
export const report = () => `akaḥ savarṇe dīrghaḥ`;
|
|
6
|
+
|
|
7
|
+
export const fix = ({path, next, name, nextName, dirgha}) => {
|
|
8
|
+
path.node.name = `${name.slice(0, -1)}${dirgha}${nextName.slice(-1)}`;
|
|
9
|
+
remove(next);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const traverse = ({push}) => ({
|
|
13
|
+
Identifier(path) {
|
|
14
|
+
const next = path.getNextSibling();
|
|
15
|
+
|
|
16
|
+
if (!next.node)
|
|
17
|
+
return;
|
|
18
|
+
|
|
19
|
+
const {name} = path.node;
|
|
20
|
+
const nextName = next.node.name;
|
|
21
|
+
|
|
22
|
+
const last = name
|
|
23
|
+
.at(-1)
|
|
24
|
+
.toLowerCase();
|
|
25
|
+
|
|
26
|
+
const first = nextName
|
|
27
|
+
.at(0)
|
|
28
|
+
.toLowerCase();
|
|
29
|
+
|
|
30
|
+
if (last !== first)
|
|
31
|
+
return;
|
|
32
|
+
|
|
33
|
+
const dirgha = first.toUpperCase();
|
|
34
|
+
|
|
35
|
+
push({
|
|
36
|
+
path,
|
|
37
|
+
next,
|
|
38
|
+
dirgha,
|
|
39
|
+
name,
|
|
40
|
+
nextName,
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {operator} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {remove} = operator;
|
|
4
|
+
const SANDHI = {
|
|
5
|
+
i: 'e',
|
|
6
|
+
u: 'o',
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const report = () => `ād‑guṇaḥ`;
|
|
10
|
+
|
|
11
|
+
export const fix = ({path, next, name, nextName, guna}) => {
|
|
12
|
+
path.node.name = `${name.slice(0, -1)}${guna}${nextName.slice(1)}`;
|
|
13
|
+
remove(next);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const traverse = ({push}) => ({
|
|
17
|
+
Identifier(path) {
|
|
18
|
+
const next = path.getNextSibling();
|
|
19
|
+
|
|
20
|
+
if (!next.node)
|
|
21
|
+
return;
|
|
22
|
+
|
|
23
|
+
const {name} = path.node;
|
|
24
|
+
const nextName = next.node.name;
|
|
25
|
+
|
|
26
|
+
const last = name
|
|
27
|
+
.at(-1)
|
|
28
|
+
.toLowerCase();
|
|
29
|
+
|
|
30
|
+
const first = nextName
|
|
31
|
+
.at(0)
|
|
32
|
+
.toLowerCase();
|
|
33
|
+
|
|
34
|
+
if (last !== 'a' || !/[iu]/.test(first))
|
|
35
|
+
return;
|
|
36
|
+
|
|
37
|
+
const guna = SANDHI[first];
|
|
38
|
+
|
|
39
|
+
push({
|
|
40
|
+
path,
|
|
41
|
+
next,
|
|
42
|
+
guna,
|
|
43
|
+
name,
|
|
44
|
+
nextName,
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {operator} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {remove} = operator;
|
|
4
|
+
const {keys} = Object;
|
|
5
|
+
|
|
6
|
+
const SANDHI = {
|
|
7
|
+
i: 'y',
|
|
8
|
+
u: 'v',
|
|
9
|
+
f: 'r',
|
|
10
|
+
x: 'l',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const YAN = keys(SANDHI);
|
|
14
|
+
|
|
15
|
+
const SVARA = [
|
|
16
|
+
'a',
|
|
17
|
+
'i',
|
|
18
|
+
'u',
|
|
19
|
+
'f',
|
|
20
|
+
'x',
|
|
21
|
+
'e',
|
|
22
|
+
'o',
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
export const report = () => `iko yaṇaci`;
|
|
26
|
+
|
|
27
|
+
export const fix = ({path, next, name, nextName, yan}) => {
|
|
28
|
+
path.node.name = `${name.slice(0, -1)}${yan}${nextName}`;
|
|
29
|
+
remove(next);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const traverse = ({push}) => ({
|
|
33
|
+
Identifier(path) {
|
|
34
|
+
const next = path.getNextSibling();
|
|
35
|
+
|
|
36
|
+
if (!next.node)
|
|
37
|
+
return;
|
|
38
|
+
|
|
39
|
+
const {name} = path.node;
|
|
40
|
+
const nextName = next.node.name;
|
|
41
|
+
|
|
42
|
+
const last = name
|
|
43
|
+
.at(-1)
|
|
44
|
+
.toLowerCase();
|
|
45
|
+
|
|
46
|
+
const first = nextName
|
|
47
|
+
.at(0)
|
|
48
|
+
.toLowerCase();
|
|
49
|
+
|
|
50
|
+
if (!SVARA.includes(first))
|
|
51
|
+
return;
|
|
52
|
+
|
|
53
|
+
if (!YAN.includes(last))
|
|
54
|
+
return;
|
|
55
|
+
|
|
56
|
+
const yan = SANDHI[last];
|
|
57
|
+
|
|
58
|
+
push({
|
|
59
|
+
path,
|
|
60
|
+
next,
|
|
61
|
+
name,
|
|
62
|
+
nextName,
|
|
63
|
+
yan,
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as applyGuna from './apply-guna/index.js';
|
|
2
|
+
import * as applyYan from './apply-yan/index.js';
|
|
3
|
+
import * as applyDirgha from './apply-dirgha/index.js';
|
|
4
|
+
|
|
5
|
+
export const rules = {
|
|
6
|
+
'apply-dirgha': applyDirgha,
|
|
7
|
+
'apply-yan': applyYan,
|
|
8
|
+
'apply-guna': applyGuna,
|
|
9
|
+
};
|
package/package.json
CHANGED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const {entries} = Object;
|
|
2
|
-
|
|
3
|
-
const VRIDDHI = {
|
|
4
|
-
ie: 'ye',
|
|
5
|
-
ai: 'e',
|
|
6
|
-
ia: 'ya',
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const report = ({from, to}) => `vṛddhirādaic: ${from} -> ${to}`;
|
|
10
|
-
|
|
11
|
-
export const traverse = ({push}) => ({
|
|
12
|
-
Identifier(path) {
|
|
13
|
-
const {name} = path.node;
|
|
14
|
-
|
|
15
|
-
for (const [from, to] of entries(VRIDDHI)) {
|
|
16
|
-
if (name.includes(from)) {
|
|
17
|
-
push({
|
|
18
|
-
path,
|
|
19
|
-
from,
|
|
20
|
-
to,
|
|
21
|
-
});
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
export function fix({path, from, to}) {
|
|
29
|
-
const {name} = path.node;
|
|
30
|
-
path.node.name = name.replace(from, to);
|
|
31
|
-
}
|