bindu 1.4.1 → 1.5.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 +7 -0
- package/README.md +12 -4
- package/lib/bindu.js +5 -17
- package/lib/process.js +17 -0
- package/lib/sandhi/apply-ayadaya/index.js +46 -0
- package/lib/sandhi/index.js +2 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -41,11 +41,19 @@ places[0].message;
|
|
|
41
41
|
|
|
42
42
|
### Sandhi
|
|
43
43
|
|
|
44
|
-
- ✅[`sandhi/apply-dirgha`](https://putout.cloudcmd.io/#/gist/0ad8154614be489ae50931109618100a/5ce86f7344b37fd40afeb229e6cb1f668d4f92fd): [अकः सवर्णे दीर्घः](https://www.learnsanskrit.org/vyakarana/sounds/ac-sandhi
|
|
44
|
+
- ✅[`sandhi/apply-dirgha`](https://putout.cloudcmd.io/#/gist/0ad8154614be489ae50931109618100a/5ce86f7344b37fd40afeb229e6cb1f668d4f92fd): [अकः सवर्णे दीर्घः](https://www.learnsanskrit.org/vyakarana/sounds/ac-sandhi/#:~: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);
|
|
45
45
|
- ✅[`sandhi/apply-yan`](https://putout.cloudcmd.io/#/gist/3091528d3d3eb095032fbec200599df0/c4dcefa2d29fd85f9d3d768b6eaf6934fd5a3fbb): [इको यणचि](https://www.learnsanskrit.org/vyakarana/sounds/vidhi-rules);
|
|
46
|
-
- ✅[`sandhi/apply-guna`](https://putout.cloudcmd.io/#/gist/c057229cbbedf356c1d317022141f8ca/dea60bda78c84f12aef77a9e08bc17274d66c65e): [आद्गुणः](https://www.learnsanskrit.org/panini/vowel
|
|
47
|
-
- ✅[`sandhi/apply-vriddhi`](https://putout.cloudcmd.io/#/gist/7cdc2383c74d7afeb8cfd93df7b5f868/79b1c979be725fc082cf81991b16fac527cfcd7b): [वृद्धिरेचि](https://www.learnsanskrit.org/panini/vowel
|
|
48
|
-
- ✅[`sandhi/apply-purvarupa`](https://putout.cloudcmd.io/#/gist/23e2b612a185529ea6823e5f81d35b7d/2ace30ac469be03af1c41911b78d85e85b9a1120): [एकः पूर्वपरयोः](https://www.learnsanskrit.org/panini/vowel
|
|
46
|
+
- ✅[`sandhi/apply-guna`](https://putout.cloudcmd.io/#/gist/c057229cbbedf356c1d317022141f8ca/dea60bda78c84f12aef77a9e08bc17274d66c65e): [आद्गुणः](https://www.learnsanskrit.org/panini/vowel/#:~: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);
|
|
47
|
+
- ✅[`sandhi/apply-vriddhi`](https://putout.cloudcmd.io/#/gist/7cdc2383c74d7afeb8cfd93df7b5f868/79b1c979be725fc082cf81991b16fac527cfcd7b): [वृद्धिरेचि](https://www.learnsanskrit.org/panini/vowel/#:~: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/#:~: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
|
+
- ✅[`sandhi/apply-ayadaya`](https://putout.cloudcmd.io/#/gist/39db56c40174f61caed795c2a2dc89a7/dc956c6b0834167d9814ba70036674f4a10f56f9): [आयादयः](https://www.learnsanskrit.org/references/sandhi/vowel/#:~:text=madhu%20iva%20%E2%86%92%20madhviva-,Now,-%2C%20some%20examples%20for)
|
|
50
|
+
|
|
51
|
+
#### apply-ayadaya
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
भोअति → भवति
|
|
55
|
+
bhoati → bhavati
|
|
56
|
+
```
|
|
49
57
|
|
|
50
58
|
#### apply-dirgha
|
|
51
59
|
|
package/lib/bindu.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
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 {
|
|
4
|
+
import {postProcess, preProcess} from './process.js';
|
|
5
5
|
|
|
6
6
|
export const toSLP1 = (a) => Sanscript.t(a, 'devanagari', 'slp1');
|
|
7
7
|
export const toDevanagari = (a) => Sanscript.t(a, 'slp1', 'devanagari');
|
|
8
8
|
|
|
9
9
|
export const bindu = (text, overrides = {}) => {
|
|
10
10
|
const {fix = true, type} = overrides;
|
|
11
|
-
const source =
|
|
12
|
-
.replaceAll(' ', ',')
|
|
13
|
-
.replaceAll(avagraha.spl1, avagraha.code)
|
|
14
|
-
.replaceAll(danda.spl1, danda.code);
|
|
11
|
+
const source = preProcess(text);
|
|
15
12
|
|
|
16
13
|
const {code, places} = putout(source, {
|
|
17
14
|
fix,
|
|
@@ -20,25 +17,16 @@ export const bindu = (text, overrides = {}) => {
|
|
|
20
17
|
],
|
|
21
18
|
});
|
|
22
19
|
|
|
23
|
-
const cleanText = code
|
|
24
|
-
.replaceAll(/[,;()]/g, '')
|
|
25
|
-
.replaceAll(avagraha.code, avagraha.spl1)
|
|
26
|
-
.replaceAll(danda.code, danda.spl1)
|
|
27
|
-
.slice(0, -1);
|
|
20
|
+
const cleanText = postProcess(code);
|
|
28
21
|
|
|
29
22
|
if (type === 'slp1')
|
|
30
23
|
return {
|
|
31
|
-
code:
|
|
24
|
+
code: cleanText,
|
|
32
25
|
places,
|
|
33
26
|
};
|
|
34
27
|
|
|
35
28
|
return {
|
|
36
|
-
code:
|
|
29
|
+
code: toDevanagari(cleanText),
|
|
37
30
|
places,
|
|
38
31
|
};
|
|
39
32
|
};
|
|
40
|
-
|
|
41
|
-
const convertDashToDanda = (a) => {
|
|
42
|
-
return a.replaceAll(danda.code, danda.devanagari);
|
|
43
|
-
};
|
|
44
|
-
|
package/lib/process.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {toSLP1} from './bindu.js';
|
|
2
|
+
import {avagraha, danda} from './symbols.js';
|
|
3
|
+
|
|
4
|
+
export const preProcess = (text) => {
|
|
5
|
+
return toSLP1(text)
|
|
6
|
+
.replaceAll(' ', ',')
|
|
7
|
+
.replaceAll(avagraha.spl1, avagraha.code)
|
|
8
|
+
.replaceAll(danda.spl1, danda.code);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const postProcess = (code) => {
|
|
12
|
+
return code
|
|
13
|
+
.replaceAll(/[,;()]/g, '')
|
|
14
|
+
.replaceAll(avagraha.code, avagraha.spl1)
|
|
15
|
+
.replaceAll(danda.code, danda.spl1)
|
|
16
|
+
.slice(0, -1);
|
|
17
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {operator} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {remove} = operator;
|
|
4
|
+
const SANDHI = {
|
|
5
|
+
e: 'aya',
|
|
6
|
+
o: 'ava',
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const report = () => `ayādayaḥ`;
|
|
10
|
+
|
|
11
|
+
export const fix = ({path, next, name, nextName}) => {
|
|
12
|
+
const joint = SANDHI[nextName];
|
|
13
|
+
|
|
14
|
+
path.node.name = `${name.slice(0, -1)}${joint}${nextName.slice(1)}`;
|
|
15
|
+
remove(next);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const traverse = ({push}) => ({
|
|
19
|
+
Identifier(path) {
|
|
20
|
+
const next = path.getNextSibling();
|
|
21
|
+
|
|
22
|
+
if (!next.node)
|
|
23
|
+
return;
|
|
24
|
+
|
|
25
|
+
const {name} = path.node;
|
|
26
|
+
const nextName = next.node.name;
|
|
27
|
+
|
|
28
|
+
const last = name
|
|
29
|
+
.at(-1)
|
|
30
|
+
.toLowerCase();
|
|
31
|
+
|
|
32
|
+
const first = nextName
|
|
33
|
+
.at(0)
|
|
34
|
+
.toLowerCase();
|
|
35
|
+
|
|
36
|
+
if (last !== 'a' || !/[eo]/.test(first))
|
|
37
|
+
return;
|
|
38
|
+
|
|
39
|
+
push({
|
|
40
|
+
path,
|
|
41
|
+
next,
|
|
42
|
+
name,
|
|
43
|
+
nextName,
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
});
|
package/lib/sandhi/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as applyAyadaya from './apply-ayadaya/index.js';
|
|
1
2
|
import * as applyPurvarupa from './apply-purvarupa/index.js';
|
|
2
3
|
import * as applyVriddhi from './apply-vriddhi/index.js';
|
|
3
4
|
import * as applyGuna from './apply-guna/index.js';
|
|
@@ -10,4 +11,5 @@ export const rules = {
|
|
|
10
11
|
'apply-guna': applyGuna,
|
|
11
12
|
'apply-vriddhi': applyVriddhi,
|
|
12
13
|
'apply-purvarupa': applyPurvarupa,
|
|
14
|
+
'apply-ayadaya': applyAyadaya,
|
|
13
15
|
};
|