bindu 1.4.0 → 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 CHANGED
@@ -1,3 +1,15 @@
1
+ 2025.12.11, v1.5.0
2
+
3
+ feature:
4
+ - 4b99ad6 bindu: sandhi: ayadaya: add
5
+ - 173c577 bindu: process: add
6
+ - 0941b75 bindu: remove useless convertDashToDanda
7
+
8
+ 2025.12.11, v1.4.1
9
+
10
+ feature:
11
+ - 7a23422 bindu: symbols: add
12
+
1
13
  2025.12.10, v1.4.0
2
14
 
3
15
  feature:
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/?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);
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/?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);
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)
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
 
@@ -63,6 +71,22 @@ u + u → ū
63
71
  ṛ + ṛ → ṝ
64
72
  ```
65
73
 
74
+ #### apply-purvarupa
75
+
76
+ ```
77
+ ए + अ → ए
78
+ e + a → e
79
+
80
+ ओ + अ → ओ
81
+ o + a → o
82
+ ```
83
+
84
+ Example:
85
+
86
+ ```
87
+ अन्ते + अपि → अन्तेऽपि
88
+ ```
89
+
66
90
  ## License
67
91
 
68
92
  MIT
package/lib/bindu.js CHANGED
@@ -1,15 +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 {postProcess, preProcess} from './process.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');
7
8
 
8
9
  export const bindu = (text, overrides = {}) => {
9
10
  const {fix = true, type} = overrides;
10
- const source = toSLP1(text)
11
- .replaceAll(' ', ',')
12
- .replaceAll('|', '_');
11
+ const source = preProcess(text);
13
12
 
14
13
  const {code, places} = putout(source, {
15
14
  fix,
@@ -18,22 +17,16 @@ export const bindu = (text, overrides = {}) => {
18
17
  ],
19
18
  });
20
19
 
21
- const cleanText = code
22
- .replaceAll(/[,;()]/g, '')
23
- .slice(0, -1);
20
+ const cleanText = postProcess(code);
24
21
 
25
22
  if (type === 'slp1')
26
23
  return {
27
- code: convertDashToDanda(cleanText),
24
+ code: cleanText,
28
25
  places,
29
26
  };
30
27
 
31
28
  return {
32
- code: convertDashToDanda(toDevanagari(cleanText)),
29
+ code: toDevanagari(cleanText),
33
30
  places,
34
31
  };
35
32
  };
36
-
37
- const convertDashToDanda = (a) => {
38
- return a.replaceAll('_', '|');
39
- };
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
+ });
@@ -1,11 +1,12 @@
1
1
  import {operator} from 'putout';
2
+ import {avagraha} from '../../symbols.js';
2
3
 
3
4
  const {remove} = operator;
4
5
 
5
6
  export const report = () => `ekaḥ pūrvaparayoḥ`;
6
7
 
7
8
  export const fix = ({path, next, name, nextName}) => {
8
- path.node.name = `${name}'${nextName.slice(1)}`;
9
+ path.node.name = `${name}${avagraha.code}${nextName.slice(1)}`;
9
10
  remove(next);
10
11
  };
11
12
 
@@ -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
  };
package/lib/symbols.js ADDED
@@ -0,0 +1,11 @@
1
+ export const avagraha = {
2
+ devanagari: 'ऽ',
3
+ spl1: `'`,
4
+ code: '__avagraha__',
5
+ };
6
+
7
+ export const danda = {
8
+ devanagari: '|',
9
+ spl1: '|',
10
+ code: '__danda__',
11
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bindu",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Pāṇini Aṣṭādhyāyī",
5
5
  "main": "lib/bindu.js",
6
6
  "bin": {