bindu 1.3.0 → 1.4.1
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 +10 -0
- package/README.md +35 -0
- package/lib/bindu.js +7 -2
- package/lib/sandhi/apply-purvarupa/index.js +41 -0
- package/lib/sandhi/index.js +2 -0
- package/lib/symbols.js +11 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -39,10 +39,45 @@ places[0].message;
|
|
|
39
39
|
|
|
40
40
|
## Rules
|
|
41
41
|
|
|
42
|
+
### Sandhi
|
|
43
|
+
|
|
42
44
|
- ✅[`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
45
|
- ✅[`sandhi/apply-yan`](https://putout.cloudcmd.io/#/gist/3091528d3d3eb095032fbec200599df0/c4dcefa2d29fd85f9d3d768b6eaf6934fd5a3fbb): [इको यणचि](https://www.learnsanskrit.org/vyakarana/sounds/vidhi-rules);
|
|
44
46
|
- ✅[`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);
|
|
45
47
|
- ✅[`sandhi/apply-vriddhi`](https://putout.cloudcmd.io/#/gist/7cdc2383c74d7afeb8cfd93df7b5f868/79b1c979be725fc082cf81991b16fac527cfcd7b): [वृद्धिरेचि](https://www.learnsanskrit.org/panini/vowel/?utm_source=chatgpt.com#:~:text=and%20%C4%81.-,6.1.88,-%E0%A4%B5%E0%A5%83%E0%A4%A6%E0%A5%8D%E0%A4%A7%E0%A4%BF%E0%A4%B0%E0%A5%87%E0%A4%9A%E0%A4%BF);
|
|
48
|
+
- ✅[`sandhi/apply-purvarupa`](https://putout.cloudcmd.io/#/gist/23e2b612a185529ea6823e5f81d35b7d/2ace30ac469be03af1c41911b78d85e85b9a1120): [एकः पूर्वपरयोः](https://www.learnsanskrit.org/panini/vowel/?utm_source=chatgpt.com#:~:text=this%20rule%20mean%3F-,%E0%A4%8F%E0%A4%95%E0%A4%83%20%E0%A4%AA%E0%A5%82%E0%A4%B0%E0%A5%8D%E0%A4%B5%E0%A4%AA%E0%A4%B0%E0%A4%AF%E0%A5%8B%E0%A4%83,-eka%E1%B8%A5%20p%C5%ABrvaparayo%E1%B8%A5)
|
|
49
|
+
|
|
50
|
+
#### apply-dirgha
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
अ + अ → आ
|
|
54
|
+
a + a → ā
|
|
55
|
+
|
|
56
|
+
इ + इ → ई
|
|
57
|
+
i + i → ī
|
|
58
|
+
|
|
59
|
+
उ + उ → ऊ
|
|
60
|
+
u + u → ū
|
|
61
|
+
|
|
62
|
+
ऋ + ऋ → ॠ
|
|
63
|
+
ṛ + ṛ → ṝ
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### apply-purvarupa
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
ए + अ → ए
|
|
70
|
+
e + a → e
|
|
71
|
+
|
|
72
|
+
ओ + अ → ओ
|
|
73
|
+
o + a → o
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Example:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
अन्ते + अपि → अन्तेऽपि
|
|
80
|
+
```
|
|
46
81
|
|
|
47
82
|
## License
|
|
48
83
|
|
package/lib/bindu.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import putout from 'putout';
|
|
2
2
|
import Sanscript from '@indic-transliteration/sanscript';
|
|
3
3
|
import * as sandhi from './sandhi/index.js';
|
|
4
|
+
import {danda, avagraha} from './symbols.js';
|
|
4
5
|
|
|
5
6
|
export const toSLP1 = (a) => Sanscript.t(a, 'devanagari', 'slp1');
|
|
6
7
|
export const toDevanagari = (a) => Sanscript.t(a, 'slp1', 'devanagari');
|
|
@@ -9,7 +10,8 @@ export const bindu = (text, overrides = {}) => {
|
|
|
9
10
|
const {fix = true, type} = overrides;
|
|
10
11
|
const source = toSLP1(text)
|
|
11
12
|
.replaceAll(' ', ',')
|
|
12
|
-
.replaceAll(
|
|
13
|
+
.replaceAll(avagraha.spl1, avagraha.code)
|
|
14
|
+
.replaceAll(danda.spl1, danda.code);
|
|
13
15
|
|
|
14
16
|
const {code, places} = putout(source, {
|
|
15
17
|
fix,
|
|
@@ -20,6 +22,8 @@ export const bindu = (text, overrides = {}) => {
|
|
|
20
22
|
|
|
21
23
|
const cleanText = code
|
|
22
24
|
.replaceAll(/[,;()]/g, '')
|
|
25
|
+
.replaceAll(avagraha.code, avagraha.spl1)
|
|
26
|
+
.replaceAll(danda.code, danda.spl1)
|
|
23
27
|
.slice(0, -1);
|
|
24
28
|
|
|
25
29
|
if (type === 'slp1')
|
|
@@ -35,5 +39,6 @@ export const bindu = (text, overrides = {}) => {
|
|
|
35
39
|
};
|
|
36
40
|
|
|
37
41
|
const convertDashToDanda = (a) => {
|
|
38
|
-
return a.replaceAll(
|
|
42
|
+
return a.replaceAll(danda.code, danda.devanagari);
|
|
39
43
|
};
|
|
44
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {operator} from 'putout';
|
|
2
|
+
import {avagraha} from '../../symbols.js';
|
|
3
|
+
|
|
4
|
+
const {remove} = operator;
|
|
5
|
+
|
|
6
|
+
export const report = () => `ekaḥ pūrvaparayoḥ`;
|
|
7
|
+
|
|
8
|
+
export const fix = ({path, next, name, nextName}) => {
|
|
9
|
+
path.node.name = `${name}${avagraha.code}${nextName.slice(1)}`;
|
|
10
|
+
remove(next);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const traverse = ({push}) => ({
|
|
14
|
+
Identifier(path) {
|
|
15
|
+
const next = path.getNextSibling();
|
|
16
|
+
|
|
17
|
+
if (!next.node)
|
|
18
|
+
return;
|
|
19
|
+
|
|
20
|
+
const {name} = path.node;
|
|
21
|
+
const nextName = next.node.name;
|
|
22
|
+
|
|
23
|
+
const last = name
|
|
24
|
+
.at(-1)
|
|
25
|
+
.toLowerCase();
|
|
26
|
+
|
|
27
|
+
const first = nextName
|
|
28
|
+
.at(0)
|
|
29
|
+
.toLowerCase();
|
|
30
|
+
|
|
31
|
+
if (first !== 'a' || !/[eo]/.test(last))
|
|
32
|
+
return;
|
|
33
|
+
|
|
34
|
+
push({
|
|
35
|
+
path,
|
|
36
|
+
next,
|
|
37
|
+
name,
|
|
38
|
+
nextName,
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
});
|
package/lib/sandhi/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as applyPurvarupa from './apply-purvarupa/index.js';
|
|
1
2
|
import * as applyVriddhi from './apply-vriddhi/index.js';
|
|
2
3
|
import * as applyGuna from './apply-guna/index.js';
|
|
3
4
|
import * as applyYan from './apply-yan/index.js';
|
|
@@ -8,4 +9,5 @@ export const rules = {
|
|
|
8
9
|
'apply-yan': applyYan,
|
|
9
10
|
'apply-guna': applyGuna,
|
|
10
11
|
'apply-vriddhi': applyVriddhi,
|
|
12
|
+
'apply-purvarupa': applyPurvarupa,
|
|
11
13
|
};
|
package/lib/symbols.js
ADDED