marathi-transliterate 1.7.4 → 1.8.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/README.md +119 -0
- package/package.json +10 -4
- package/src/dictionary.js +106 -0
- package/src/gender.js +712 -0
- package/src/index.js +122 -1
package/README.md
CHANGED
|
@@ -29,6 +29,17 @@ In everyday reality, people in Maharashtra type phonetically:
|
|
|
29
29
|
- `chaha` → **चहा**
|
|
30
30
|
- `dnyaneshwar` → **ज्ञानेश्वर**
|
|
31
31
|
- `patil` → **पाटील**
|
|
32
|
+
- `khandeshi` → **खान्देशी**
|
|
33
|
+
- `khandesh` → **खान्देश**
|
|
34
|
+
- `ahirani` → **अहिराणी**
|
|
35
|
+
- `varhadi` → **वऱ्हाडी** / `varhad` → **वऱ्हाड**
|
|
36
|
+
- `kokani` → **कोकणी** / `malvani` → **मालवणी**
|
|
37
|
+
- `thecha` → **ठेचा**
|
|
38
|
+
- `kalna` → **कळणा**
|
|
39
|
+
- `shevbhaji` → **शेवभाजी**
|
|
40
|
+
- `bharit` → **भरीत**
|
|
41
|
+
- `bhandar` → **भांडार**
|
|
42
|
+
- `vyapari` → **व्यापारी**
|
|
32
43
|
|
|
33
44
|
`marathi-transliterate` is built specifically for modern Marathi phonetic typing:
|
|
34
45
|
- **Zero dependencies**: Pure JavaScript, ~15 KB.
|
|
@@ -140,6 +151,35 @@ export function MarathiInput() {
|
|
|
140
151
|
|
|
141
152
|
---
|
|
142
153
|
|
|
154
|
+
## Regional Dialects & Cultural Words (खानदेशी, अहिराणी, वऱ्हाडी, कोकणी)
|
|
155
|
+
|
|
156
|
+
`marathi-transliterate` natively handles difficult Marathi conjuncts, regional dialect spellings, traditional foods, and business terminology without getting garbled:
|
|
157
|
+
|
|
158
|
+
| Category | Input | Output | Suggestions |
|
|
159
|
+
| :--- | :--- | :--- | :--- |
|
|
160
|
+
| **Khandesh & Ahirani** | `khandeshi` | **खान्देशी** | `['खान्देशी', 'खानदेशी', 'खांदेशी']` |
|
|
161
|
+
| | `khandesh` | **खान्देश** | `['खान्देश', 'खानदेश', 'खांदेश']` |
|
|
162
|
+
| | `ahirani` | **अहिराणी** | `['अहिराणी', 'अहिराणि']` |
|
|
163
|
+
| | `khandoba` | **खंडोबा** | `['खंडोबा', 'खंडेराव']` |
|
|
164
|
+
| **Varhad & Vidarbha** | `varhad` / `warhad` | **वऱ्हाड** | ऱ्ह conjunct (`वऱ्हाड`) |
|
|
165
|
+
| | `varhadi` / `warhadi`| **वऱ्हाडी** | `['वऱ्हाडी']` |
|
|
166
|
+
| | `vidarbha` / `vidarbhi` | **विदर्भ** / **विदर्भी** | `['विदर्भ', 'विदर्भी', 'विदर्भीय']` |
|
|
167
|
+
| **Kokan & Western MH** | `kokan` / `konkan` | **कोकण** | `['कोकण', 'कोकणी']` |
|
|
168
|
+
| | `malvan` / `malvani` | **मालवण** / **मालवणी** | `['मालवण', 'मालवणी']` |
|
|
169
|
+
| | `marathwada` / `marathwadi` | **मराठवाडा** / **मराठवाडी** | `['मराठवाडा', 'मराठवाडी']` |
|
|
170
|
+
| | `mandesh` / `mandeshi` | **मान्देश** / **मान्देशी** | `['मान्देशी', 'मानदेशी']` |
|
|
171
|
+
| **Traditional Foods** | `kalna` / `kalnache` | **कळणा** / **कळण्याचे** | (कळण्याची भाकर / पीठ) |
|
|
172
|
+
| | `shevbhaji` | **शेवभाजी** | (खानदेशी शेवभाजी) |
|
|
173
|
+
| | `thecha` | **ठेचा** | (मिरचीचा ठेचा) |
|
|
174
|
+
| | `bharit` | **भरीत** | (वांग्याचे भरीत) |
|
|
175
|
+
| | `puranpoli` | **पुरणपोळी** | (पुरणपोळी) |
|
|
176
|
+
| | `pithla` / `pithle` | **पिठलं** / **पिठले** | (पिठलं-भाकरी) |
|
|
177
|
+
| **Business & Trade** | `bhandar` / `kiranabhandar` | **भांडार** / **किराणा भांडार** | |
|
|
178
|
+
| | `vyapari` / `kharedidar` | **व्यापारी** / **खरेदीदार** | |
|
|
179
|
+
| | `kamgar` / `karagir` | **कामगार** / **कारागीर** | |
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
143
183
|
## API Reference
|
|
144
184
|
|
|
145
185
|
### `transliterateWord(word: string): string`
|
|
@@ -197,6 +237,85 @@ Attaches keyboard listeners to an `<input>` or `<textarea>` element.
|
|
|
197
237
|
|
|
198
238
|
---
|
|
199
239
|
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## 🧬 Marathi Grammatical Gender & Linguistics (लिंग व्यवस्था)
|
|
243
|
+
|
|
244
|
+
`marathi-transliterate` includes a zero-dependency, offline grammatical gender analyzer and inflection engine for Marathi nouns, supporting **पुल्लिंग (Masculine / तो)**, **स्त्रीलिंग (Feminine / ती)**, **नपुंसकलिंग (Neuter / ते)**, and **उभयलिंग (Dual / Common)**.
|
|
245
|
+
|
|
246
|
+
You can import directly from the root package or via the dedicated submodules `marathi-transliterate/gender` / `marathi-transliterate/ling`:
|
|
247
|
+
|
|
248
|
+
```javascript
|
|
249
|
+
import {
|
|
250
|
+
getGender,
|
|
251
|
+
getPronoun,
|
|
252
|
+
formatWithPronoun,
|
|
253
|
+
getOppositeGender,
|
|
254
|
+
changeGender,
|
|
255
|
+
isMasculine,
|
|
256
|
+
isFeminine,
|
|
257
|
+
isNeuter,
|
|
258
|
+
isDualGender,
|
|
259
|
+
GENDERS
|
|
260
|
+
} from "marathi-transliterate";
|
|
261
|
+
// Or: import { getGender } from "marathi-transliterate/gender";
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### 1. Gender Detection (`getGender`)
|
|
265
|
+
Accepts either Devanagari Marathi text or phonetic Latin English typing (auto-transliterated):
|
|
266
|
+
|
|
267
|
+
```javascript
|
|
268
|
+
// Kirana & Grocery items
|
|
269
|
+
getGender("कांदा");
|
|
270
|
+
// → { word: "कांदा", gender: "पुल्लिंग", pronoun: "तो", label: "पुल्लिंग (तो)", formatted: "तो कांदा" }
|
|
271
|
+
|
|
272
|
+
getGender("sakhar");
|
|
273
|
+
// → { word: "sakhar", devanagari: "साखर", gender: "स्त्रीलिंग", pronoun: "ती", formatted: "ती साखर" }
|
|
274
|
+
|
|
275
|
+
getGender("tel");
|
|
276
|
+
// → { word: "tel", devanagari: "तेल", gender: "नपुंसकलिंग", pronoun: "ते", formatted: "ते तेल" }
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### 2. Demonstrative Pronoun Resolution (`getPronoun`, `formatWithPronoun`)
|
|
280
|
+
```javascript
|
|
281
|
+
getPronoun("साखर"); // → "ती"
|
|
282
|
+
getPronoun("कांदा"); // → "तो"
|
|
283
|
+
getPronoun("दूध"); // → "ते"
|
|
284
|
+
|
|
285
|
+
formatWithPronoun("कांदा"); // → "तो कांदा"
|
|
286
|
+
formatWithPronoun("साखर"); // → "ती साखर"
|
|
287
|
+
formatWithPronoun("पुस्तक"); // → "ते पुस्तक"
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### 3. Opposite Gender Inflection (`getOppositeGender`, `changeGender`)
|
|
291
|
+
Pairs masculine and feminine counterparts (Family, Occupations, Titles, Animals):
|
|
292
|
+
|
|
293
|
+
```javascript
|
|
294
|
+
getOppositeGender("मुलगा"); // → "मुलगी"
|
|
295
|
+
getOppositeGender("घोडा"); // → "घोडी"
|
|
296
|
+
getOppositeGender("बैल"); // → "गाय"
|
|
297
|
+
getOppositeGender("शिक्षक"); // → "शिक्षिका"
|
|
298
|
+
getOppositeGender("मालक"); // → "मालकीण"
|
|
299
|
+
getOppositeGender("राजा"); // → "राणी"
|
|
300
|
+
getOppositeGender("वाघ"); // → "वाघीण"
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### 4. Dual / Common Gender Recognition (`isDualGender`)
|
|
304
|
+
Words that naturally take both masculine and feminine in Marathi:
|
|
305
|
+
```javascript
|
|
306
|
+
isDualGender("बाग"); // → true ("तो बाग" / "ती बाग")
|
|
307
|
+
isDualGender("वेळ"); // → true ("तो वेळ" / "ती वेळ")
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### 5. Runtime Extensibility (`extendGenderDictionary`)
|
|
311
|
+
```javascript
|
|
312
|
+
import { extendGenderDictionary, GENDERS } from "marathi-transliterate";
|
|
313
|
+
|
|
314
|
+
extendGenderDictionary({
|
|
315
|
+
"अनोखीवस्तू": GENDERS.STREELINGA
|
|
316
|
+
});
|
|
317
|
+
```
|
|
318
|
+
|
|
200
319
|
## License
|
|
201
320
|
|
|
202
321
|
MIT © Ketan Katore
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marathi-transliterate",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Zero-dependency, offline-first Marathi / Devanagari phonetic transliteration library. Converts English typing to Marathi (e.g. sakhar -> साखर) seamlessly in plain JS, Node.js, and frontend frameworks.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": "./src/index.js",
|
|
10
10
|
"./dom": "./src/dom.js",
|
|
11
|
-
"./dictionary": "./src/dictionary.js"
|
|
11
|
+
"./dictionary": "./src/dictionary.js",
|
|
12
|
+
"./gender": "./src/gender.js",
|
|
13
|
+
"./ling": "./src/gender.js"
|
|
12
14
|
},
|
|
13
15
|
"scripts": {
|
|
14
|
-
"test": "node tests
|
|
16
|
+
"test": "node --test tests/*.test.js"
|
|
15
17
|
},
|
|
16
18
|
"keywords": [
|
|
17
19
|
"marathi",
|
|
@@ -22,7 +24,11 @@
|
|
|
22
24
|
"marathi-typing",
|
|
23
25
|
"input-tools",
|
|
24
26
|
"ime",
|
|
25
|
-
"offline"
|
|
27
|
+
"offline",
|
|
28
|
+
"marathi-gender",
|
|
29
|
+
"ling",
|
|
30
|
+
"grammar",
|
|
31
|
+
"linguistics"
|
|
26
32
|
],
|
|
27
33
|
"author": "Ketan Katore",
|
|
28
34
|
"license": "MIT",
|
package/src/dictionary.js
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
* Kirana/grocery items, customer names, units, and shop terms.
|
|
4
4
|
*/
|
|
5
5
|
export const MARATHI_DICTIONARY = {
|
|
6
|
+
"mulga": "मुलगा",
|
|
7
|
+
"mulgi": "मुलगी",
|
|
8
|
+
"pustak": "पुस्तक",
|
|
9
|
+
|
|
6
10
|
// --- Popular Marathi Kirana Brands, Masale & Staples with Anusvara ---
|
|
7
11
|
'rambandhu': 'रामबंधू',
|
|
8
12
|
'rambandhoo': 'रामबंधू',
|
|
@@ -1726,5 +1730,107 @@ export const MARATHI_DICTIONARY = {
|
|
|
1726
1730
|
"jalebi": "जिलेबी",
|
|
1727
1731
|
"gulabjamun": "गुलाबजाम",
|
|
1728
1732
|
"biscuit": "बिस्कीट",
|
|
1733
|
+
|
|
1734
|
+
// --- Regional Dialects, Cultures & Communities (Khandesh, Ahirani, Varhad, Kokan, etc.) ---
|
|
1735
|
+
"khandeshi": "खान्देशी",
|
|
1736
|
+
"khaandeshi": "खान्देशी",
|
|
1737
|
+
"khandesh": "खान्देश",
|
|
1738
|
+
"khaandesh": "खान्देश",
|
|
1739
|
+
"khandeshkar": "खान्देशकर",
|
|
1740
|
+
"khaandeshkar": "खान्देशकर",
|
|
1741
|
+
"khandoba": "खंडोबा",
|
|
1742
|
+
"khandvi": "खांडवी",
|
|
1743
|
+
|
|
1744
|
+
"mandeshi": "मान्देशी",
|
|
1745
|
+
"maandeshi": "मान्देशी",
|
|
1746
|
+
"mandesh": "मान्देश",
|
|
1747
|
+
"maandesh": "मान्देश",
|
|
1748
|
+
|
|
1749
|
+
"ahirani": "अहिराणी",
|
|
1750
|
+
"aahirani": "अहिराणी",
|
|
1751
|
+
"ahir": "अहिर",
|
|
1752
|
+
|
|
1753
|
+
"varhad": "वऱ्हाड",
|
|
1754
|
+
"warhad": "वऱ्हाड",
|
|
1755
|
+
"varhadi": "वऱ्हाडी",
|
|
1756
|
+
"warhadi": "वऱ्हाडी",
|
|
1757
|
+
|
|
1758
|
+
"kokan": "कोकण",
|
|
1759
|
+
"konkan": "कोकण",
|
|
1760
|
+
"kokani": "कोकणी",
|
|
1761
|
+
"konkani": "कोकणी",
|
|
1762
|
+
"koknastha": "कोकणस्थ",
|
|
1763
|
+
"kokanastha": "कोकणस्थ",
|
|
1764
|
+
|
|
1765
|
+
"malvan": "मालवण",
|
|
1766
|
+
"maalvan": "मालवण",
|
|
1767
|
+
"malvani": "मालवणी",
|
|
1768
|
+
"maalvani": "मालवणी",
|
|
1769
|
+
|
|
1770
|
+
"marathwada": "मराठवाडा",
|
|
1771
|
+
"marathwadi": "मराठवाडी",
|
|
1772
|
+
|
|
1773
|
+
"vidarbha": "विदर्भ",
|
|
1774
|
+
"vidarbhi": "विदर्भी",
|
|
1775
|
+
"vidarbhiya": "विदर्भीय",
|
|
1776
|
+
|
|
1777
|
+
"deshastha": "देशस्थ",
|
|
1778
|
+
"marhati": "मऱ्हाटी",
|
|
1779
|
+
"marhatta": "मऱ्हाटा",
|
|
1780
|
+
|
|
1781
|
+
"kannada": "कन्नड",
|
|
1782
|
+
"kanadi": "कानडी",
|
|
1783
|
+
"marwadi": "मारवाडी",
|
|
1784
|
+
"marwari": "मारवाडी",
|
|
1785
|
+
"sindhi": "सिंधी",
|
|
1786
|
+
"gujarati": "गुजराती",
|
|
1787
|
+
"rajasthani": "राजस्थानी",
|
|
1788
|
+
"bengali": "बंगाली",
|
|
1789
|
+
"punjabi": "पंजाबी",
|
|
1790
|
+
|
|
1791
|
+
// --- Kirana, Business & Trade Terms ---
|
|
1792
|
+
"bhandar": "भांडार",
|
|
1793
|
+
"bhandare": "भंडारे",
|
|
1794
|
+
"vastubhandar": "वस्तुभांडार",
|
|
1795
|
+
"kiranabhandar": "किराणा भांडार",
|
|
1796
|
+
"vyapari": "व्यापारी",
|
|
1797
|
+
"kharedidar": "खरेदीदार",
|
|
1798
|
+
"karagir": "कारागीर",
|
|
1799
|
+
"kamgar": "कामगार",
|
|
1800
|
+
|
|
1801
|
+
// --- Khandeshi & Maharashtrian Traditional Foods & Dishes ---
|
|
1802
|
+
"kalna": "कळणा",
|
|
1803
|
+
"kaalna": "कळणा",
|
|
1804
|
+
"kalnache": "कळण्याचे",
|
|
1805
|
+
"kalnapith": "कळणा पीठ",
|
|
1806
|
+
"thecha": "ठेचा",
|
|
1807
|
+
"shevbhaji": "शेवभाजी",
|
|
1808
|
+
"bharit": "भरीत",
|
|
1809
|
+
"vangyachebharit": "वांग्याचे भरीत",
|
|
1810
|
+
"puranpoli": "पुरणपोळी",
|
|
1811
|
+
"pithla": "पिठलं",
|
|
1812
|
+
"pithle": "पिठले",
|
|
1813
|
+
"solkadhi": "सोलकढी",
|
|
1814
|
+
"ukadpendi": "उकडपेंडी",
|
|
1815
|
+
"chakli": "चकली",
|
|
1816
|
+
"shankarpali": "शंकरपाळी",
|
|
1817
|
+
"shankarpalya": "शंकरपाळ्या",
|
|
1818
|
+
"anarse": "अनारसे",
|
|
1819
|
+
"anarsa": "अनारसा",
|
|
1820
|
+
"vadapav": "वडापाव",
|
|
1821
|
+
"misalpav": "मिसळपाव",
|
|
1822
|
+
"basundi": "बासुंदी",
|
|
1823
|
+
"pedhe": "पेढे",
|
|
1824
|
+
"modak": "मोदक",
|
|
1825
|
+
"kachori": "कचोरी",
|
|
1826
|
+
"samosa": "समोसा",
|
|
1827
|
+
|
|
1828
|
+
// --- Common Marathi Descriptors & Colloquial Words ---
|
|
1829
|
+
"bhari": "भारी",
|
|
1830
|
+
"khup": "खूप",
|
|
1831
|
+
"khoop": "खूप",
|
|
1832
|
+
"lay": "लय",
|
|
1833
|
+
"chaan": "छान",
|
|
1834
|
+
"chan": "छान",
|
|
1729
1835
|
};
|
|
1730
1836
|
|
package/src/gender.js
ADDED
|
@@ -0,0 +1,712 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* marathi-transliterate / gender (मराठी व्याकरण लिंग व्यवस्था)
|
|
3
|
+
* Offline-first Marathi grammatical gender analyzer, pronoun resolver,
|
|
4
|
+
* and morphological inflection engine.
|
|
5
|
+
*
|
|
6
|
+
* Supports three primary Marathi genders (पुल्लिंग, स्त्रीलिंग, नपुंसकलिंग)
|
|
7
|
+
* as well as common/dual-gender words (उभयलिंग).
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { transliterateWord } from "./index.js";
|
|
11
|
+
|
|
12
|
+
export const GENDERS = Object.freeze({
|
|
13
|
+
PULLINGA: "पुल्लिंग", // Masculine
|
|
14
|
+
STREELINGA: "स्त्रीलिंग", // Feminine
|
|
15
|
+
NAPUNSAKLINGA: "नपुंसकलिंग", // Neuter
|
|
16
|
+
UBHAYLINGA: "उभयलिंग" // Dual / Common
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const GENDER_KEYS = Object.freeze({
|
|
20
|
+
MASCULINE: "masculine",
|
|
21
|
+
FEMININE: "feminine",
|
|
22
|
+
NEUTER: "neuter",
|
|
23
|
+
COMMON: "common"
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const PRONOUNS = Object.freeze({
|
|
27
|
+
PULLINGA: "तो",
|
|
28
|
+
STREELINGA: "ती",
|
|
29
|
+
NAPUNSAKLINGA: "ते",
|
|
30
|
+
UBHAYLINGA: "तो/ती",
|
|
31
|
+
[GENDERS.PULLINGA]: "तो",
|
|
32
|
+
[GENDERS.STREELINGA]: "ती",
|
|
33
|
+
[GENDERS.NAPUNSAKLINGA]: "ते",
|
|
34
|
+
[GENDERS.UBHAYLINGA]: "तो/ती"
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Opposite Gender Pairs (पुल्लिंग <-> स्त्रीलिंग)
|
|
39
|
+
*/
|
|
40
|
+
export const OPPOSITE_GENDER_PAIRS = {
|
|
41
|
+
// माणसे व नातेसंबंध (Family & Kinship)
|
|
42
|
+
"मुलगा": "मुलगी",
|
|
43
|
+
"मुलगी": "मुलगा",
|
|
44
|
+
"भाऊ": "बहीण",
|
|
45
|
+
"बहीण": "भाऊ",
|
|
46
|
+
"वडील": "आई",
|
|
47
|
+
"आई": "वडील",
|
|
48
|
+
"काका": "काकू",
|
|
49
|
+
"काकू": "काका",
|
|
50
|
+
"मामा": "मामी",
|
|
51
|
+
"मामी": "मामा",
|
|
52
|
+
"आत्या": "मामा",
|
|
53
|
+
"मावशी": "मावसा",
|
|
54
|
+
"मावसा": "मावशी",
|
|
55
|
+
"आजोबा": "आजी",
|
|
56
|
+
"आजी": "आजोबा",
|
|
57
|
+
"पंजोबा": "पंजी",
|
|
58
|
+
"पंजी": "पंजोबा",
|
|
59
|
+
"नवरा": "बायको",
|
|
60
|
+
"बायको": "नवरा",
|
|
61
|
+
"पती": "पत्नी",
|
|
62
|
+
"पत्नी": "पती",
|
|
63
|
+
"सासरा": "सासू",
|
|
64
|
+
"सासू": "सासरा",
|
|
65
|
+
"जावई": "सून",
|
|
66
|
+
"सून": "जावई",
|
|
67
|
+
"दीर": "जाऊ",
|
|
68
|
+
"जाऊ": "दीर",
|
|
69
|
+
"भावोजी": "नणंद",
|
|
70
|
+
"नणंद": "भावोजी",
|
|
71
|
+
"मेहुणा": "मेहुणी",
|
|
72
|
+
"मेहुणी": "मेहुणा",
|
|
73
|
+
"मित्र": "मैत्रीण",
|
|
74
|
+
"मैत्रीण": "मित्र",
|
|
75
|
+
|
|
76
|
+
// हुद्दे, व्यवसाय व सामाजिक पदव्या (Professions, Titles & Royalty)
|
|
77
|
+
"राजा": "राणी",
|
|
78
|
+
"राणी": "राजा",
|
|
79
|
+
"सम्राट": "सम्राज्ञी",
|
|
80
|
+
"सम्राज्ञी": "सम्राट",
|
|
81
|
+
"मालक": "मालकीण",
|
|
82
|
+
"मालकीण": "मालक",
|
|
83
|
+
"शेठ": "शेठाणी",
|
|
84
|
+
"शेठाणी": "शेठ",
|
|
85
|
+
"व्यापारी": "व्यापारीण",
|
|
86
|
+
"शिक्षक": "शिक्षिका",
|
|
87
|
+
"शिक्षिका": "शिक्षक",
|
|
88
|
+
"अध्यापक": "अध्यापिका",
|
|
89
|
+
"अध्यापिका": "अध्यापक",
|
|
90
|
+
"लेखक": "लेखिका",
|
|
91
|
+
"लेखिका": "लेखक",
|
|
92
|
+
"कवी": "कवयित्री",
|
|
93
|
+
"कवयित्री": "कवी",
|
|
94
|
+
"गायक": "गायिका",
|
|
95
|
+
"गायिका": "गायक",
|
|
96
|
+
"नायक": "नायिका",
|
|
97
|
+
"नायिका": "नायक",
|
|
98
|
+
"अभिनेता": "अभिनेत्री",
|
|
99
|
+
"अभिनेत्री": "अभिनेता",
|
|
100
|
+
"विद्वान": "विदुषी",
|
|
101
|
+
"विदुषी": "विद्वान",
|
|
102
|
+
"श्रीमान": "श्रीमती",
|
|
103
|
+
"श्रीमती": "श्रीमान",
|
|
104
|
+
"तरुण": "तरुणी",
|
|
105
|
+
"तरुणी": "तरुण",
|
|
106
|
+
"वृद्ध": "वृद्धा",
|
|
107
|
+
"वृद्धा": "वृद्ध",
|
|
108
|
+
"नोकर": "नोकराणी",
|
|
109
|
+
"नोकराणी": "नोकर",
|
|
110
|
+
"धोबी": "धोबीण",
|
|
111
|
+
"धोबीण": "धोबी",
|
|
112
|
+
"कोळी": "कोळीण",
|
|
113
|
+
"कोळीण": "कोळी",
|
|
114
|
+
"गवळी": "गवळण",
|
|
115
|
+
"गवळण": "गवळी",
|
|
116
|
+
"सोनार": "सोनारीण",
|
|
117
|
+
"सोनारीण": "सोनार",
|
|
118
|
+
"लोहार": "लोहारीण",
|
|
119
|
+
"लोहारीण": "लोहार",
|
|
120
|
+
"सुतार": "सुतारीण",
|
|
121
|
+
"सुतारीण": "सुतार",
|
|
122
|
+
"कुंभार": "कुंभारीण",
|
|
123
|
+
"कुंभारीण": "कुंभार",
|
|
124
|
+
"तेली": "तेलीण",
|
|
125
|
+
"तेलीण": "तेली",
|
|
126
|
+
"माळी": "माळीण",
|
|
127
|
+
"माळीण": "माळी",
|
|
128
|
+
"शिंपी": "शिंपीण",
|
|
129
|
+
"शिंपीण": "शिंपी",
|
|
130
|
+
"शेतकरी": "शेतकरीण",
|
|
131
|
+
"शेतकरीण": "शेतकरी",
|
|
132
|
+
"वकील": "वकीलीण",
|
|
133
|
+
|
|
134
|
+
// प्राणी व पक्षी (Animals & Birds)
|
|
135
|
+
"बैल": "गाय",
|
|
136
|
+
"गाय": "बैल",
|
|
137
|
+
"घोडा": "घोडी",
|
|
138
|
+
"घोडी": "घोडा",
|
|
139
|
+
"कुत्रा": "कुत्री",
|
|
140
|
+
"कुत्री": "कुत्रा",
|
|
141
|
+
"बोका": "मांजर",
|
|
142
|
+
"मांजर": "बोका",
|
|
143
|
+
"वाघ": "वाघीण",
|
|
144
|
+
"वाघीण": "वाघ",
|
|
145
|
+
"सिंह": "सिंहीण",
|
|
146
|
+
"सिंहीण": "सिंह",
|
|
147
|
+
"हत्ती": "हत्तीण",
|
|
148
|
+
"हत्तीण": "हत्ती",
|
|
149
|
+
"बोकड": "शेळी",
|
|
150
|
+
"शेळी": "बोकड",
|
|
151
|
+
"मेंढा": "मेंढी",
|
|
152
|
+
"मेंढी": "मेंढा",
|
|
153
|
+
"रेडा": "म्हैस",
|
|
154
|
+
"म्हैस": "रेडा",
|
|
155
|
+
"कोंबडा": "कोंबडी",
|
|
156
|
+
"कोंबडी": "कोंबडा",
|
|
157
|
+
"मोर": "लांडोर",
|
|
158
|
+
"लांडोर": "मोर",
|
|
159
|
+
"कावळा": "कावळी",
|
|
160
|
+
"कावळी": "कावळा",
|
|
161
|
+
"चिमणा": "चिमणी",
|
|
162
|
+
"चिमणी": "चिमणा",
|
|
163
|
+
"हंस": "हंसी",
|
|
164
|
+
"हंसी": "हंस",
|
|
165
|
+
"वानर": "वानरी",
|
|
166
|
+
"वानरी": "वानर",
|
|
167
|
+
"उंट": "सांडणी",
|
|
168
|
+
"सांडणी": "उंट",
|
|
169
|
+
"हरिण": "हरिणी",
|
|
170
|
+
"हरिणी": "हरिण",
|
|
171
|
+
"कोल्हा": "कोल्ही",
|
|
172
|
+
"कोल्ही": "कोल्हा"
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Comprehensive Dictionary of Marathi Nouns & Their Grammatical Gender
|
|
177
|
+
*/
|
|
178
|
+
export const MARATHI_GENDER_DICTIONARY = {
|
|
179
|
+
// === किराणा व अन्नधान्य (Grocery, Staples, Spices, Dairy) ===
|
|
180
|
+
// पुल्लिंग (तो)
|
|
181
|
+
"तांदूळ": GENDERS.PULLINGA,
|
|
182
|
+
"गहू": GENDERS.PULLINGA,
|
|
183
|
+
"रवा": GENDERS.PULLINGA,
|
|
184
|
+
"मैदा": GENDERS.PULLINGA,
|
|
185
|
+
"गूळ": GENDERS.PULLINGA,
|
|
186
|
+
"चहा": GENDERS.PULLINGA,
|
|
187
|
+
"साबण": GENDERS.PULLINGA,
|
|
188
|
+
"कांदा": GENDERS.PULLINGA,
|
|
189
|
+
"बटाटा": GENDERS.PULLINGA,
|
|
190
|
+
"लसूण": GENDERS.PULLINGA,
|
|
191
|
+
"मसाला": GENDERS.PULLINGA,
|
|
192
|
+
"पोहे": GENDERS.PULLINGA,
|
|
193
|
+
"साबुदाणा": GENDERS.PULLINGA,
|
|
194
|
+
"मका": GENDERS.PULLINGA,
|
|
195
|
+
"चना": GENDERS.PULLINGA,
|
|
196
|
+
"उडीद": GENDERS.PULLINGA,
|
|
197
|
+
"मूग": GENDERS.PULLINGA,
|
|
198
|
+
"वाटाणा": GENDERS.PULLINGA,
|
|
199
|
+
"पापड": GENDERS.PULLINGA,
|
|
200
|
+
"कापूर": GENDERS.PULLINGA,
|
|
201
|
+
"धूप": GENDERS.PULLINGA,
|
|
202
|
+
"हिंग": GENDERS.PULLINGA,
|
|
203
|
+
"कढीपत्ता": GENDERS.PULLINGA,
|
|
204
|
+
"टोमॅटो": GENDERS.PULLINGA,
|
|
205
|
+
"भोपळा": GENDERS.PULLINGA,
|
|
206
|
+
"कोबी": GENDERS.PULLINGA,
|
|
207
|
+
"आंबा": GENDERS.PULLINGA,
|
|
208
|
+
"पेरू": GENDERS.PULLINGA,
|
|
209
|
+
"चिकू": GENDERS.PULLINGA,
|
|
210
|
+
"नारळ": GENDERS.PULLINGA,
|
|
211
|
+
"काजू": GENDERS.PULLINGA,
|
|
212
|
+
"बदाम": GENDERS.PULLINGA,
|
|
213
|
+
"पिस्ता": GENDERS.PULLINGA,
|
|
214
|
+
"अक्रोड": GENDERS.PULLINGA,
|
|
215
|
+
"खजूर": GENDERS.PULLINGA,
|
|
216
|
+
"आवळा": GENDERS.PULLINGA,
|
|
217
|
+
"लाडू": GENDERS.PULLINGA,
|
|
218
|
+
"पेढा": GENDERS.PULLINGA,
|
|
219
|
+
"शिरा": GENDERS.PULLINGA,
|
|
220
|
+
"भात": GENDERS.PULLINGA,
|
|
221
|
+
"जाम": GENDERS.PULLINGA,
|
|
222
|
+
"शाम्पू": GENDERS.PULLINGA,
|
|
223
|
+
|
|
224
|
+
// स्त्रीलिंग (ती)
|
|
225
|
+
"साखर": GENDERS.STREELINGA,
|
|
226
|
+
"हळद": GENDERS.STREELINGA,
|
|
227
|
+
"डाळ": GENDERS.STREELINGA,
|
|
228
|
+
"तूरडाळ": GENDERS.STREELINGA,
|
|
229
|
+
"मूगडाळ": GENDERS.STREELINGA,
|
|
230
|
+
"चणाडाळ": GENDERS.STREELINGA,
|
|
231
|
+
"उडीदडाळ": GENDERS.STREELINGA,
|
|
232
|
+
"मसूरडाळ": GENDERS.STREELINGA,
|
|
233
|
+
"मोहरी": GENDERS.STREELINGA,
|
|
234
|
+
"मेथी": GENDERS.STREELINGA,
|
|
235
|
+
"मिरची": GENDERS.STREELINGA,
|
|
236
|
+
"कोथिंबीर": GENDERS.STREELINGA,
|
|
237
|
+
"लवंग": GENDERS.STREELINGA,
|
|
238
|
+
"वेलची": GENDERS.STREELINGA,
|
|
239
|
+
"खसखस": GENDERS.STREELINGA,
|
|
240
|
+
"सुंठ": GENDERS.STREELINGA,
|
|
241
|
+
"दालचिनी": GENDERS.STREELINGA,
|
|
242
|
+
"ज्वारी": GENDERS.STREELINGA,
|
|
243
|
+
"बाजरी": GENDERS.STREELINGA,
|
|
244
|
+
"कॉफी": GENDERS.STREELINGA,
|
|
245
|
+
"हळदी": GENDERS.STREELINGA,
|
|
246
|
+
"शेव": GENDERS.STREELINGA,
|
|
247
|
+
"चकली": GENDERS.STREELINGA,
|
|
248
|
+
"भाजी": GENDERS.STREELINGA,
|
|
249
|
+
"चपाती": GENDERS.STREELINGA,
|
|
250
|
+
"पोळी": GENDERS.STREELINGA,
|
|
251
|
+
"भाकरी": GENDERS.STREELINGA,
|
|
252
|
+
"पुरी": GENDERS.STREELINGA,
|
|
253
|
+
"खीर": GENDERS.STREELINGA,
|
|
254
|
+
"अंगूर": GENDERS.STREELINGA,
|
|
255
|
+
"द्राक्षे": GENDERS.NAPUNSAKLINGA,
|
|
256
|
+
"सुपारी": GENDERS.STREELINGA,
|
|
257
|
+
"अगरबत्ती": GENDERS.STREELINGA,
|
|
258
|
+
"मेणबत्ती": GENDERS.STREELINGA,
|
|
259
|
+
"कात्री": GENDERS.STREELINGA,
|
|
260
|
+
"सुरी": GENDERS.STREELINGA,
|
|
261
|
+
"पिशवी": GENDERS.STREELINGA,
|
|
262
|
+
"बाटली": GENDERS.STREELINGA,
|
|
263
|
+
"वाटी": GENDERS.STREELINGA,
|
|
264
|
+
"थाळी": GENDERS.STREELINGA,
|
|
265
|
+
|
|
266
|
+
// नपुंसकलिंग (ते)
|
|
267
|
+
"तेल": GENDERS.NAPUNSAKLINGA,
|
|
268
|
+
"तूप": GENDERS.NAPUNSAKLINGA,
|
|
269
|
+
"मीठ": GENDERS.NAPUNSAKLINGA,
|
|
270
|
+
"बेसन": GENDERS.NAPUNSAKLINGA,
|
|
271
|
+
"पीठ": GENDERS.NAPUNSAKLINGA,
|
|
272
|
+
"दूध": GENDERS.NAPUNSAKLINGA,
|
|
273
|
+
"पाणी": GENDERS.NAPUNSAKLINGA,
|
|
274
|
+
"दही": GENDERS.NAPUNSAKLINGA,
|
|
275
|
+
"ताक": GENDERS.NAPUNSAKLINGA,
|
|
276
|
+
"पनीर": GENDERS.NAPUNSAKLINGA,
|
|
277
|
+
"लोणी": GENDERS.NAPUNSAKLINGA,
|
|
278
|
+
"धान्य": GENDERS.NAPUNSAKLINGA,
|
|
279
|
+
"कडधान्य": GENDERS.NAPUNSAKLINGA,
|
|
280
|
+
"केळे": GENDERS.NAPUNSAKLINGA,
|
|
281
|
+
"सफरचंद": GENDERS.NAPUNSAKLINGA,
|
|
282
|
+
"डाळिंब": GENDERS.NAPUNSAKLINGA,
|
|
283
|
+
"अननस": GENDERS.NAPUNSAKLINGA,
|
|
284
|
+
"लिंबू": GENDERS.NAPUNSAKLINGA,
|
|
285
|
+
"लोणचे": GENDERS.NAPUNSAKLINGA,
|
|
286
|
+
"आले": GENDERS.NAPUNSAKLINGA,
|
|
287
|
+
"अद्रक": GENDERS.NAPUNSAKLINGA,
|
|
288
|
+
"वांगे": GENDERS.NAPUNSAKLINGA,
|
|
289
|
+
"खोबरे": GENDERS.NAPUNSAKLINGA,
|
|
290
|
+
"बिस्कीट": GENDERS.NAPUNSAKLINGA,
|
|
291
|
+
"भांडे": GENDERS.NAPUNSAKLINGA,
|
|
292
|
+
"ताट": GENDERS.NAPUNSAKLINGA,
|
|
293
|
+
"पातेले": GENDERS.NAPUNSAKLINGA,
|
|
294
|
+
"पोर": GENDERS.NAPUNSAKLINGA,
|
|
295
|
+
"मूल": GENDERS.NAPUNSAKLINGA,
|
|
296
|
+
"बाळ": GENDERS.NAPUNSAKLINGA,
|
|
297
|
+
|
|
298
|
+
// === निसर्ग, घरे, वस्तू व दैनंदिन जीवन ===
|
|
299
|
+
// पुल्लिंग (तो)
|
|
300
|
+
"दगड": GENDERS.PULLINGA,
|
|
301
|
+
"डोंगर": GENDERS.PULLINGA,
|
|
302
|
+
"पर्वत": GENDERS.PULLINGA,
|
|
303
|
+
"रस्ता": GENDERS.PULLINGA,
|
|
304
|
+
"चौक": GENDERS.PULLINGA,
|
|
305
|
+
"पूल": GENDERS.PULLINGA,
|
|
306
|
+
"दिवा": GENDERS.PULLINGA,
|
|
307
|
+
"टेबल": GENDERS.PULLINGA,
|
|
308
|
+
"पंखा": GENDERS.PULLINGA,
|
|
309
|
+
"डबा": GENDERS.PULLINGA,
|
|
310
|
+
"चमचा": GENDERS.PULLINGA,
|
|
311
|
+
"पेन": GENDERS.PULLINGA,
|
|
312
|
+
"कागद": GENDERS.PULLINGA,
|
|
313
|
+
"फळा": GENDERS.PULLINGA,
|
|
314
|
+
"रुमाल": GENDERS.PULLINGA,
|
|
315
|
+
"दरवाजा": GENDERS.PULLINGA,
|
|
316
|
+
"सूर्य": GENDERS.PULLINGA,
|
|
317
|
+
"चंद्र": GENDERS.PULLINGA,
|
|
318
|
+
"वारा": GENDERS.PULLINGA,
|
|
319
|
+
"पाऊस": GENDERS.PULLINGA,
|
|
320
|
+
"समुद्र": GENDERS.PULLINGA,
|
|
321
|
+
"आवाज": GENDERS.PULLINGA,
|
|
322
|
+
"रंग": GENDERS.PULLINGA,
|
|
323
|
+
"खडू": GENDERS.PULLINGA,
|
|
324
|
+
"फोन": GENDERS.PULLINGA,
|
|
325
|
+
"संगणक": GENDERS.PULLINGA,
|
|
326
|
+
|
|
327
|
+
// स्त्रीलिंग (ती)
|
|
328
|
+
"नदी": GENDERS.STREELINGA,
|
|
329
|
+
"हवा": GENDERS.STREELINGA,
|
|
330
|
+
"वीज": GENDERS.STREELINGA,
|
|
331
|
+
"जमीन": GENDERS.STREELINGA,
|
|
332
|
+
"माती": GENDERS.STREELINGA,
|
|
333
|
+
"वाळू": GENDERS.STREELINGA,
|
|
334
|
+
"रात्र": GENDERS.STREELINGA,
|
|
335
|
+
"सकाळ": GENDERS.STREELINGA,
|
|
336
|
+
"संध्याकाळ": GENDERS.STREELINGA,
|
|
337
|
+
"वही": GENDERS.STREELINGA,
|
|
338
|
+
"पेन्सिल": GENDERS.STREELINGA,
|
|
339
|
+
"भिंत": GENDERS.STREELINGA,
|
|
340
|
+
"खिडकी": GENDERS.STREELINGA,
|
|
341
|
+
"खोली": GENDERS.STREELINGA,
|
|
342
|
+
"इमारत": GENDERS.STREELINGA,
|
|
343
|
+
"शाळा": GENDERS.STREELINGA,
|
|
344
|
+
"बँक": GENDERS.STREELINGA,
|
|
345
|
+
"गाडी": GENDERS.STREELINGA,
|
|
346
|
+
"सायकल": GENDERS.STREELINGA,
|
|
347
|
+
"बस": GENDERS.STREELINGA,
|
|
348
|
+
"आगगाडी": GENDERS.STREELINGA,
|
|
349
|
+
"चादर": GENDERS.STREELINGA,
|
|
350
|
+
"गोधडी": GENDERS.STREELINGA,
|
|
351
|
+
"साडी": GENDERS.STREELINGA,
|
|
352
|
+
"टोपी": GENDERS.STREELINGA,
|
|
353
|
+
"खुर्ची": GENDERS.STREELINGA,
|
|
354
|
+
|
|
355
|
+
// नपुंसकलिंग (ते)
|
|
356
|
+
"पुस्तक": GENDERS.NAPUNSAKLINGA,
|
|
357
|
+
"झाड": GENDERS.NAPUNSAKLINGA,
|
|
358
|
+
"फूल": GENDERS.NAPUNSAKLINGA,
|
|
359
|
+
"पान": GENDERS.NAPUNSAKLINGA,
|
|
360
|
+
"मूळ": GENDERS.NAPUNSAKLINGA,
|
|
361
|
+
"बी": GENDERS.NAPUNSAKLINGA,
|
|
362
|
+
"फळ": GENDERS.NAPUNSAKLINGA,
|
|
363
|
+
"घर": GENDERS.NAPUNSAKLINGA,
|
|
364
|
+
"शहर": GENDERS.NAPUNSAKLINGA,
|
|
365
|
+
"गाव": GENDERS.NAPUNSAKLINGA,
|
|
366
|
+
"राज्य": GENDERS.NAPUNSAKLINGA,
|
|
367
|
+
"राष्ट्र": GENDERS.NAPUNSAKLINGA,
|
|
368
|
+
"जग": GENDERS.NAPUNSAKLINGA,
|
|
369
|
+
"दार": GENDERS.NAPUNSAKLINGA,
|
|
370
|
+
"छप्पर": GENDERS.NAPUNSAKLINGA,
|
|
371
|
+
"मैदान": GENDERS.NAPUNSAKLINGA,
|
|
372
|
+
"पाखरू": GENDERS.NAPUNSAKLINGA,
|
|
373
|
+
"चित्र": GENDERS.NAPUNSAKLINGA,
|
|
374
|
+
"अक्षर": GENDERS.NAPUNSAKLINGA,
|
|
375
|
+
"वाक्य": GENDERS.NAPUNSAKLINGA,
|
|
376
|
+
"पत्र": GENDERS.NAPUNSAKLINGA,
|
|
377
|
+
"कपाट": GENDERS.NAPUNSAKLINGA,
|
|
378
|
+
"दुकान": GENDERS.NAPUNSAKLINGA,
|
|
379
|
+
|
|
380
|
+
// === उभयलिंगी शब्द (Both Masculine & Feminine) ===
|
|
381
|
+
"बाग": GENDERS.UBHAYLINGA,
|
|
382
|
+
"वेळ": GENDERS.UBHAYLINGA,
|
|
383
|
+
"तंबाखू": GENDERS.UBHAYLINGA,
|
|
384
|
+
"पोर": GENDERS.UBHAYLINGA
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Extends the gender dictionary at runtime with custom words.
|
|
389
|
+
* @param {Record<string, string>} map - Map of Marathi word -> Gender
|
|
390
|
+
*/
|
|
391
|
+
export function extendGenderDictionary(map) {
|
|
392
|
+
if (map && typeof map === "object") {
|
|
393
|
+
Object.assign(MARATHI_GENDER_DICTIONARY, map);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Heuristic morphological rule analyzer for words not present in the dictionary.
|
|
399
|
+
* Analyzes Devanagari vowel and consonant suffixes.
|
|
400
|
+
* @param {string} marathiWord
|
|
401
|
+
* @returns {{ gender: string, confidence: string, reason: string }}
|
|
402
|
+
*/
|
|
403
|
+
function analyzeGenderByMorphology(marathiWord) {
|
|
404
|
+
const word = marathiWord.trim();
|
|
405
|
+
if (!word) {
|
|
406
|
+
return { gender: GENDERS.PULLINGA, confidence: "default", reason: "empty input" };
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// 1. Feminine agentive/diminutive suffixes
|
|
410
|
+
// उदा. -ीण (वाघीण, सिंहीण, मालकीण, धोबीण), -िका (शिक्षिका, लेखिका, गायिका)
|
|
411
|
+
if (word.endsWith("ीण") || word.endsWith("िका") || word.endsWith("त्री") || word.endsWith("वती") || word.endsWith("मती")) {
|
|
412
|
+
return {
|
|
413
|
+
gender: GENDERS.STREELINGA,
|
|
414
|
+
confidence: "rule",
|
|
415
|
+
reason: "feminine suffix (-ीण / -िका / -त्री / -वती)"
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// 2. Neuter abstract / collective suffixes
|
|
420
|
+
// उदा. -पण, -त्व, -मंडळ, -स्थान, -गृह
|
|
421
|
+
if (word.endsWith("पण") || word.endsWith("त्व") || word.endsWith("मंडळ") || word.endsWith("स्थान") || word.endsWith("गृह") || word.endsWith("केंद्र")) {
|
|
422
|
+
return {
|
|
423
|
+
gender: GENDERS.NAPUNSAKLINGA,
|
|
424
|
+
confidence: "rule",
|
|
425
|
+
reason: "neuter abstract/collective suffix"
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// 3. Vowel Ending Heuristics (अंत्य स्वर खूण)
|
|
430
|
+
// -ा (उदा. आकारांत: घोडा, दिवा, डबा, चमचा, मुलगा) -> बहुतांशी पुल्लिंग
|
|
431
|
+
if (word.endsWith("ा")) {
|
|
432
|
+
// Apavad: हवा, शाळा, दिशा, सभा (Sanskrit stree-linga)
|
|
433
|
+
if (["हवा", "शाळा", "दिशा", "सभा", "आशा", "पूजा", "विद्या", "सेवा", "माता"].includes(word)) {
|
|
434
|
+
return { gender: GENDERS.STREELINGA, confidence: "dictionary", reason: "stree-linga a-ending" };
|
|
435
|
+
}
|
|
436
|
+
return {
|
|
437
|
+
gender: GENDERS.PULLINGA,
|
|
438
|
+
confidence: "rule",
|
|
439
|
+
reason: "a-ending (आकारांत बहुतांशी पुल्लिंग)"
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// -ी or -ई (उदा. ईकारांत: वही, नदी, गाडी, साडी, बाटली, काठी) -> बहुतांशी स्त्रीलिंग
|
|
444
|
+
if (word.endsWith("ी") || word.endsWith("ई") || word.endsWith("ि") || word.endsWith("इ")) {
|
|
445
|
+
// Apavad: पाणी, लोणी, दही (नपुंसकलिंग), हत्ती, माळी, धोबी, काझी (पुल्लिंग)
|
|
446
|
+
if (["पाणी", "लोणी", "दही", "मोती"].includes(word)) {
|
|
447
|
+
return { gender: GENDERS.NAPUNSAKLINGA, confidence: "dictionary", reason: "neuter ee-ending" };
|
|
448
|
+
}
|
|
449
|
+
if (["हत्ती", "माळी", "धोबी", "तेली", "शेतकरी", "व्यापारी", "पक्षी"].includes(word)) {
|
|
450
|
+
return { gender: GENDERS.PULLINGA, confidence: "dictionary", reason: "masculine profession ee-ending" };
|
|
451
|
+
}
|
|
452
|
+
return {
|
|
453
|
+
gender: GENDERS.STREELINGA,
|
|
454
|
+
confidence: "rule",
|
|
455
|
+
reason: "ee-ending (ईकारांत बहुतांशी स्त्रीलिंग)"
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// -े or -ए (उदा. एकारांत: केळे, तळे, गाणे, भांडे, पातेले, लाडके) -> बहुतांशी नपुंसकलिंग
|
|
460
|
+
if (word.endsWith("े") || word.endsWith("ए")) {
|
|
461
|
+
return {
|
|
462
|
+
gender: GENDERS.NAPUNSAKLINGA,
|
|
463
|
+
confidence: "rule",
|
|
464
|
+
reason: "e-ending (एकारांत बहुतांशी नपुंसकलिंग)"
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// -ू or -ऊ (उदा. ऊकारांत):
|
|
469
|
+
if (word.endsWith("ू") || word.endsWith("ऊ")) {
|
|
470
|
+
if (["सासू", "जळू", "वाळू", "दारू", "वस्तू"].includes(word)) {
|
|
471
|
+
return { gender: GENDERS.STREELINGA, confidence: "dictionary", reason: "feminine oo-ending" };
|
|
472
|
+
}
|
|
473
|
+
if (["लिंबू", "पाखरू", "पिळू"].includes(word)) {
|
|
474
|
+
return { gender: GENDERS.NAPUNSAKLINGA, confidence: "dictionary", reason: "neuter oo-ending" };
|
|
475
|
+
}
|
|
476
|
+
return {
|
|
477
|
+
gender: GENDERS.PULLINGA,
|
|
478
|
+
confidence: "rule",
|
|
479
|
+
reason: "oo-ending (उदा. लाडू, पेढा, खडू)"
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
// Default for unclassified consonant endings (अकारांत)
|
|
484
|
+
return {
|
|
485
|
+
gender: GENDERS.PULLINGA,
|
|
486
|
+
confidence: "default",
|
|
487
|
+
reason: "consonant ending heuristic (अकारांत)"
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Analyzes the grammatical gender (लिंग) of any Marathi word.
|
|
493
|
+
* Automatically accepts both Devanagari (e.g. "साखर") and Latin transliteration (e.g. "sakhar").
|
|
494
|
+
*
|
|
495
|
+
* @param {string} word - The word to analyze
|
|
496
|
+
* @returns {{
|
|
497
|
+
* word: string,
|
|
498
|
+
* devanagari: string,
|
|
499
|
+
* gender: string,
|
|
500
|
+
* genderKey: string,
|
|
501
|
+
* pronoun: string,
|
|
502
|
+
* label: string,
|
|
503
|
+
* confidence: "dictionary" | "pair" | "rule" | "default",
|
|
504
|
+
* isDual: boolean,
|
|
505
|
+
* oppositeGender: string | null,
|
|
506
|
+
* formatted: string
|
|
507
|
+
* }}
|
|
508
|
+
*/
|
|
509
|
+
export function getGender(word) {
|
|
510
|
+
if (!word || typeof word !== "string") {
|
|
511
|
+
return {
|
|
512
|
+
word: "",
|
|
513
|
+
devanagari: "",
|
|
514
|
+
gender: GENDERS.PULLINGA,
|
|
515
|
+
genderKey: GENDER_KEYS.MASCULINE,
|
|
516
|
+
pronoun: PRONOUNS.PULLINGA,
|
|
517
|
+
label: `${GENDERS.PULLINGA} (${PRONOUNS.PULLINGA})`,
|
|
518
|
+
confidence: "default",
|
|
519
|
+
isDual: false,
|
|
520
|
+
oppositeGender: null,
|
|
521
|
+
formatted: ""
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
const clean = word.trim();
|
|
526
|
+
// Check if Latin script is passed, auto-transliterate
|
|
527
|
+
const isAscii = /^[a-zA-Z0-9_\-\s]+$/.test(clean);
|
|
528
|
+
const devanagari = isAscii ? transliterateWord(clean) : clean;
|
|
529
|
+
|
|
530
|
+
// 1. Direct match in dictionary
|
|
531
|
+
if (MARATHI_GENDER_DICTIONARY[devanagari]) {
|
|
532
|
+
const gender = MARATHI_GENDER_DICTIONARY[devanagari];
|
|
533
|
+
const isDual = gender === GENDERS.UBHAYLINGA;
|
|
534
|
+
const pronoun = isDual ? "तो/ती" : PRONOUNS[gender];
|
|
535
|
+
const oppositeGender = OPPOSITE_GENDER_PAIRS[devanagari] || null;
|
|
536
|
+
const genderKey = isDual
|
|
537
|
+
? GENDER_KEYS.COMMON
|
|
538
|
+
: gender === GENDERS.PULLINGA
|
|
539
|
+
? GENDER_KEYS.MASCULINE
|
|
540
|
+
: gender === GENDERS.STREELINGA
|
|
541
|
+
? GENDER_KEYS.FEMININE
|
|
542
|
+
: GENDER_KEYS.NEUTER;
|
|
543
|
+
|
|
544
|
+
return {
|
|
545
|
+
word: clean,
|
|
546
|
+
devanagari,
|
|
547
|
+
gender,
|
|
548
|
+
genderKey,
|
|
549
|
+
pronoun,
|
|
550
|
+
label: `${gender} (${pronoun})`,
|
|
551
|
+
confidence: "dictionary",
|
|
552
|
+
isDual,
|
|
553
|
+
oppositeGender,
|
|
554
|
+
formatted: `${pronoun} ${devanagari}`
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// 2. Check opposite gender pairs table
|
|
559
|
+
if (OPPOSITE_GENDER_PAIRS[devanagari]) {
|
|
560
|
+
const opp = OPPOSITE_GENDER_PAIRS[devanagari];
|
|
561
|
+
// If opposite exists in dictionary, invert it!
|
|
562
|
+
const oppGender = MARATHI_GENDER_DICTIONARY[opp];
|
|
563
|
+
let gender = GENDERS.PULLINGA;
|
|
564
|
+
if (oppGender === GENDERS.PULLINGA) gender = GENDERS.STREELINGA;
|
|
565
|
+
else if (oppGender === GENDERS.STREELINGA) gender = GENDERS.PULLINGA;
|
|
566
|
+
else {
|
|
567
|
+
// Analyze suffix
|
|
568
|
+
gender = devanagari.endsWith("ी") || devanagari.endsWith("ीण") || devanagari.endsWith("िका")
|
|
569
|
+
? GENDERS.STREELINGA
|
|
570
|
+
: GENDERS.PULLINGA;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
const pronoun = PRONOUNS[gender];
|
|
574
|
+
return {
|
|
575
|
+
word: clean,
|
|
576
|
+
devanagari,
|
|
577
|
+
gender,
|
|
578
|
+
genderKey: gender === GENDERS.PULLINGA ? GENDER_KEYS.MASCULINE : GENDER_KEYS.FEMININE,
|
|
579
|
+
pronoun,
|
|
580
|
+
label: `${gender} (${pronoun})`,
|
|
581
|
+
confidence: "pair",
|
|
582
|
+
isDual: false,
|
|
583
|
+
oppositeGender: opp,
|
|
584
|
+
formatted: `${pronoun} ${devanagari}`
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
// 3. Morphological Rule Analysis
|
|
589
|
+
const ruleResult = analyzeGenderByMorphology(devanagari);
|
|
590
|
+
const pronoun = PRONOUNS[ruleResult.gender];
|
|
591
|
+
const genderKey = ruleResult.gender === GENDERS.PULLINGA
|
|
592
|
+
? GENDER_KEYS.MASCULINE
|
|
593
|
+
: ruleResult.gender === GENDERS.STREELINGA
|
|
594
|
+
? GENDER_KEYS.FEMININE
|
|
595
|
+
: GENDER_KEYS.NEUTER;
|
|
596
|
+
|
|
597
|
+
return {
|
|
598
|
+
word: clean,
|
|
599
|
+
devanagari,
|
|
600
|
+
gender: ruleResult.gender,
|
|
601
|
+
genderKey,
|
|
602
|
+
pronoun,
|
|
603
|
+
label: `${ruleResult.gender} (${pronoun})`,
|
|
604
|
+
confidence: ruleResult.confidence,
|
|
605
|
+
isDual: false,
|
|
606
|
+
oppositeGender: null,
|
|
607
|
+
formatted: `${pronoun} ${devanagari}`
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Returns the correct demonstrative pronoun ("तो", "ती", "ते") for a word.
|
|
613
|
+
* @param {string} word
|
|
614
|
+
* @returns {string}
|
|
615
|
+
*/
|
|
616
|
+
export function getPronoun(word) {
|
|
617
|
+
return getGender(word).pronoun;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Formats a word with its natural Marathi pronoun (e.g. "तो कांदा", "ती साखर", "ते तेल")
|
|
622
|
+
* @param {string} word
|
|
623
|
+
* @returns {string}
|
|
624
|
+
*/
|
|
625
|
+
export function formatWithPronoun(word) {
|
|
626
|
+
return getGender(word).formatted;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Returns the opposite gender counterpart if known (e.g. मुलगा -> मुलगी, घोडा -> घोडी).
|
|
631
|
+
* @param {string} word
|
|
632
|
+
* @returns {string | null}
|
|
633
|
+
*/
|
|
634
|
+
export function getOppositeGender(word) {
|
|
635
|
+
const result = getGender(word);
|
|
636
|
+
return result.oppositeGender;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Changes/inflects gender of a word if known.
|
|
641
|
+
* @param {string} word
|
|
642
|
+
* @returns {string} The inflected word or original if no known counterpart
|
|
643
|
+
*/
|
|
644
|
+
export function changeGender(word) {
|
|
645
|
+
const opposite = getOppositeGender(word);
|
|
646
|
+
return opposite || word;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Checks if a word is masculine (पुल्लिंग / तो)
|
|
651
|
+
* @param {string} word
|
|
652
|
+
* @returns {boolean}
|
|
653
|
+
*/
|
|
654
|
+
export function isMasculine(word) {
|
|
655
|
+
const res = getGender(word);
|
|
656
|
+
return res.gender === GENDERS.PULLINGA || res.isDual;
|
|
657
|
+
}
|
|
658
|
+
export const isPullinga = isMasculine;
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Checks if a word is feminine (स्त्रीलिंग / ती)
|
|
662
|
+
* @param {string} word
|
|
663
|
+
* @returns {boolean}
|
|
664
|
+
*/
|
|
665
|
+
export function isFeminine(word) {
|
|
666
|
+
const res = getGender(word);
|
|
667
|
+
return res.gender === GENDERS.STREELINGA || res.isDual;
|
|
668
|
+
}
|
|
669
|
+
export const isStreelinga = isFeminine;
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Checks if a word is neuter (नपुंसकलिंग / ते)
|
|
673
|
+
* @param {string} word
|
|
674
|
+
* @returns {boolean}
|
|
675
|
+
*/
|
|
676
|
+
export function isNeuter(word) {
|
|
677
|
+
const res = getGender(word);
|
|
678
|
+
return res.gender === GENDERS.NAPUNSAKLINGA;
|
|
679
|
+
}
|
|
680
|
+
export const isNapunsaklinga = isNeuter;
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Checks if a word has dual/common gender (उदा. बाग, वेळ)
|
|
684
|
+
* @param {string} word
|
|
685
|
+
* @returns {boolean}
|
|
686
|
+
*/
|
|
687
|
+
export function isDualGender(word) {
|
|
688
|
+
return getGender(word).isDual;
|
|
689
|
+
}
|
|
690
|
+
export const isUbhaya = isDualGender;
|
|
691
|
+
|
|
692
|
+
export default {
|
|
693
|
+
GENDERS,
|
|
694
|
+
GENDER_KEYS,
|
|
695
|
+
PRONOUNS,
|
|
696
|
+
OPPOSITE_GENDER_PAIRS,
|
|
697
|
+
MARATHI_GENDER_DICTIONARY,
|
|
698
|
+
getGender,
|
|
699
|
+
getPronoun,
|
|
700
|
+
formatWithPronoun,
|
|
701
|
+
getOppositeGender,
|
|
702
|
+
changeGender,
|
|
703
|
+
isMasculine,
|
|
704
|
+
isPullinga,
|
|
705
|
+
isFeminine,
|
|
706
|
+
isStreelinga,
|
|
707
|
+
isNeuter,
|
|
708
|
+
isNapunsaklinga,
|
|
709
|
+
isDualGender,
|
|
710
|
+
isUbhaya,
|
|
711
|
+
extendGenderDictionary
|
|
712
|
+
};
|
package/src/index.js
CHANGED
|
@@ -11,6 +11,51 @@ import { attachDevanagari } from "./dom.js";
|
|
|
11
11
|
|
|
12
12
|
export { MARATHI_DICTIONARY, fetchOnlineMarathi, attachDevanagari };
|
|
13
13
|
|
|
14
|
+
import {
|
|
15
|
+
GENDERS,
|
|
16
|
+
GENDER_KEYS,
|
|
17
|
+
PRONOUNS,
|
|
18
|
+
OPPOSITE_GENDER_PAIRS,
|
|
19
|
+
MARATHI_GENDER_DICTIONARY,
|
|
20
|
+
getGender,
|
|
21
|
+
getPronoun,
|
|
22
|
+
formatWithPronoun,
|
|
23
|
+
getOppositeGender,
|
|
24
|
+
changeGender,
|
|
25
|
+
isMasculine,
|
|
26
|
+
isPullinga,
|
|
27
|
+
isFeminine,
|
|
28
|
+
isStreelinga,
|
|
29
|
+
isNeuter,
|
|
30
|
+
isNapunsaklinga,
|
|
31
|
+
isDualGender,
|
|
32
|
+
isUbhaya,
|
|
33
|
+
extendGenderDictionary
|
|
34
|
+
} from "./gender.js";
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
GENDERS,
|
|
38
|
+
GENDER_KEYS,
|
|
39
|
+
PRONOUNS,
|
|
40
|
+
OPPOSITE_GENDER_PAIRS,
|
|
41
|
+
MARATHI_GENDER_DICTIONARY,
|
|
42
|
+
getGender,
|
|
43
|
+
getPronoun,
|
|
44
|
+
formatWithPronoun,
|
|
45
|
+
getOppositeGender,
|
|
46
|
+
changeGender,
|
|
47
|
+
isMasculine,
|
|
48
|
+
isPullinga,
|
|
49
|
+
isFeminine,
|
|
50
|
+
isStreelinga,
|
|
51
|
+
isNeuter,
|
|
52
|
+
isNapunsaklinga,
|
|
53
|
+
isDualGender,
|
|
54
|
+
isUbhaya,
|
|
55
|
+
extendGenderDictionary
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
|
|
14
59
|
/**
|
|
15
60
|
* Extends or overrides the global transliteration dictionary at runtime.
|
|
16
61
|
* @param {Record<string, string>} customWords - Map of English -> Marathi words
|
|
@@ -155,6 +200,31 @@ export function getSuggestions(word, options = {}) {
|
|
|
155
200
|
add(MARATHI_DICTIONARY[clean]);
|
|
156
201
|
}
|
|
157
202
|
|
|
203
|
+
// 1b. Priority spelling alternates for regional & cultural words
|
|
204
|
+
if (clean === "khandeshi" || clean === "khaandeshi") {
|
|
205
|
+
add("खानदेशी");
|
|
206
|
+
add("खांदेशी");
|
|
207
|
+
} else if (clean === "khandesh" || clean === "khaandesh") {
|
|
208
|
+
add("खानदेश");
|
|
209
|
+
add("खांदेश");
|
|
210
|
+
} else if (clean === "mandeshi" || clean === "maandeshi") {
|
|
211
|
+
add("मानदेशी");
|
|
212
|
+
add("मांदेशी");
|
|
213
|
+
} else if (clean === "mandesh" || clean === "maandesh") {
|
|
214
|
+
add("मानदेश");
|
|
215
|
+
add("मांदेश");
|
|
216
|
+
} else if (clean === "sindhi") {
|
|
217
|
+
add("सिन्धी");
|
|
218
|
+
} else if (clean === "kannada") {
|
|
219
|
+
add("कानडी");
|
|
220
|
+
} else if (clean === "kanadi") {
|
|
221
|
+
add("कन्नड");
|
|
222
|
+
} else if (clean === "vidarbha") {
|
|
223
|
+
add("विदर्भी");
|
|
224
|
+
} else if (clean === "vidarbhi") {
|
|
225
|
+
add("विदर्भीय");
|
|
226
|
+
}
|
|
227
|
+
|
|
158
228
|
// 2. Check local/memory cache
|
|
159
229
|
const cached = getCachedWord(clean);
|
|
160
230
|
if (cached) {
|
|
@@ -332,6 +402,38 @@ export function getSuggestions(word, options = {}) {
|
|
|
332
402
|
add(transiterateCompound(clean.slice(0, -5), "शेठ"));
|
|
333
403
|
}
|
|
334
404
|
|
|
405
|
+
// 4r. Khandesh, Mandesh & Regional alternate spellings (e.g. खान्देशी, खानदेशी, खांदेशी)
|
|
406
|
+
if (clean.startsWith("khandesh") || clean.startsWith("khaandesh")) {
|
|
407
|
+
add("खान्देशी");
|
|
408
|
+
add("खानदेशी");
|
|
409
|
+
add("खांदेशी");
|
|
410
|
+
add("खान्देश");
|
|
411
|
+
add("खानदेश");
|
|
412
|
+
add("खांदेश");
|
|
413
|
+
}
|
|
414
|
+
if (clean.startsWith("mandesh") || clean.startsWith("maandesh")) {
|
|
415
|
+
add("मान्देशी");
|
|
416
|
+
add("मानदेशी");
|
|
417
|
+
add("मान्देश");
|
|
418
|
+
add("मानदेश");
|
|
419
|
+
}
|
|
420
|
+
if (clean.startsWith("sindh")) {
|
|
421
|
+
add("सिंधी");
|
|
422
|
+
add("सिन्धी");
|
|
423
|
+
}
|
|
424
|
+
if (clean.startsWith("ahirani") || clean.startsWith("aahirani")) {
|
|
425
|
+
add("अहिराणी");
|
|
426
|
+
add("अहिराणि");
|
|
427
|
+
}
|
|
428
|
+
if (clean.startsWith("vidarbh")) {
|
|
429
|
+
add("विदर्भ");
|
|
430
|
+
add("विदर्भी");
|
|
431
|
+
add("विदर्भीय");
|
|
432
|
+
}
|
|
433
|
+
if (clean.startsWith("varhad") || clean.startsWith("warhad")) {
|
|
434
|
+
add("वऱ्हाड");
|
|
435
|
+
add("वऱ्हाडी");
|
|
436
|
+
}
|
|
335
437
|
}
|
|
336
438
|
|
|
337
439
|
// Background fetch to enrich cache if online (non-blocking)
|
|
@@ -367,5 +469,24 @@ export default {
|
|
|
367
469
|
extendDictionary,
|
|
368
470
|
normalizeMarathi,
|
|
369
471
|
MARATHI_DICTIONARY,
|
|
370
|
-
fetchOnlineMarathi
|
|
472
|
+
fetchOnlineMarathi,
|
|
473
|
+
GENDERS,
|
|
474
|
+
GENDER_KEYS,
|
|
475
|
+
PRONOUNS,
|
|
476
|
+
OPPOSITE_GENDER_PAIRS,
|
|
477
|
+
MARATHI_GENDER_DICTIONARY,
|
|
478
|
+
getGender,
|
|
479
|
+
getPronoun,
|
|
480
|
+
formatWithPronoun,
|
|
481
|
+
getOppositeGender,
|
|
482
|
+
changeGender,
|
|
483
|
+
isMasculine,
|
|
484
|
+
isPullinga,
|
|
485
|
+
isFeminine,
|
|
486
|
+
isStreelinga,
|
|
487
|
+
isNeuter,
|
|
488
|
+
isNapunsaklinga,
|
|
489
|
+
isDualGender,
|
|
490
|
+
isUbhaya,
|
|
491
|
+
extendGenderDictionary
|
|
371
492
|
};
|