greek-name-correction 2.0.0 → 2.1.1

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 CHANGED
@@ -13,7 +13,8 @@ A powerful, zero-dependency Node.js library for correcting, formatting, and vali
13
13
  🔄 **Transliteration** - Greeklish ↔ Greek ↔ Latin
14
14
  📝 **Smart Formatting** - Proper capitalization and syntax
15
15
  👔 **Title Support** - Handles Greek honorifics (Δρ., Καθ., etc.)
16
- 🔀 **Genitive Conversion** - Automatic του/της forms
16
+ 🎩 **Auto Title Addition** - Automatically adds general titles (Κ. for men, Κα for women)
17
+ 🔀 **Case Conversion** - Genitive, vocative, and accusative forms
17
18
  🎯 **Gender Detection** - Identifies gender from name endings
18
19
  📊 **Statistics** - Comprehensive name analysis
19
20
  🔍 **Diminutive Detection** - Recognizes nickname patterns
@@ -122,10 +123,60 @@ GreekNameCorrection('Γιώργος Παπαδόπουλος', {
122
123
  });
123
124
  // → {
124
125
  // corrected: "Γιώργος Παπαδόπουλος",
125
- // genitive: "Γιώργος Παπαδόπουλου"
126
+ // genitive: "Γιώργου Παπαδόπουλου"
126
127
  // }
127
128
  ```
128
129
 
130
+ ### Vocative Case Conversion
131
+ ```javascript
132
+ // Convert to vocative case (for addressing someone)
133
+ GreekNameCorrection('Γιώργος Παπαδόπουλος', {
134
+ convertToCase: 'vocative'
135
+ });
136
+ // → "Γιώργο Παπαδόπουλο"
137
+
138
+ // With preserveOriginal to get both forms
139
+ GreekNameCorrection('Γιάννης Αλεξίου', {
140
+ convertToCase: 'vocative',
141
+ preserveOriginal: true
142
+ });
143
+ // → {
144
+ // corrected: "Γιάννης Αλεξίου",
145
+ // vocative: "Γιάννη Αλεξίου"
146
+ // }
147
+
148
+ // Feminine names usually remain unchanged
149
+ GreekNameCorrection('Μαρία Κωνσταντίνου', {
150
+ convertToCase: 'vocative'
151
+ });
152
+ // → "Μαρία Κωνσταντίνου"
153
+ ```
154
+
155
+ ### Accusative Case Conversion
156
+ ```javascript
157
+ // Convert to accusative case (for direct objects)
158
+ GreekNameCorrection('Γιώργος Παπαδόπουλος', {
159
+ convertToCase: 'accusative'
160
+ });
161
+ // → "Γιώργο Παπαδόπουλο"
162
+
163
+ // With preserveOriginal to get both forms
164
+ GreekNameCorrection('Κώστας Παπαδάκης', {
165
+ convertToCase: 'accusative',
166
+ preserveOriginal: true
167
+ });
168
+ // → {
169
+ // corrected: "Κώστας Παπαδάκης",
170
+ // accusative: "Κώστα Παπαδάκη"
171
+ // }
172
+
173
+ // Feminine names usually remain unchanged
174
+ GreekNameCorrection('Μαρία Κωνσταντίνου', {
175
+ convertToCase: 'accusative'
176
+ });
177
+ // → "Μαρία Κωνσταντίνου"
178
+ ```
179
+
129
180
  ### Title Handling
130
181
  ```javascript
