Skip to content

Commit 05b88e0

Browse files
committed
feature: bindu: sandhi: ac: apply-eco-yavayava: add
1 parent bb5a365 commit 05b88e0

File tree

10 files changed

+134
-5
lines changed

10 files changed

+134
-5
lines changed

.putout.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
"putout/declare": "off"
1010
}
1111
},
12-
"ignore": ["templates"]
12+
"ignore": ["templates", "dictionary"]
1313
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ places[0].message;
5454
-[`ac/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)
5555
-[`ac/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)
5656
-[`ac/apply-padantad`](https://putout.cloudcmd.io/#/gist/f73f49bf102a6f2ab34a100ee29f81cc/6b1c3f1595841a08a035437924165e4b8d27896d): [एङः पदान्तादति](https://www.gingersunrise.com/i/133147357/एङ-पदनतदत);
57+
-[`ac/apply-ec-yava-yava`](https://putout.cloudcmd.io/#/gist/102fc8086d28f5d5431272c0402b80c2/44cf7b6cdeb9a0c240d6627710a824598cdd9696): [एचोऽयवायावः](https://ashtadhyayi.com/sutraani/6/1/78);
5758

5859
#### visarga
5960

lib/pratipadika.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import stems from '../dictionary/stems.json' with {
2+
type: 'json',
3+
};
4+
5+
export const praptaPratapadika = (a) => stems[a];

lib/pratyahara.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
const ec = [
2+
'e',
3+
'o',
4+
'ai',
5+
'au',
6+
];
17
const ac = [
28
'a',
39
'i',
410
'u',
511
'f',
612
'x',
7-
'e',
8-
'o',
9-
'ai',
10-
'au',
13+
...ec,
1114
];
1215

1316
const khar = [
@@ -23,4 +26,5 @@ const khar = [
2326
const createAsti = (a) => (b) => a.includes(b.toLowerCase());
2427

2528
export const astiAc = createAsti(ac);
29+
export const astiEc = createAsti(ec);
2630
export const astiKhar = createAsti(khar);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
(tayasti);
2+
(gaviti);
3+
(te, eti);
4+
(naAyiti);
5+
(naAvupagacchati);
6+
(rAme, atra);
7+
(nai, pathaḥ);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
te, asti;
2+
go, iti;
3+
te, eti;
4+
nai, iti;
5+
nau, upagacchati;
6+
rAme, atra;
7+
nai, pathaḥ;
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import {operator} from 'putout';
2+
import {astiAc, astiEc} from '../../../pratyahara.js';
3+
import {praptaPratapadika} from '../../../pratipadika.js';
4+
5+
const {remove} = operator;
6+
7+
export const report = () => `eco yavāyāvaḥ`;
8+
9+
export const fix = ({path, next, name, nextName}) => {
10+
if (name.endsWith('e')) {
11+
path.node.name = `${name.slice(0, -1)}ay${nextName}`;
12+
remove(next);
13+
14+
return;
15+
}
16+
17+
if (name.endsWith('o')) {
18+
path.node.name = `${name.slice(0, -1)}av${nextName}`;
19+
remove(next);
20+
21+
return;
22+
}
23+
24+
if (name.endsWith('ai')) {
25+
path.node.name = `${name.slice(0, -1)}Ay${nextName}`;
26+
remove(next);
27+
28+
return;
29+
}
30+
31+
if (name.endsWith('au')) {
32+
path.node.name = `${name.slice(0, -1)}Av${nextName}`;
33+
remove(next);
34+
35+
return;
36+
}
37+
};
38+
39+
export const traverse = ({push}) => ({
40+
Identifier(path) {
41+
const next = path.getNextSibling();
42+
43+
if (!next.node)
44+
return;
45+
46+
const {name} = path.node;
47+
48+
const nextName = next.node.name;
49+
const first = nextName.at(0);
50+
const last = name.at(-1);
51+
const preLast = name.at(-2);
52+
53+
if (!astiEc(last) && !astiEc(preLast + last))
54+
return;
55+
56+
if (!astiAc(first))
57+
return;
58+
59+
if (first === 'e' && first === last)
60+
return;
61+
62+
const stem = praptaPratapadika(name);
63+
64+
if (stem && stem !== name)
65+
return;
66+
67+
push({
68+
path,
69+
next,
70+
name,
71+
nextName,
72+
});
73+
},
74+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {createTest} from '@putout/test';
2+
import * as plugin from './index.js';
3+
4+
const test = createTest(import.meta.url, {
5+
plugins: [
6+
['apply-eco-yavayava', plugin],
7+
],
8+
});
9+
10+
test('sandhi: apply-eco-yavayava: report', (t) => {
11+
t.report('apply-eco-yavayava', `eco yavāyāvaḥ`);
12+
t.end();
13+
});
14+
15+
test('sandhi: apply-eco-yavayava: transform', (t) => {
16+
t.transform('apply-eco-yavayava');
17+
t.end();
18+
});

lib/sandhi/ac/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as applyEcoYavayava from './apply-eco-yavayava/index.js';
12
import * as applyPadantad from './apply-padantad/index.js';
23
import * as applyAyadaya from './apply-ayadaya/index.js';
34
import * as applyPurvarupa from './apply-purvarupa/index.js';
@@ -14,4 +15,5 @@ export const rules = {
1415
'apply-purvarupa': applyPurvarupa,
1516
'apply-ayadaya': applyAyadaya,
1617
'apply-padantad': applyPadantad,
18+
'apply-eco-yavayava': applyEcoYavayava,
1719
};

test/bindu.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@ test('bindu: sandhi: kharovasana', (t) => {
127127
t.end();
128128
});
129129

130+
test('bindu: sandhi: ac: ec-yava-yava', (t) => {
131+
const {code} = bindu('nai iti', {
132+
type: 'slp1',
133+
});
134+
135+
const expected = `nayiti`;
136+
137+
t.equal(code, expected);
138+
t.end();
139+
});
140+
130141
test('bindu: sandhi: bhobhago', (t) => {
131142
const {code} = bindu('namaH asti', {
132143
type: 'slp1',

0 commit comments

Comments
 (0)