twl-generator 1.4.6 → 1.4.8

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.
Files changed (2) hide show
  1. package/package.json +2 -1
  2. package/src/index.js +7 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "twl-generator",
3
- "version": "1.4.6",
3
+ "version": "1.4.8",
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": {
@@ -49,6 +49,7 @@
49
49
  "compromise": "^14.14.2",
50
50
  "csv-parse": "^5.5.6",
51
51
  "csv-stringify": "^6.5.0",
52
+ "en-inflectors": "^1.0.12",
52
53
  "jszip": "^3.10.1",
53
54
  "tsv-quote-converters": "^1.1.14"
54
55
  },
package/src/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { BibleBookData } from './common/books.js';
2
2
  import { addGLQuoteCols, convertGLQuotes2OLQuotes } from 'tsv-quote-converters';
3
+ import { Inflectors } from 'en-inflectors';
3
4
 
4
5
  const isBrowser = typeof window !== 'undefined';
5
6
 
@@ -880,7 +881,7 @@ export async function generateTwlByBook(bookCode, options = {}) {
880
881
  if (/[^aeiou]y$/i.test(w)) return w.replace(/y$/i, 'ied');
881
882
  // Do not double the final consonant for words ending in "er" (e.g., gather -> gathered)
882
883
  const lastCh = w[w.length - 1];
883
- if (endsWithCVC(w) && !/(?:er|en|or|on|al|el)$/i.test(w)) return w + lastCh + 'ed';
884
+ if (endsWithCVC(w) && !/(?:er|en|or|on|al)$/i.test(w)) return w + lastCh + 'ed';
884
885
  return w + 'ed';
885
886
  };
886
887
  const ingForm = (w) => {
@@ -888,7 +889,7 @@ export async function generateTwlByBook(bookCode, options = {}) {
888
889
  if (/ee$/i.test(w)) return w + 'ing';
889
890
  if (/e$/i.test(w)) return w.replace(/e$/i, 'ing');
890
891
  const lastCh = w[w.length - 1];
891
- if (endsWithCVC(w) && !/(?:er|en|or|on|al|el)$/i.test(w)) return w + lastCh + 'ing';
892
+ if (endsWithCVC(w) && !/(?:er|en|or|on|al)$/i.test(w)) return w + lastCh + 'ing';
892
893
  return w + 'ing';
893
894
  };
894
895
 
@@ -902,8 +903,12 @@ export async function generateTwlByBook(bookCode, options = {}) {
902
903
  const last = parts[parts.length - 1];
903
904
  const allowed = new Set([
904
905
  head + pluralizeWord(last),
906
+ head + new Inflectors(last).toPlural(),
907
+ head + new Inflectors(last).toSingular(),
905
908
  head + edForm(last),
909
+ head + new Inflectors(last).toPast(),
906
910
  head + ingForm(last),
911
+ head + new Inflectors(last).toGerund(),
907
912
  ].map(x => x.toLowerCase()));
908
913
  return allowed.has(m.toLowerCase());
909
914
  };