bindu 1.4.1 → 1.6.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.12, v1.6.0
2
+
3
+ feature:
4
+ - d4f2d69 bindu: avyaya: add
5
+
6
+ 2025.12.11, v1.5.0
7
+
8
+ feature:
9
+ - 4b99ad6 bindu: sandhi: ayadaya: add
10
+ - 173c577 bindu: process: add
11
+ - 0941b75 bindu: remove useless convertDashToDanda
12
+
1
13
  2025.12.11, v1.4.1
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
 
@@ -0,0 +1,7 @@
1
+ export const demonstratives = {
2
+ ayam: 'this (masculine singular)',
3
+ iyam: 'this (feminine singular)',
4
+ ayaM: 'this (dual)',
5
+ eso: 'this (masculine singular, near)',
6
+ esaU: 'this (feminine singular, near)',
7
+ };
@@ -0,0 +1,15 @@
1
+ import {particles} from './particles.js';
2
+ import {pronouns} from './pronouns.js';
3
+ import {demonstratives} from './demonstratives.js';
4
+
5
+ const {keys} = Object;
6
+
7
+ const avyaya = new Set([
8
+ ...keys(particles),
9
+ ...keys(pronouns),
10
+ ...keys(demonstratives),
11
+ ]);
12
+
13
+ export const avyayamAsti = (a) => {
14
+ return avyaya.has(a);
15
+ };
@@ -0,0 +1,22 @@
1
+ export const particles = {
2
+ iti: 'thus, so',
3
+ iha: 'here',
4
+ api: 'also, even',
5
+ ca: 'and',
6
+ eva: 'indeed, certainly',
7
+ hi: 'surely, indeed',
8
+ vā: 'or',
9
+ tu: 'but',
10
+ na: 'not',
11
+ vA: 'or (alternative form of vā)',
12
+ tathA: 'thus, in that way',
13
+ kintu: 'but, however',
14
+ atha: 'then, now',
15
+ athaApi: 'and also then',
16
+ athaiva: 'then only, just then',
17
+ atara: 'however, but',
18
+ evaM: 'thus, in this way',
19
+ tvam: 'you (used as particle sometimes)',
20
+ yad: 'if',
21
+ yatra: 'where',
22
+ };
@@ -0,0 +1,22 @@
1
+ export const pronouns = {
2
+ aham: 'I',
3
+ tvam: 'you (singular)',
4
+ asmad: 'we (exclusive)',
5
+ yuSmad: 'you (plural)',
6
+ saH: 'he',
7
+ sA: 'she',
8
+ so: 'he (alternate form)',
9
+ saU: 'she (alternate form)',
10
+ yad: 'who, which',
11
+ yam: 'whom',
12
+ yUyam: 'you (plural)',
13
+ asmAkaM: 'our',
14
+ yuSmAkaM: 'your (plural)',
15
+ te: 'they (dual/plural)',
16
+ teSu: 'them (plural)',
17
+ tasya: 'his',
18
+ tasmin: 'in him',
19
+ tasyaH: 'of him',
20
+ asmai: 'to me',
21
+ tve: 'to you',
22
+ };
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 {danda, avagraha} from './symbols.js';
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 = toSLP1(text)
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: convertDashToDanda(cleanText),
24
+ code: cleanText,
32
25
  places,
33
26
  };
34
27
 
