twl-generator 1.4.8 → 1.4.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.4.8",
3
+ "version": "1.4.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": {
@@ -43,12 +43,21 @@ async function processZipBuffer(zipBuffer) {
43
43
  for (const term of terms) {
44
44
  // Normalize terms by removing parentheses and spaces before them
45
45
  // e.g., "Joseph (OT)" -> "Joseph", "Mary (sister of Martha)" -> "Mary"
46
- const normalizedTerm = term.replace(/\s+\([^)]*\)$/, '').trim();
46
+ let normalizedTerm = term.replace(/\s+\([^)]*\)$/, '').trim();
47
+ // Strip leading articles, demonstratives, and possessive pronouns (allow repeated prefixes)
48
+ const prefixRegex = /^(?:(?:a|an|the|this|that|these|those|my|your|his|her|its|our|their)\s+)+/i;
49
+ let cleaned = normalizedTerm.trim();
50
+ while (prefixRegex.test(cleaned)) {
51
+ cleaned = cleaned.replace(prefixRegex, '').trim();
52
+ }
53
+ normalizedTerm = cleaned;
47
54
 
48
55
  if (!termMap[normalizedTerm]) {
49
56
  termMap[normalizedTerm] = [];
50
57
  }
51
- termMap[normalizedTerm].push(truncated);
58
+ if (!termMap[normalizedTerm].includes(truncated)) {
59
+ termMap[normalizedTerm].push(truncated);
60
+ }
52
61
  }
53
62
  }
54
63