131
182
  GreekNameCorrection('δρ. γιώργος παπαδόπουλος', {
@@ -138,6 +189,39 @@ GreekNameCorrection('δρ. γιώργος παπαδόπουλος', {
138
189
  // }
139
190
  ```
140
191
 
192
+ ### Automatic General Title Addition
193
+ ```javascript
194
+ // Add general title (κ. for men, κα for women) if no title exists
195
+ // Titles are always lowercase
196
+ GreekNameCorrection('Γιώργος Παπαδόπουλος', {
197
+ addGeneralTitle: true
198
+ });
199
+ // → "κ. Γιώργος Παπαδόπουλος"
200
+
201
+ GreekNameCorrection('Μαρία Κωνσταντίνου', {
202
+ addGeneralTitle: true
203
+ });
204
+ // → "κα Μαρία Κωνσταντίνου"
205
+
206
+ // Names with existing titles are not modified
207
+ GreekNameCorrection('Δρ. Γιώργος Παπαδόπουλος', {
208
+ addGeneralTitle: true
209
+ });
210
+ // → "Δρ. Γιώργος Παπαδόπουλος"
211
+
212
+ // Works with preserveOriginal option
213
+ GreekNameCorrection('Ελένη Γεωργίου', {
214
+ addGeneralTitle: true,
215
+ preserveOriginal: true
216
+ });
217
+ // → {
218
+ // corrected: "κα Ελένη Γεωργίου",
219
+ // original: "Ελένη Γεωργίου",
220
+ // title: "κα",
221
+ // isValid: true
222
+ // }
223
+ ```
224
+
141
225
  ### Name Corrections
142
226
  ```javascript
143
227
  GreekNameCorrection('γιοργος παπαδοπουλος', {
@@ -258,9 +342,11 @@ GreekNameCorrection(input, options)
258
342
  | `removeExtraSpaces` | `boolean` | `true` | Remove extra whitespace |
259
343
  | `handleParticles` | `boolean` | `true` | Handle Greek particles (του/της/των) |
260
344
  | `convertToGenitive` | `boolean` | `false` | Convert to genitive case |
345
+ | `convertToCase` | `string\|null` | `null` | Convert to case: `'vocative'` or `'accusative'` |
261
346
  | `transliterate` | `string\|null` | `null` | Transliteration mode: `'greeklish-to-greek'`, `'greek-to-latin'`, `'greek-to-greeklish'` |
262
347
  | `detectDiminutive` | `boolean` | `false` | Detect diminutive/nickname forms |
263
348
  | `handleTitles` | `boolean` | `true` | Extract and format titles |
349
+ | `addGeneralTitle` | `boolean` | `false` | Automatically add general title (κ. for men, κα for women) if no title exists (always lowercase) |
264
350
  | `suggestCorrections` | `boolean` | `false` | Suggest corrections for misspellings |
265
351
  | `recognizeKatharevousa` | `boolean` | `false` | Convert archaic Greek forms |
266
352
  | `databaseSafe` | `boolean` | `false` | Remove problematic characters |
@@ -286,6 +372,8 @@ When `preserveOriginal: true`, returns an object with:
286
372
  parts?: Object, // Name parts (if splitNames)
287
373
  diminutive?: Array, // Diminutive info (if detectDiminutive)
288
374
  genitive?: string, // Genitive form (if convertToGenitive)
375
+ vocative?: string, // Vocative form (if convertToCase: 'vocative')
376
+ accusative?: string, // Accusative form (if convertToCase: 'accusative')
289
377
  sortKey?: string, // Sort key (if generateSortKey)
290
378
  statistics?: Object, // Name statistics (if statistics)
291
379
  wasCorrected?: boolean, // If corrections were applied
@@ -303,6 +391,14 @@ The library recognizes and properly formats the following Greek titles:
303
391
  - **Religious**: Αρχιεπίσκοπος, Μητροπολίτης, Επίσκοπος, Πατήρ
304
392
  - **Military**: Στρατηγός, Ταξίαρχος, Συνταγματάρχης, Αντισυνταγματάρχης
305
393
 
394
+ ### Automatic General Title Addition
395
+
396
+ When `addGeneralTitle: true` is enabled, the library automatically adds general titles based on detected gender:
397
+ - **κ.** (κύριος) for male names
398
+ - **κα** (κυρία) for female names
399
+
400
+ **Note:** General titles are always added in lowercase format. This feature only adds titles when no existing title is detected, ensuring that professional or academic titles are preserved.
401
+
306
402
  ## Common Name Corrections
307
403
 
308
404
  The library automatically corrects common Greek name misspellings:
@@ -347,6 +443,7 @@ const result = GreekNameCorrection('dr giorgos tou papa', {
347
443
  transliterate: 'greeklish-to-greek',
348
444
  preserveOriginal: true,
349
445
  handleTitles: true,
446
+ addGeneralTitle: true,
350
447
  handleParticles: true,
351
448
  suggestCorrections: true,
352
449
  detectGender: true,
@@ -448,6 +545,20 @@ const recipient = GreekNameCorrection(name, {
448
545
  });
449
546
 
450
547
  console.log(`Προς: ${recipient.genitive}`);
548
+
549
+ // Use vocative case for addressing someone
550
+ const addressee = GreekNameCorrection('Γιώργος Παπαδόπουλος', {
551
+ convertToCase: 'vocative'
552
+ });
553
+
554
+ console.log(`Αγαπητέ ${addressee},`); // "Αγαπητέ Γιώργο Παπαδόπουλο,"
555
+
556
+ // Use accusative case for direct objects
557
+ const object = GreekNameCorrection('Δημήτρης Νικολάου', {
558
+ convertToCase: 'accusative'
559
+ });
560
+
561
+ console.log(`Είδα τον ${object}`); // "Είδα τον Δημήτρη Νικολάου"
451
562
  ```
452
563
 
453
564
  ### 5. Gender-Based Processing
@@ -494,7 +605,7 @@ Contributions are welcome! Please feel free to submit a Pull Request. For major
494
605
  ### Development
495
606
  ```bash
496
607
  # Clone the repository
497
- git clone https://github.com/yourusername/greek-name-correction.git
608
+ git clone https://github.com/sraftopo/greek-name-correction.git
498
609
 
499
610
  # Install dependencies (none currently!)
500
611
  npm install
@@ -513,8 +624,9 @@ The test suite covers:
513
624
  - Array processing
514
625
  - Object processing
515
626
  - All transliteration modes
516
- - Genitive conversion
627
+ - Case conversions (genitive, vocative, accusative)
517
628
  - Title handling
629
+ - Automatic general title addition
518
630
  - Diminutive detection
519
631
  - Gender detection
520
632
  - Statistics generation
@@ -522,9 +634,18 @@ The test suite covers:
522
634
 
523
635
  ## Changelog
524
636
 
525
- ### Version 2.0.0 (Current)
637
+ ### Version 2.1.1 (Current)
638
+ - ✨ **Automatic General Title Addition** - Added `addGeneralTitle` option to automatically add general titles (κ. for men, κα for women) when no title exists
639
+
640
+ ### Version 2.1.0
641
+ - 🏗️ **Modular Architecture** - Complete codebase refactoring into logical modules
642
+ - 📦 **Improved Structure** - Separated into `transliteration.js`, `cases.js`, `validation.js`, `utils.js`, `constants.js`
643
+ - 🔧 **Better Maintainability** - Clean separation of concerns for easier testing and development
644
+ - ✨ **Enhanced Code Organization** - Each module has a single, clear responsibility
645
+
646
+ ### Version 2.0.0
526
647
  - ✨ Added transliteration support (Greeklish ↔ Greek ↔ Latin)
527
- - ✨ Added genitive case conversion
648
+ - ✨ Added case conversion (genitive, vocative, accusative)
528
649
  - ✨ Added diminutive detection
529
650
  - ✨ Added title/honorific support
530
651
  - ✨ Added name correction suggestions
@@ -548,7 +669,7 @@ MIT © Stavros
548
669
 
549
670
  ## Support
550
671
 
551
- For bugs, questions, and discussions please use the [GitHub Issues](https://github.com/yourusername/greek-name-correction/issues).
672
+ For bugs, questions, and discussions please use the [GitHub Issues](https://github.com/sraftopo/greek-name-correction/issues).
552
673
 
553
674
  ## Acknowledgments
554
675
 
@@ -565,4 +686,4 @@ Special thanks to all contributors and users who help improve this library.
565
686
 
566
687
  **Made in Greece 🇬🇷**
567
688
 
568
- If you find this library helpful, please consider giving it a ⭐️ on GitHub!
689
+ If you find this library helpful, please consider giving it a ⭐️ on GitHub!