bindu 1.5.0 → 1.7.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 +13 -0
- package/README.md +6 -1
- package/lib/avyaya/demonstratives.js +7 -0
- package/lib/avyaya/index.js +15 -0
- package/lib/avyaya/particles.js +22 -0
- package/lib/avyaya/pronouns.js +22 -0
- package/lib/bindu.js +7 -0
- package/lib/sandhi/apply-ayadaya/index.js +15 -15
- package/lib/sandhi/apply-dirgha/index.js +4 -0
- package/lib/sandhi/apply-purvarupa/index.js +6 -3
- package/lib/sandhi/apply-vriddhi/index.js +4 -13
- package/package.json +6 -1
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -27,7 +27,12 @@ npm i bindu -g
|
|
|
27
27
|
import {bindu} from 'bindu';
|
|
28
28
|
|
|
29
29
|
bindu('प्रतिएक');
|
|
30
|
-
// returns {code: 'प्रत्येक'
|
|
30
|
+
// returns {code: 'प्रत्येक'}
|
|
31
|
+
|
|
32
|
+
bindu('द्रौपदी अश्वम्', {
|
|
33
|
+
type: 'iast',
|
|
34
|
+
});
|
|
35
|
+
// returns {code: 'draupadyaśvam'}
|
|
31
36
|
|
|
32
37
|
const {places} = bindu('प्रतिएक', {
|
|
33
38
|
fix: false,
|
|
@@ -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
|
@@ -5,6 +5,7 @@ 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
|
+
export const toIAST = (a) => Sanscript.t(a, 'slp1', 'iast');
|
|
8
9
|
|
|
9
10
|
export const bindu = (text, overrides = {}) => {
|
|
10
11
|
const {fix = true, type} = overrides;
|
|
@@ -25,6 +26,12 @@ export const bindu = (text, overrides = {}) => {
|
|
|
25
26
|
places,
|
|
26
27
|
};
|
|
27
28
|
|
|
29
|
+
if (type === 'iast')
|
|
30
|
+
return {
|
|
31
|
+
code: toIAST(cleanText),
|
|
32
|
+
places,
|
|
33
|
+
};
|
|
34
|
+
|
|
28
35
|
return {
|
|
29
36
|
code: toDevanagari(cleanText),
|
|
30
37
|
places,
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import {operator} from 'putout';
|
|
2
2
|
|
|
3
3
|
const {remove} = operator;
|
|
4
|
-
const SANDHI = {
|
|
5
|
-
e: 'aya',
|
|
6
|
-
o: 'ava',
|
|
7
|
-
};
|
|
8
4
|
|
|
9
5
|
export const report = () => `ayādayaḥ`;
|
|
10
6
|
|
|
11
7
|
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
8
|
remove(next);
|
|
9
|
+
|
|
10
|
+
if (nextName.startsWith('a')) {
|
|
11
|
+
path.node.name = `${name}${nextName.slice(1)}`;
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (nextName.startsWith('ya')) {
|
|
16
|
+
path.node.name = `${name.slice(0, -1)}${nextName.slice(1)}`;
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
path.node.name = `${name.slice(0, -1)}i${nextName.slice(1)}`;
|
|
16
21
|
};
|
|
17
22
|
|
|
18
23
|
export const traverse = ({push}) => ({
|
|
@@ -25,15 +30,10 @@ export const traverse = ({push}) => ({
|
|
|
25
30
|
const {name} = path.node;
|
|
26
31
|
const nextName = next.node.name;
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
.toLowerCase();
|
|
31
|
-
|
|
32
|
-
const first = nextName
|
|
33
|
-
.at(0)
|
|
34
|
-
.toLowerCase();
|
|
33
|
+
if (!name.endsWith('ya'))
|
|
34
|
+
return;
|
|
35
35
|
|
|
36
|
-
if (
|
|
36
|
+
if (!/^(i|a|ya)/.test(nextName))
|
|
37
37
|
return;
|
|
38
38
|
|
|
39
39
|
push({
|
|
@@ -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 {
|
|
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}${
|
|
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 (
|
|
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
|
|
12
|
-
path.node.name = `${name.slice(0, -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' || !/[
|
|
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
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bindu",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.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"
|