twl-generator 1.2.8 → 1.2.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "twl-generator",
3
- "version": "1.2.8",
3
+ "version": "1.2.9",
4
4
  "description": "Generate term-to-article lists from unfoldingWord en_tw archive for Bible books. Works in both Node.js (CLI) and React.js (browser) environments.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -56,4 +56,4 @@
56
56
  "optional": true
57
57
  }
58
58
  }
59
- }
59
+ }
@@ -5,59 +5,61 @@ function generateVariants(term) {
5
5
  const variants = new Set([term]);
6
6
 
7
7
  const nouns = ['doe', 'deer', 'father', 'Father'];
8
+ const do_not_pluralize = ['doe'];
9
+ const do_not_depluralize = [];
8
10
 
9
11
  // Handle pluralization - simple 's' removal (but not for words ending in 'ss')
10
- if (term.endsWith('s') && term.length > 2 && !term.endsWith('ss') && !term.endsWith('es')) {
12
+ if (term.endsWith('s') && term.length > 2 && !term.endsWith('ss') && !term.endsWith('es') && !do_not_depluralize.includes(term)) {
11
13
  variants.add(term.slice(0, -1)); // dogs -> dog (but not does -> doe)
12
- } else {
14
+ } else if (!do_not_pluralize.includes(term)) {
13
15
  variants.add(term + 's'); // dog -> dogs
14
16
  }
15
17
 
16
18
  // Handle 'es' endings - but only for legitimate plural patterns
17
- if (term.endsWith('es') && term.length > 4) {
19
+ if (term.endsWith('es') && term.length > 4 && !do_not_depluralize.includes(term)) {
18
20
  const base = term.slice(0, -2);
19
21
  // Only if the base word would naturally take 'es' plural
20
22
  if (/[sxz]$|[cs]h$/.test(base)) {
21
23
  variants.add(base); // horses -> horse, churches -> church
22
24
  }
23
- } else if (term.endsWith('e')) {
25
+ } else if (term.endsWith('e') && !do_not_pluralize.includes(term)) {
24
26
  variants.add(term + 's'); // horse -> horses
25
- } else if (/[sxz]$|[cs]h$/.test(term)) {
27
+ } else if (/[sxz]$|[cs]h$/.test(term) && !do_not_pluralize.includes(term)) {
26
28
  variants.add(term + 'es'); // church -> churches
27
29
  }
28
30
 
29
31
  // Handle 'ies' endings for words ending in 'y'
30
- if (term.endsWith('ies') && term.length > 4) {
32
+ if (term.endsWith('ies') && term.length > 4 && !do_not_depluralize.includes(term)) {
31
33
  variants.add(term.slice(0, -3) + 'y'); // cities -> city
32
- } else if (term.endsWith('y') && term.length > 2 && !/[aeiou]y$/.test(term)) {
34
+ } else if (term.endsWith('y') && term.length > 2 && !/[aeiou]y$/.test(term) && !do_not_pluralize.includes(term)) {
33
35
  variants.add(term.slice(0, -1) + 'ies'); // city -> cities
34
36
  }
35
37
 
36
- // // Handle possessive forms
38
+ // // Handle possessive forms -- // Commented out since we use curly quotes
37
39
  // variants.add(term + "'s");
38
40
  // variants.add(term + "'");
39
41
  // if (term.endsWith('s')) {
40
42
  // variants.add(term + "'");
41
43
  // }
42
44
 
43
- // Handle -ed forms - but only for legitimate verb patterns
44
- if (term.endsWith('ed') && term.length > 4) {
45
- const base = term.slice(0, -2);
46
- // Only create base form if it looks like a legitimate verb stem
47
- if (base.length > 2) {
48
- variants.add(base); // walked -> walk
45
+ if (!nouns.includes(term)) {
46
+ // Handle -ed forms - but only for legitimate verb patterns
47
+ if (term.endsWith('ed') && term.length > 4) {
48
+ const base = term.slice(0, -2);
49
+ // Only create base form if it looks like a legitimate verb stem
50
+ if (base.length > 2) {
51
+ variants.add(base); // walked -> walk
52
+ }
49
53
  }
50
- }
51
54
 
52
- // Handle -ing forms
53
- if (term.endsWith('ing') && term.length > 5) {
54
- const base = term.slice(0, -3);
55
- if (base.length > 2) {
56
- variants.add(base); // walking -> walk
55
+ // Handle -ing forms
56
+ if (term.endsWith('ing') && term.length > 5) {
57
+ const base = term.slice(0, -3);
58
+ if (base.length > 2) {
59
+ variants.add(base); // walking -> walk
60
+ }
57
61
  }
58
- }
59
62
 
60
- if (!nouns.includes(term)) {
61
63
  // Double consonant handling for -ed/-ing
62
64
  if (/[bcdfghjklmnpqrstvwxyz][aeiou][bcdfghjklmnpqrstvwxyz]$/.test(term)) {
63
65
  variants.add(term + term.slice(-1) + 'ed'); // stop -> stopped