35
28
  return {
36
- code: convertDashToDanda(toDevanagari(cleanText)),
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,56 @@
1
+ import {operator} from 'putout';
2
+ import {avagraha} from '../../symbols.js';
3
+
4
+ const {remove} = operator;
5
+
6
+ export const report = () => `ayādayaḥ`;
7
+
8
+ export const fix = ({path, next, name, nextName}) => {
9
+ const joint = createJoint(name, nextName);
10
+
11
+ path.node.name = `${name.slice(0, -1)}${joint}${nextName.slice(1)}`;
12
+ remove(next);
13
+ };
14
+
15
+ export const traverse = ({push}) => ({
16
+ Identifier(path) {
17
+ const next = path.getNextSibling();
18
+
19
+ if (!next.node)
20
+ return;
21
+
22
+ const {name} = path.node;
23
+ const nextName = next.node.name;
24
+
25
+ const last = name
26
+ .at(-1)
27
+ .toLowerCase();
28
+
29
+ const first = nextName
30
+ .at(0)
31
+ .toLowerCase();
32
+
33
+ if (!/[aiueo]/.test(last) || !/[aiueo]/.test(first))
34
+ return;
35
+
36
+ push({
37
+ path,
38
+ next,
39
+ name,
40
+ nextName,
41
+ });
42
+ },
43
+ });
44
+
45
+ function createJoint(name, nextName) {
46
+ if (name.endsWith('a') && nextName.startsWith('e'))
47
+ return 'aye';
48
+
49
+ if (name.endsWith('a') && nextName.startsWith('o'))
50
+ return 'ayau';
51
+
52
+ if (name.endsWith('e') && nextName.startsWith('a'))
53
+ return `e${avagraha.code}`;
54
+
55
+ return '';
56
+ }
@@ -1,4 +1,5 @@
1
1
  import {operator} from 'putout';
2
+ import {avyayamAsti} from '#avyaya';
2
3
 
3
4
  const {remove} = operator;
4
5
 
@@ -19,6 +20,9 @@ export const traverse = ({push}) => ({
19
20
  const {name} = path.node;
20
21
  const nextName = next.node.name;
21
22
 
23
+ if (avyayamAsti(nextName))
24
+ return;
25
+
22
26
  const last = name
23
27
  .at(-1)
24
28
  .toLowerCase();
@@ -1,12 +1,12 @@
1
1
  import {operator} from 'putout';
2
- import {avagraha} from '../../symbols.js';
2
+ import {avyayamAsti} from '#avyaya';
3
3
 
4
4
  const {remove} = operator;
5
5
 
6
6
  export const report = () => `ekaḥ pūrvaparayoḥ`;
7
7
 
8
8
  export const fix = ({path, next, name, nextName}) => {
9
- path.node.name = `${name}${avagraha.code}${nextName.slice(1)}`;
9
+ path.node.name = `${name}${nextName.slice(1)}`;
10
10
  remove(next);
11
11
  };
12
12
 
@@ -28,7 +28,10 @@ export const traverse = ({push}) => ({
28
28
  .at(0)
29
29
  .toLowerCase();
30
30
 
31
- if (first !== 'a' || !/[eo]/.test(last))
31
+ if (!avyayamAsti(nextName))
32
+ return;
33
+
34
+ if (!/[aiueo]/.test(last) || first === 'a' && last === 'e')
32
35
  return;
33
36
 
34
37
  push({
@@ -1,15 +1,11 @@
1
1
  import {operator} from 'putout';
2
2
 
3
3
  const {remove} = operator;
4
- const SANDHI = {
5
- e: 'ai',
6
- o: 'au',
7
- };
8
4
 
9
5
  export const report = () => `vṛddhireci`;
10
6
 
11
- export const fix = ({path, next, name, nextName, vriddhi}) => {
12
- path.node.name = `${name.slice(0, -1)}${vriddhi}${nextName.slice(1)}`;
7
+ export const fix = ({path, next, name, nextName}) => {
8
+ path.node.name = `${name.slice(0, -1)}A${nextName.slice(1)}`;
13
9
  remove(next);
14
10
  };
15
11
 
@@ -27,19 +23,14 @@ export const traverse = ({push}) => ({
27
23
  .at(-1)
28
24
  .toLowerCase();
29
25
 
30
- const first = nextName
31
- .at(0)
32
- .toLowerCase();
26
+ const [first, second] = nextName;
33
27
 
34
- if (last !== 'a' || !/[eo]/.test(first))
28
+ if (last !== 'a' || first !== 'a' || !/[iu]/.test(second))
35
29
  return;
36
30
 
37
- const vriddhi = SANDHI[first];
38
-
39
31
  push({
40
32
  path,
41
33
  next,
42
- vriddhi,
43
34
  name,
44
35
  nextName,
45
36
  });
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bindu",
3
- "version": "1.4.1",
3
+ "version": "1.6.0",
4
4
  "description": "Pāṇini Aṣṭādhyāyī",
5
5
  "main": "lib/bindu.js",
6
6
  "bin": {
@@ -41,6 +41,11 @@
41
41
  "engines": {
42
42
  "node": ">=20"
43
43
  },
44
+ "imports": {
45
+ "#avyaya": {
46
+ "default": "./lib/avyaya/index.js"
47
+ }
48
+ },
44
49
  "dependencies": {
45
50
  "@indic-transliteration/sanscript": "^1.3.3",
46
51
  "putout": "^41.0.0"