scripture-guide 1.0.32 → 1.0.34

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/cmd.js CHANGED
@@ -6,5 +6,5 @@ const input = process.argv[2]
6
6
  const lang = process.argv[3] || null;
7
7
  if(lang) setLanguage(lang);
8
8
  console.log("Input: ", input)
9
- const isVerseIds = /[0-9,-]+/.test(input);
9
+ const isVerseIds = /^[0-9,-]+$/.test(input);
10
10
  console.log(isVerseIds ? generateReference(input) : parse(input))
@@ -1,4 +1,5 @@
1
1
 
2
+
2
3
  const prepareBlacklist = (lang_extras) => {
3
4
  var blacklist = [];
4
5
  blacklist.push("\\d{4,}"); // 4 Digit references
@@ -12,12 +13,228 @@ const prepareBlacklist = (lang_extras) => {
12
13
  blacklist.push("\\b(AC3|PS2|PS3|PS4)\\b"); //Common file extentions
13
14
  blacklist.push("\\b(ps|PS)[1-9]\\b"); //Common file extentions'
14
15
 
16
+ //Increase strictness for abbreviations
17
+ blacklist.push("\\b[a-z][a-z] [0-9]"); //lowercase 2-letter abbreviation
18
+
15
19
 
16
20
  var blacklist_pattern = new RegExp("(" + blacklist.join("|") + ")", 'g');
17
21
 
18
22
  return blacklist_pattern;
19
23
  }
20
24
 
25
+
26
+ const findMatchingBooks = (content,books) => {
27
+ const matchingBooks = books.filter(i=>(new RegExp(i,"ig")).test(content));
28
+ return matchingBooks;
29
+ }
30
+
31
+ const findMatches = (content,books,lang_extra) => {
32
+
33
+ const preBookMatch = lang_extra.book || `(First|I|1|1st|Second|II|2|2nd|Third|III|3|3rd|Fourth|IV|4|4th)*\\s*(books* of)*\\s*`;
34
+ const matchingBooks = findMatchingBooks(content,books);
35
+ const postBookMatch = lang_extra.chapter || "([0-9:;,~ —–-])*[0-9]+";
36
+ const matchesWithReferences = matchingBooks.map(bookMatch=>{
37
+ const patternString = preBookMatch + bookMatch + postBookMatch;
38
+ const pattern = (new RegExp(patternString,"ig"));
39
+ const stringMatch = pattern.test(content) ? patternString : null;
40
+ //console.log({pattern,content,stringMatch});
41
+ return stringMatch;
42
+ }).filter(x=>!!x);
43
+
44
+
45
+
46
+ // Ensure the match ends with a number
47
+ // Also remove duplicates that may have been created by the postBookMatch
48
+ return matchesWithReferences.map(string=>{
49
+ const pattern = (new RegExp(string,"ig"));
50
+ const matches = content.match(pattern)?.map(i=>i.trim().replace(/[^0-9]+$/,""));
51
+ return matches;
52
+ }).flat()
53
+ .reduce((prev,current)=>{
54
+ if(prev.includes(current)) return prev;
55
+ return [...prev,current]
56
+ },[]).filter(i=>!!i);
57
+
58
+
59
+
60
+
61
+ //TODO: Process on a language by language basis
62
+ // 2. Prebook JST
63
+ // 3. Prechapter (, chapter, ch)
64
+ // 4. Preverse (, verse, v, vv, vv, vvv)
65
+ // 5. Joiners (,;and, &, cf, etc)
66
+ }
67
+
68
+
69
+
70
+ function findMatchIndexes(content, matches,lookupReference) {
71
+ const indexes = matches.map(i=>{
72
+ const length = i.length;
73
+ let positions = [];
74
+ let strPos = content.indexOf(i);
75
+ while (strPos != -1) {
76
+ positions.push(strPos);
77
+ strPos = content.indexOf(i, strPos + 1);
78
+ }
79
+ return positions.map(i=>[i,i+length]);
80
+ }).flat()
81
+ .filter(a=>{
82
+
83
+ const substring = content.substring(a[0],a[1]);
84
+ const charRightBeforeMatch = content.substring(a[0]-1,a[0]);
85
+ if(!/(^|\s|\W)/.test(charRightBeforeMatch)) return false;
86
+ const verse_ids = lookupReference(substring).verse_ids;
87
+ // console.log({a,substring,verse_ids});
88
+ if(verse_ids.length > 0) return true;
89
+
90
+
91
+ return false;
92
+ })
93
+ .sort((a, b) => a[0] - b[0]);
94
+
95
+
96
+
97
+ if(!indexes.length) return false;
98
+
99
+
100
+ const tieBreaker = (pair1,pair2)=>{
101
+ const string1 = content.substring(pair1[0],pair1[1]);
102
+ const string2 = content.substring(pair2[0],pair2[1]);
103
+
104
+ // if one pair is all lower case, return the other one
105
+ if(/[^A-Z]/.test(string1) && !/[^A-Z]/.test(string2)) return pair2;
106
+ if(/[^A-Z]/.test(string2) && !/[^A-Z]/.test(string1)) return pair1;
107
+
108
+ if(string1.length > string2.length) return pair1;
109
+ if(string2.length > string1.length) return pair2;
110
+
111
+ return pair1;
112
+ }
113
+
114
+
115
+ const nonOverlappingIndeces = indexes.reduce((prev, current) => {
116
+ if (prev.length === 0) {
117
+ return [current];
118
+ }
119
+ const lastPair = prev[prev.length - 1];
120
+ if (current[0] < lastPair[1]) { // They overlap
121
+ const chosenPair = tieBreaker(lastPair, current);
122
+ if (chosenPair === lastPair) {
123
+ // Keep the last pair, discard the current one
124
+ return prev;
125
+ } else {
126
+ // Replace the last pair with the current one
127
+ prev.pop();
128
+ return [...prev, current];
129
+ }
130
+ } else {
131
+ // They don't overlap, add the current pair
132
+ return [...prev, current];
133
+ }
134
+ }, []);
135
+
136
+
137
+ return nonOverlappingIndeces;
138
+
139
+
140
+
141
+ }
142
+
143
+
144
+
145
+
146
+
147
+ const processReferenceDetection = (content,books,lang_extra,lookupReference,callback) =>
148
+ {
149
+ lang_extra = lang_extra || {};
150
+ const matches = findMatches(content,books,lang_extra);
151
+
152
+
153
+ const matchIndeces = findMatchIndexes(content,matches,lookupReference);
154
+ if(!matchIndeces) return content;
155
+
156
+
157
+ const gapsBetweenIndeces = matchIndeces.reduce((prev,current,index)=>{
158
+ if(index === 0) return prev;
159
+ const lastPair = matchIndeces[index-1];
160
+ const gap = [lastPair[1],current[0]];
161
+ return [...prev,gap];
162
+ },[]);
163
+
164
+
165
+
166
+
167
+ joiners = lang_extra.joiners || ["^[;, ]*(and|c\.*f\.*)*$"];
168
+ const gapThatMayBeMerged = gapsBetweenIndeces.map(([start,end])=>{
169
+ const string = content.substring(start,end).trim();
170
+ const canBeMerged = joiners.some(joiner=>(new RegExp(joiner,"ig")).test(string));
171
+ return canBeMerged;
172
+ });
173
+
174
+
175
+
176
+ // new incexes
177
+ const mergedIndeces = matchIndeces.reduce((prev, current, index) => {
178
+ if (index === 0) {
179
+ return [current];
180
+ } else {
181
+ const prevIndex = prev[prev.length - 1];
182
+ if (gapThatMayBeMerged[index - 1]) {
183
+ const merged = [prevIndex[0], current[1]];
184
+ prev[prev.length - 1] = merged;
185
+ } else {
186
+ prev.push(current);
187
+ }
188
+ return prev;
189
+ }
190
+ }, []);
191
+
192
+ //get the gaps and the front/end bumpers if any
193
+ const negativeSpace = mergedIndeces.reduce((prev, current, index, array) => {
194
+ if (index !== 0) {
195
+ const prevIndex = array[index - 1];
196
+ const gap = [prevIndex[1], current[0]];
197
+ prev.push(gap);
198
+ }
199
+ return prev;
200
+ }, []);
201
+
202
+ if (mergedIndeces[0][0] !== 0) {
203
+ negativeSpace.unshift([0, mergedIndeces[0][0]]);
204
+ }
205
+
206
+ if (mergedIndeces[mergedIndeces.length - 1][1] !== content.length) {
207
+ negativeSpace.push([mergedIndeces[mergedIndeces.length - 1][1], content.length]);
208
+ }
209
+
210
+
211
+ //check content between matches. If puctuation only (or 'and'), then merge
212
+
213
+ const cutItems = mergedIndeces.map(([start,end])=>{
214
+ return lookupReference(content.substring(start,end)).query
215
+ }).map(callback);
216
+
217
+ const negativeItems = negativeSpace.map(([start,end])=>content.substring(start,end));
218
+
219
+ const firstReferenceIsAtStart = mergedIndeces[0][0] === 0;
220
+ const maxCount = Math.max(cutItems.length,negativeItems.length);
221
+ //merge by alternating cutItems and negativeItems. run the callback on the cut items
222
+ const merged = [];
223
+
224
+ for(i=0;i<maxCount;i++){
225
+ const firstItem = firstReferenceIsAtStart ? cutItems[i] : negativeItems[i];
226
+ const secondItem = firstReferenceIsAtStart ? negativeItems[i] : cutItems[i];
227
+ if(firstItem) merged.push(firstItem);
228
+ if(secondItem) merged.push(secondItem);
229
+ }
230
+
231
+
232
+ return merged.join("");
233
+
234
+
235
+ }
236
+
237
+
21
238
  const preparePattern = (booklist,wordBreak,lang_extras) => {
22
239
 
23
240
 
@@ -81,5 +298,6 @@ const preparePattern = (booklist,wordBreak,lang_extras) => {
81
298
 
82
299
  module.exports = {
83
300
  prepareBlacklist,
84
- preparePattern
301
+ preparePattern,
302
+ processReferenceDetection
85
303
  }
@@ -1,10 +1,11 @@
1
1
  module.exports = {
2
2
  ko:{
3
- books:{ "창세기": ["창"], "출애굽기": ["출", "탈출기"], "레위기": ["레"], "민수기": ["민"], "신명기": ["신"], "여호수아": ["수"], "사사기": ["삿", "판관기"], "룻기": ["룻"], "사무엘상": ["삼상"], "사무엘하": ["삼하"], "열왕기상": ["왕상"], "열왕기하": ["왕하"], "역대상": ["대상", "역대기 상"], "역대하": ["대하", "역대기 하"], "에스라": ["스", "에즈라"], "느헤미야": ["느"], "에스더": ["에", "에스텔"], "욥기": ["욥"], "시편": ["시"], "잠언": ["잠"], "전도서": ["전", "코헬렛"], "아가": ["아"], "이사야": ["사", "이사야서"], "예레미야": ["렘", "예레미야서"], "예레미야애가": ["애"], "에스겔": ["겔", "에제키엘"], "다니엘": ["단", "다니엘서"], "호세아": ["호", "호세아서"], "요엘": ["욜", "요엘서"], "아모스": ["암", "아모스서"], "오바댜": ["옵", "오바댜서", "오바디야"], "요나": ["욘", "요나서"], "미가": ["미", "미가서"], "나훔": ["나", "나훔서"], "하박국": ["합", "[하합]박[꾹국]서*"], "스바냐": ["습", "스바니야"], "학개": ["학", "하깨"], "스가랴": ["슥", "즈가리야"], "말라기": ["말", "말라기서"], "마태복음": ["마", "마태", "마태오 복음서", "마태오의 복음서"], "마가복음": ["막", "마가", "마르코 복음서"], "누가복음": ["눅","[루누][가카]","[루누][가카] *복음서*"], "요한복음": ["요", "요한", "요한 *복음서*"], "사도행전": ["사*도*행전*","악"], "로마서": ["롬", "로마인들에게 보낸 편지"], "고린도전서": ["고전", "코린토1서"], "고린도후서": ["고후", "코린토2서"], "갈라디아서": ["갈"], "에베소서": ["엡", "에페소인들에게 보낸 편지"], "빌립보서": ["빌", "필리피서"], "골로새서": ["골", "콜로새서"], "데살로니가전서": ["살전", "테살로니카1서"], "데살로니가후서": ["살후", "테살로니카2서"], "디모데전서": ["딤전", "티모테오1서"], "디모데후서": ["딤후", "티모테오2서", "티모테후서"], "디도서": ["딛", "티토서"], "빌레몬서": ["몬", "필레몬서"], "히브리서": ["히"], "야고보서": ["약"], "베드로전서": ["베드로 전서","벧전", "베드로1서"], "베드로후서": ["베드로 후서", "벧후", "베드로2서"], "요한일서": ["요1", "요(일|1)", "(일|1)요"], "요한이서": ["요2", "요(이|2)", "(이|2)요"], "요한삼서": ["요3", "요(삼|3)", "(삼|3)요"], "유다서": ["유다*", "유다의 편지"], "요한 계시록": ["계시*록*", "요한 *[묵계]시록"], "니파이전서": ["니전"], "니파이후서": ["니후"], "야곱서": ["야곱"], "이노스서": ["이노", "이노스서"], "예이롬서": ["예이", "예이롬"], "옴나이서": ["옴", "옴나이"], "몰몬의 말씀": ["몰말", "몰몬말씀"], "모사이야서": ["모사", "모사이야"], "앨마서": ["앨", "앨마"], "힐라맨서": ["힐", "힐라맨"], "제3니파이": ["3니", "제*3니파이서*"], "제4니파이": ["4니", "제*4니파이서*"], "몰몬서": ["몰", "몰몬"], "이더서": ["이더"], "모로나이서": ["모로", "모로나이"], "교리와 성약": ["교성", "교리성약"], "모세서": ["모세"], "아브라함서": ["아브", "아브라함"], "조셉 스미스—마태복음": ["조마", "조셉 스미스—마태"], "조셉 스미스—역사": ["조역", "조셉 스미스—역사"], "신앙개조": ["신개"] },
3
+ books:{ "창세기": ["창"], "출애굽기": ["출", "탈출기"], "레위기": ["레"], "민수기": ["민"], "신명기": ["신"], "여호수아": ["수"], "사사기": ["삿", "판관기"], "룻기": ["룻"], "사무엘상": ["삼상"], "사무엘하": ["삼하"], "열왕기상": ["왕상"], "열왕기하": ["왕하"], "역대상": ["대상", "역대기 *상"], "역대하": ["대하", "역대기 *하"], "에스라": ["스", "에즈라"], "느헤미야": ["느"], "에스더": ["에", "에스텔"], "욥기": ["욥"], "시편": ["시"], "잠언": ["잠"], "전도서": ["전", "코헬렛"], "아가": ["아"], "이사야": ["사", "이사야서"], "예레미야": ["렘", "예레미야서"], "예레미야애가": ["애"], "에스겔": ["겔", "에제키엘"], "다니엘": ["단", "다니엘서"], "호세아": ["호", "호세아서"], "요엘": ["욜", "요엘서"], "아모스": ["암", "아모스서"], "오바댜": ["옵", "오바댜서", "오바디야"], "요나": ["욘", "요나서"], "미가": ["미", "미가서"], "나훔": ["나", "나훔서"], "하박국": ["합", "[하합]박[꾹국]서*"], "스바냐": ["습", "스바니야"], "학개": ["학", "하깨"], "스가랴": ["슥", "즈가리야"], "말라기": ["말", "말라기서"], "마태복음": ["마", "마태", "마태오 복음서", "마태오의 복음서"], "마가복음": ["막", "마가", "마르코 복음서"], "누가복음": ["눅","[루누][가카]","[루누][가카] *복음서*"], "요한복음": ["요", "요한", "요한 *복음서*"], "사도행전": ["사*도*행전*","악"], "로마서": ["롬", "로마인들에게 보낸 편지"], "고린도전서": ["고전", "코린토1서"], "고린도후서": ["고후", "코린토2서"], "갈라디아서": ["갈"], "에베소서": ["엡", "에페소인들에게 보낸 편지"], "빌립보서": ["빌", "필리피서"], "골로새서": ["골", "콜로새서"], "데살로니가전서": ["살전", "테살로니카1서"], "데살로니가후서": ["살후", "테살로니카2서"], "디모데전서": ["딤전", "티모테오1서"], "디모데후서": ["딤후", "티모테오2서", "티모테후서"], "디도서": ["딛", "티토서"], "빌레몬서": ["몬", "필레몬서"], "히브리서": ["히"], "야고보서": ["약"], "베드로전서": ["베드로 전서","벧전", "베드로1서"], "베드로후서": ["베드로 후서", "벧후", "베드로2서"], "요한일서": ["요1", "요(일|1)", "(일|1)요"], "요한이서": ["요2", "요(이|2)", "(이|2)요"], "요한삼서": ["요3", "요(삼|3)", "(삼|3)요"], "유다서": ["유다*", "유다의 편지"], "요한 계시록": ["계시*록*", "요한 *[묵계]시록"], "니파이전서": ["니전"], "니파이후서": ["니후"], "야곱서": ["야곱"], "이노스서": ["이노", "이노스서"], "예이롬서": ["예이", "예이롬"], "옴나이서": ["옴", "옴나이"], "몰몬의 말씀": ["몰말", "몰몬말씀"], "모사이야서": ["모사", "모사이야"], "앨마서": ["앨", "앨마"], "힐라맨서": ["힐", "힐라맨"], "제3니파이": ["3니", "제*3니파이서*"], "제4니파이": ["4니", "제*4니파이서*"], "몰몬서": ["몰", "몰몬"], "이더서": ["이더"], "모로나이서": ["모로", "모로나이"], "교리와 성약": ["교성", "교리성약"], "모세서": ["모세"], "아브라함서": ["아브", "아브라함"], "조셉 스미스—마태복음": ["조마", "조셉 스미스—마태"], "조셉 스미스—역사": ["조역", "조셉 스미스—역사"], "신앙개조": ["신개"] },
4
4
  pre_rules: [
5
5
  //handle 1장 2절-3절
6
6
  //turn 30 장 10 절 into 30장 10절
7
7
  ["(\\d+)\\s*장\\s*(\\d+)(?:~|-)(\\d+)\\s*절*", "$1:$2-$3"],
8
+ ["(비교|또는*|그리고)", ";"],
8
9
  //handle 1장 2절
9
10
  ["(\\d+)\\s*장\\s*(\\d+)\\s*절*", "$1:$2"],
10
11
  ["~", "-"],
@@ -26,10 +27,13 @@ module.exports = {
26
27
  ["\\s+", " "],
27
28
  ["제\\s*([3-4])장\\s*니파이", "제$1니파이"],
28
29
  ["([0-9]+)장\\s*([0-9]+)", "$1장 $2"]
30
+
29
31
  ],
30
32
  matchRules:{
31
- chapter:"장[절0-9~ -–]*",
33
+ book: "(제[0-9]+)*",
34
+ chapter:"([0-9:;,~——–-\\s])*[0-9]+",
32
35
  verse:"절",
36
+ joiners: ["^[;, ]*(또는*|그리고|비교)*$",]
33
37
  },
34
38
  },
35
39
  de:{
@@ -45,8 +49,16 @@ module.exports = {
45
49
  },
46
50
  ru:{
47
51
  books:{
48
- "Бытие": ["Быт"], "Исход": ["Исх"], "Левит": ["Лев"], "Числа": ["Числ"], "Второзаконие": ["Втор"], "Иисус Навин": ["Нав"], "Книга Судей": ["Суд"], "Руфь": ["Руфь"], "1-я Царств": ["1 Цар"], "2-я Царств": ["2 Цар"], "3-я Царств": ["3 Цар"], "4-я Царств": ["4 Цар"], "1-я Паралипоменон": ["1 Пар"], "2-я Паралипоменон": ["2 Пар"], "Ездра": ["Езд"], "Неемия": ["Неем"], "Есфирь": ["Есф"], "Иов": ["Иов"], "Псалтирь": ["Пс"], "Притчи": ["Притч"], "Екклесиаст": ["Еккл"], "Песня Песней": ["Песн"], "Исаия": ["Ис"], "Иеремия": ["Иер"], "Плач Иеремии": ["Плач"], "Иезекииль": ["Иез"], "Даниил": ["Дан"], "Осия": ["Ос"], "Иоиль": ["Иоиль"], "Амос": ["Ам"], "Авдий": ["Авд"], "Иона": ["Иона"], "Михей": ["Мих"], "Наум": ["Наум"], "Аввакум": ["Авв"], "Софония": ["Соф"], "Аггей": ["Агг"], "Захария": ["Зах"], "Малахия": ["Мал"], "От Матфея": ["Мф"], "От Марка": ["Мк"], "От Луки": ["Лк"], "От Иоанна": ["Ин"], "Деяния": ["Деян"], "К Римлянам": ["Рим"], "1-е к Коринфянам": ["1 Кор"], "2-е к Коринфянам": ["2 Кор"], "К Галатам": ["Гал"], "К Ефесянам": ["Еф"], "К Филиппийцам": ["Флп"], "К Колоссянам": ["Кол"], "1-е к Фессалоникийцам": ["1 Фес"], "2-е к Фессалоникийцам": ["2 Фес"], "1-е к Тимофею": ["1 Тим"], "2-е к Тимофею": ["2 Тим"], "К Титу": ["Тит"], "К Филимону": ["Флм"], "К Евреям": ["Евр"], "Иакова": ["Иакова"], "1-е Петра": ["1 Пет"], "2-е Петра": ["2 Пет"], "1-е Иоанна": ["1 Ин"], "2-е Иоанна": ["2 Ин"], "3-е Иоанна": ["3 Ин"], "Иуды": ["Иуд"], "Откровение": ["Откр"], "1 Нефий": ["1 Неф"], "2 Нефий": ["2 Неф"], "Енос": ["Енос"], "Иаром": ["Иаром"], "Омний": ["Омний"], "Слова Мормона": ["Сл М"], "Мосия": ["Мосия"], "Алма": ["Алма"], "Геламан": ["Гел"], "3 Нефий": ["3 Неф"], "4 Нефий": ["4 Неф"], "Мормон": ["Морм"], "Ефер": ["Ефер"], "Мороний": ["Морон"], "Учение и Заветы": ["У и З"], "Моисей": ["Моис"], "Авраам": ["Авр"], "Джозеф Смит – от Матфея": ["ДжС–Мф"], "Джозеф Смит – История": ["ДжС–Ист"], "Символы веры": ["С В"]
49
- }
52
+ "Бытие": ["Быт"], "Исход": ["Исх"], "Левит": ["Лев"], "Числа": ["Числ"], "Второзаконие": ["Втор"], "Иисус Навин": ["Нав"], "Книга Судей": ["Суд"], "Руфь": ["Руфь"], "1я Царств": ["1[яек]* Цар"], "2я Царств": ["2[яек-]* Цар"], "3я Царств": ["3[яек]* Цар"], "4-я Царств": ["4 Цар"], "1я Паралипоменон": ["1[яек]* Пар"], "2я Паралипоменон": ["2[яек-]* Пар"], "Ездра": ["Езд"], "Неемия": ["Неем"], "Есфирь": ["Есф"], "Иов": ["Иов"], "Псалтирь": ["Пс"], "Притчи": ["Притч"], "Екклесиаст": ["Еккл"], "Песня Песней": ["Песн"], "Исаия": ["Ис"], "Иеремия": ["Иер"], "Плач Иеремии": ["Плач"], "Иезекииль": ["Иез"], "Даниил": ["Дан"], "Осия": ["Ос"], "Иоиль": ["Иоиль"], "Амос": ["Ам"], "Авдий": ["Авд"], "Иона": ["Иона"], "Михей": ["Мих"], "Наум": ["Наум"], "Аввакум": ["Авв"], "Софония": ["Соф"], "Аггей": ["Агг"], "Захария": ["Зах"], "Малахия": ["Мал"], "От Матфея": ["Мф"], "От Марка": ["Мк"], "От Луки": ["Лк"], "От Иоанна": ["Ин"], "Деяния": ["Деян"], "К Римлянам": ["Рим"], "1е к Коринфянам": ["1[яек]* Кор"], "2е к Коринфянам": ["2[яек]* Кор"], "К Галатам": ["Гал"], "К Ефесянам": ["Еф"], "К Филиппийцам": ["Флп"], "К Колоссянам": ["Кол"], "1е к Фессалоникийцам": ["1[яек]* Фес"], "2е к Фессалоникийцам": ["2[яек]* Фес"], "1е к Тимофею": ["1[яек]* Тим"], "2е к Тимофею": ["2[яек]* Тим"], "К Титу": ["Тит"], "К Филимону": ["Флм"], "К Евреям": ["Евр"], "Иакова": ["Иакова"], "1е Петра": ["1[яек]* Пет"], "2е Петра": ["2[яек]* Пет"], "1е Иоанна": ["1[яек]* Ин"], "2е Иоанна": ["2[яек]* Ин"], "3е Иоанна": ["3[яек]* Ин"], "Иуды": ["Иуд"], "Откровение": ["Откр"], "1 Нефий": ["1[яек]* Неф"], "2 Нефий": ["2[яек]* Неф"], "Енос": ["Енос"], "Иаром": ["Иаром"], "Омний": ["Омний"], "Слова Мормона": ["Сл М"], "Мосия": ["Мосия"], "Алма": ["Алма"], "Геламан": ["Гел"], "3 Нефий": ["3[яек]* Неф"], "4 Нефий": ["4 Неф"], "Мормон": ["Морм"], "Ефер": ["Ефер"], "Мороний": ["Морон"], "Учение и Заветы": ["У и З"], "Моисей": ["Моис"], "Авраам": ["Авр"], "Джозеф Смит – от Матфея": ["ДжС–Мф"], "Джозеф Смит – История": ["ДжС–Ист"], "Символы веры": ["С В"]
53
+ },
54
+ pre_rules: [
55
+ ["([1-3])[ –-]*([яек])", "$1$2"],
56
+ ["p", "р"],
57
+ ],
58
+ post_rules: [
59
+ ["([1-3])-*([ея])", "$1-$2"],
60
+
61
+ ]
50
62
  },
51
63
  vn:{
52
64
  pre_rules: [
@@ -54,8 +66,15 @@ module.exports = {
54
66
  ["-([^0-9 ])", " $1"],
55
67
  ],
56
68
  books:{
57
- "Sáng Thế": ["STK[yý]", "Sáng Thế Ký","S[áa]ng *Th[ếe] *(K[yý])*"], "Xuất Ê Díp Tô": ["X[ÊE]DT(K[ýy])*","X[úu]at *Ê *D[íi]p *T[ôo] *(K[yý])*","Xu[ấa]t h[àa]nh *(k[yý])*"], "Lê Vi": ["L[êe] *Vi *(K[yý])*","LV(K[ýy])*"], "Dân Số": ["DS(K[yý])*","D[âa]n *S[ốo] *(K[yý])*"], "Phục Truyền Luật Lệ": ["PTLL(K[yý])*","Ph[úu]c *Truy[ềe]n *Lu[ậa]t *L[ệe] *(K[yý])*"], "Giô Suê": ["Gi[ôo] *Su[êe]"], "Các Quan Xét": ["C[áa]c *Quan *X[ée]t","QX[ée]t"], "Ru Tơ": ["Ru *T[ơo]"], "1 Sa Mu Ên": ["1 *Sa *Mu *Ên","1 *SM[EÊ]n"], "2 Sa Mu Ên": ["2 *Sa *Mu *Ên","2 *SM[EÊ]n"], "1 Các Vua": ["1 *C[áa]c *Vua","1 *Vua"], "2 Các Vua": ["2 *C[áa]c *Vua","2 *Vua"], "1 Sử Ký": ["1 *S[ửu] *K[yý]"], "2 Sử Ký": ["2 *S[ửu] *K[yý]"], "E Xơ Ra": ["E *X[ơo] *Ra"], "Nê Hê Mi": ["N[êe] *H[êe] *Mi"], "Ê Xơ Tê": ["Ê *X[ơo] *T[êe]"], "Gióp": ["Gi[óo]p"], "Thi Thiên": ["Th*i* *Thi[êe]n"], "Châm Ngôn": ["Ch[âa]m *Ng[ôo]n","CNg[ôo]n"], "Truyền Đạo": ["T[DĐ][aạ]o","Truy[ềe]n *[ĐD]a[ọo]"], "Nhã Ca": ["Nh[ãa] *Ca"], "Ê Sai": ["[ÊE] *Sai"], "Giê Rê Mi": ["GRMi","Gi[êe] *R[êe] *Mi"], "Ca Thương": ["CTh[uư][oơ]ng","Ca *Th[ưu]ng"], "Ê Xê Chi Ên": ["[EÊ]XC[EÊ]n","Ê *X[êe] *Chi *[ÊE]n"], "Đa Ni Ên": ["[DĐ]N[EÊ]n","[ĐD]a *Ni *[ÊE]n"], "Ô Sê": ["[ÔO] *S[êe]"], "Giô Ên": ["Gi[ôo] *[ÊE]n"], "A Mốt": ["A *M[ốo]t"], "Áp Đia": ["[ÁA]p *Đia"], "Giô Na": ["Gi[ôo] *Na"], "Mi Chê": ["Mi *Ch[êe]"], "Na Hum": ["Na *Hum"], "Ha Ba Cúc": ["HBCuc","Ha *Ba *C[úu]c"], "Sô Phô Ni": ["S[ôo]* *Ph*[ôo]* *Ni"], "A Ghê": ["A *Gh[êe]"], "Xa Cha Ri": ["Xa* *Ch*a* *Ri"], "Ma La Chi": ["Ma* *La* *Chi"], "Ma Thi Ơ": ["Ma *Thi *[ƠO]","MT[OƠ]"], "Mác": ["M[áa]c"], "Lu Ca": ["Lu *Ca"], "Giăng": ["Gi[ăa]ng"], "Công Vụ Các Sứ Đồ": ["C[ôo]ng *Vụ *C[áa]c *Sứ *Đ[ồo]", "CVCS[ĐD]"], "Rô Ma": ["R[ôo] *Ma"], "1 Cô Rinh Tô": ["1 *C[ôo]* *Ri*n*h* *T[ôo]"], "2 Cô Rinh Tô": ["2 *C[ôo]* *Ri*n*h* *T[ôo]"], "Ga La Ti": ["Ga *La *Ti"], "Ê Phê Sô": ["[ÊE] *Ph[êe] *S[ôo]","[ÊE]PS[ÔO]"], "Phi Líp": ["Phi *L[íi]p"], "Cô Lô Se": ["C[ôo] *L[ôo] *Se","CL[ÔO]*Se"], "1 Tê Sa Lô Ni Ca": ["1 *Tê *Sa *L[ôo] *Ni *Ca","1 *TSLN[ÔO]Ca","1 TSLNCa"], "2 Tê Sa Lô Ni Ca": ["2 TSLNCa","2 *Tê *Sa *L[ôo] *Ni *Ca","2 *TSLN[ÔO]Ca"], "1 Ti Mô Thê": ["1 *Ti *Mô *Th[êe]","1 *TMTh[ÊE]"], "2 Ti Mô Thê": ["2 *Ti *Mô *Th[êe]","2 *TMTh[ÊE]"], "Tít": ["T[íi]t"], "Phi Lê Môn": ["Phi *L[êe] *Môn","PL[ÊE]M[ÔO]n","PLM[oô]n"], "Hê Bơ Rơ": ["H[êe] *Bơ *Rơ","HBR[ƠO]"], "Gia Cơ": ["GLTi", "Gia *C[ơo]"], "1 Phi E Rơ": ["1 *Phi *E *R[ơo]","1 *PER[ƠO]"], "2 Phi E Rơ": ["2 *Phi *E *R[ơo]","2 *PER[ƠO]"], "1 Giăng": ["1 *Gi[ăa]ng"], "2 Giăng": ["2 *Gi[ăa]ng"], "3 Giăng": ["3 *Gi[ăa]ng"], "Giu Đe": ["Giu *[ĐD]e"], "Khải Huyền": ["Kh[ảa]i *Huy[ềe]n","KHuy[ềe]n"], "1 Nê Phi": ["1 *N[êe] *Phi"], "2 Nê Phi": ["2 *N[êe] *Phi"], "Gia Cốp": ["Gi*a* *C[ốo]p"], "Ê Nót": ["[ÊE] *N[óo]t"], "Gia Rôm": ["Gi*a* *R[ôo]m"], "Ôm Ni": ["[ÔO]m *Ni"], "Lời Mặc Môn": ["L[ờo]i *M[ặa]c *M[ôo]n","LMM[ÔO]n"], "Mô Si A": ["M[ôo] *Si *A"], "An Ma": ["An *Ma"], "Hê La Man": ["H[êe]* *La* *Man"], "3 Nê Phi": ["3 *N[êe] *Phi"], "4 Nê Phi": ["4 *N[êe] *Phi"], "Mặc Môn": ["M[ậa]c *M[ôo]n", "MM[ÔO]n"], "Ê The": ["[ÊE] *The"], "Mô Rô Ni": ["M[ôo] *R[ôo] *Ni","MRN[ÎI]"], "Giáo Lý và Giao Ước": ["Gi[áa]o *L[ýi] *v[àa] *Giao *[ƯU][ớo]c","GLG[ƯU]"], "Môi Se": ["M[ôo]i *Se"], "Áp Ra Ham": ["[ÁA]p *Ra *Ham","ARH[ÂA]m"], "Joseph Smith—Ma Thi Ơ": ["Joseph *Smith—Ma *Thi *[ƠO]", "JS—MT[ƠO]"], "Joseph Smith—Lịch Sử": ["Joseph *Smith—L[ịi]ch *S[ửu]", "JS—LS"], "Những Tín Điều": ["Nh[ữu]ng *T[íi]n *[ĐD]i[ềe]u", "NT[ĐD]"]
69
+ "Sáng Thế": ["STK[yý]", "Sáng Thế Ký","S[áa]ng *Th[ếe] *(K[yý])*"], "Xuất Ê Díp Tô": ["X[ÊE]DT(K[ýy])*","X[úu]at *Ê *D[íi]p *T[ôo] *(K[yý])*","Xu[ấa]t h[àa]nh *(k[yý])*"], "Lê Vi": ["L[êe] *Vi *(K[yý])*","LV(K[ýy])*"], "Dân Số": ["DS(K[yý])*","D[âa]n *S[ốo] *(K[yý])*"], "Phục Truyền Luật Lệ": ["PTLL(K[yý])*","Ph[úu]c *Truy[ềe]n *Lu[ậa]t *L[ệe] *(K[yý])*"], "Giô Suê": ["Gi[ôo] *Su[êe]"], "Các Quan Xét": ["C[áa]c *Quan *X[ée]t","QX[ée]t"], "Ru Tơ": ["Ru *T[ơo]"], "1 Sa Mu Ên": ["1 *Sa *Mu *Ên","1 *SM[EÊ]n"], "2 Sa Mu Ên": ["2 *Sa *Mu *Ên","2 *SM[EÊ]n"], "1 Các Vua": ["1 *C[áa]c *Vua","1 *Vua"], "2 Các Vua": ["2 *C[áa]c *Vua","2 *Vua"], "1 Sử Ký": ["1 *S[ửu] *K[yý]"], "2 Sử Ký": ["2 *S[ửu] *K[yý]"], "E Xơ Ra": ["E *X[ơo] *Ra"], "Nê Hê Mi": ["N[êe] *H[êe] *Mi"], "Ê Xơ Tê": ["Ê *X[ơo] *T[êe]"], "Gióp": ["Gi[óo]p"], "Thi Thiên": ["Th*i* *Thi[êe]n"], "Châm Ngôn": ["Ch[âa]m *Ng[ôo]n","CNg[ôo]n"], "Truyền Đạo": ["T[DĐ][aạ]o","Truy[ềe]n *[ĐD]a[ọo]"], "Nhã Ca": ["Nh[ãa] *Ca"], "Ê Sai": ["[ÊE] *Sai"], "Giê Rê Mi": ["GRMi","Gi[êe] *R[êe] *Mi"], "Ca Thương": ["CTh[uư][oơ]ng","Ca *Th[ưu]ng"], "Ê Xê Chi Ên": ["[EÊ]XC[EÊ]n","Ê *X[êe] *Chi *[ÊE]n"], "Đa Ni Ên": ["[DĐ]N[EÊ]n","[ĐD]a *Ni *[ÊE]n"], "Ô Sê": ["[ÔO] *S[êe]"], "Giô Ên": ["Gi[ôo] *[ÊE]n"], "A Mốt": ["A *M[ốo]t"], "Áp Đia": ["[ÁA]p *Đia"], "Giô Na": ["Gi[ôo] *Na"], "Mi Chê": ["Mi *Ch[êe]"], "Na Hum": ["Na *Hum"], "Ha Ba Cúc": ["HBCuc","Ha *Ba *C[úu]c"], "Sô Phô Ni": ["S[ôo]* *Ph*[ôo]* *Ni"], "A Ghê": ["A *Gh[êe]"], "Xa Cha Ri": ["Xa* *Ch*a* *Ri"], "Ma La Chi": ["Ma* *La* *Chi"], "Ma Thi Ơ": ["Ma *Thi *[ƠO]","MT[OƠ]"], "Mác": ["M[áa]c"], "Lu Ca": ["Lu *Ca"], "Giăng": ["Gio*[ăa]ng*"], "Công Vụ Các Sứ Đồ": ["C[ôo]ng *Vụ *C[áa]c *Sứ *Đ[ồo]", "CVCS[ĐD]"], "Rô Ma": ["R[ôo] *Ma"], "1 Cô Rinh Tô": ["1 *C[ôo]* *Ri*n*h* *T[ôo]"], "2 Cô Rinh Tô": ["2 *C[ôo]* *Ri*n*h* *T[ôo]"], "Ga La Ti": ["Ga *La *Ti"], "Ê Phê Sô": ["[ÊE] *Ph[êe] *S[ôo]","[ÊE]PS[ÔO]"], "Phi Líp": ["Phi *L[íi]p"], "Cô Lô Se": ["C[ôo] *L[ôo] *Se","CL[ÔO]*Se"], "1 Tê Sa Lô Ni Ca": ["1 *Tê *Sa *L[ôo] *Ni *Ca","1 *TSLN[ÔO]Ca","1 TSLNCa"], "2 Tê Sa Lô Ni Ca": ["2 TSLNCa","2 *Tê *Sa *L[ôo] *Ni *Ca","2 *TSLN[ÔO]Ca"], "1 Ti Mô Thê": ["1 *Ti *Mô *Th[êe]","1 *TMTh[ÊE]"], "2 Ti Mô Thê": ["2 *Ti *Mô *Th[êe]","2 *TMTh[ÊE]"], "Tít": ["T[íi]t"], "Phi Lê Môn": ["Phi *L[êe] *Môn","PL[ÊE]M[ÔO]n","PLM[oô]n"], "Hê Bơ Rơ": ["H[êe] *Bơ *Rơ","HBR[ƠO]"], "Gia Cơ": ["GLTi", "Gia *C[ơo]"], "1 Phi E Rơ": ["1 *Phi *E *R[ơo]","1 *PER[ƠO]"], "2 Phi E Rơ": ["2 *Phi *E *R[ơo]","2 *PER[ƠO]"], "1 Giăng": ["1 *Gio*[ăa]ng*"], "2 Giăng": ["2 *Gio*[ăa]ng*"], "3 Giăng": ["3 *Gio*[ăa]ng*"], "Giu Đe": ["Giu *[ĐD]e"], "Khải Huyền": ["Kh[ảa]i *Huy[ềe]n","KHuy[ềe]n"], "1 Nê Phi": ["1 *N[êe] *Phi"], "2 Nê Phi": ["2 *N[êe] *Phi"], "Gia Cốp": ["Gi*a* *C[ốo]p"], "Ê Nót": ["[ÊE] *N[óo]t"], "Gia Rôm": ["Gi*a* *R[ôo]m"], "Ôm Ni": ["[ÔO]m *Ni"], "Lời Mặc Môn": ["L[ờo]i *M[ặa]c *M[ôo]n","LMM[ÔO]n"], "Mô Si A": ["M[ôo] *Si *A"], "An Ma": ["An *Ma"], "Hê La Man": ["H[êe]* *La* *Man"], "3 Nê Phi": ["3 *N[êe] *Phi"], "4 Nê Phi": ["4 *N[êe] *Phi"], "Mặc Môn": ["M[ậa]c *M[ôo]n", "MM[ÔO]n"], "Ê The": ["[ÊE] *The"], "Mô Rô Ni": ["M[ôo] *R[ôo] *Ni","MRN[ÎI]"], "Giáo Lý và Giao Ước": ["Gi[áa]o *L[ýi] *v[àa] *Giao *[ƯU][ớo]c","GLG[ƯU]"], "Môi Se": ["M[ôo]i *Se"], "Áp Ra Ham": ["[ÁA]p *Ra *Ham","ARH[ÂA]m"], "Joseph Smith—Ma Thi Ơ": ["Joseph *Smith—Ma *Thi *[ƠO]", "JS—MT[ƠO]"], "Joseph Smith—Lịch Sử": ["Joseph *Smith—L[ịi]ch *S[ửu]", "JS—LS"], "Những Tín Điều": ["Nh[ữu]ng *T[íi]n *[ĐD]i[ềe]u", "NT[ĐD]"]
58
70
  },
71
+ matchRules:{
72
+ book: `(Thứ nhất|I|1|Thứ hai|II|2|Thứ ba|III|3|Thứ tư|IV|4)*\\s*(Sách* của)*\\s*`,
73
+ chapter:"chương",
74
+ verse:"đoạn",
75
+ joiners: ["^[;, ]*(hoặc|và|so với)*$",]
76
+ },
77
+
59
78
  },
60
79
  fr:{
61
80
  books:{
@@ -108,7 +127,7 @@ module.exports = {
108
127
  "2 Corinthiens" : ["2 Cor*"],
109
128
  "Galates" : ["Gal*"],
110
129
  "Éphésiens" : ["[EÉ]ph*"],
111
- "Philippiens" : ["Phi*l*"],
130
+ "Philippiens" : ["Phi*l"],
112
131
  "Colossiens" : ["Col"],
113
132
  "1 Thessaloniciens" : ["1 Th"],
114
133
  "2 Thessaloniciens" : ["2 Th"],
@@ -143,9 +162,32 @@ module.exports = {
143
162
  "Doctrine et Alliances" : ["D&A"],
144
163
  "Moïse" : ["Mo[iï](se)*"],
145
164
  "Abraham" : ["Abr"],
146
- "Joseph Smith, Matthieu" : ["JS,M"],
147
- "Joseph Smith, Histoire" : ["JS,H"],
165
+ "Joseph Smith Matthieu" : ["JSM"],
166
+ "Joseph Smith Histoire" : ["JSH"],
148
167
  "Articles de foi" : ["AF"]
168
+ },
169
+ pre_rules: [
170
+ ["Smith[,—–-]+", "Smith"],
171
+ ["JS[,—–-]+ *", "JS"],
172
+ ["le (.*) livre de", "$1"],
173
+ ["(premier|première|1er|1ère)", "1"],
174
+ ["(deuxième|2ème|II)", "2"],
175
+ ["(troisième|3ème|III)", "3"],
176
+ ["(quatrième|4ème|IV)", "4"],
177
+ [",*\\s*(chapitre|ch[.]|section)*\\s*([0-9]+)" , "$2"],
178
+ //["\\s*(:|,|\\.)\\s*(v+[.]*|verset|versets)*\\s*([0-9]*)", "$3"],
179
+ ],
180
+ post_rules: [
181
+ ["Smith (H|M)", "Smith, $1"],
182
+ ],
183
+ matchRules:{
184
+ jst:"JSH",
185
+ book:`(Premier|Première|I|1|1er|1ère|Deuxième|II|2|2ème|Troisième|III|3|3ème|Quatrième|IV|4|4ème)*\\s*(livres* de)*\\s*`,
186
+ verse:"\\s*(:|,|\\.)\\s*(v+[.]*|verset|versets)*\\s*[0-9]*",
187
+ joiners: [
188
+ "^[ ,;]*(et|aussi|voir|voir aussi|v\\. *a\\.)*\\s*:*$",
189
+ ]
190
+
149
191
  }
150
192
  },
151
193
 
@@ -37,7 +37,7 @@ module.exports = {
37
37
  ["zech*\\.*(?:ariah)*", "Zechariah"],
38
38
  ["mal*\\.*(?:achi)*", "Malachi"],
39
39
 
40
- ["(?:ma*t*t*h*|mt)\\.*(?:ew)*", "Matthew"],
40
+ ["(?:mat*t*h*|mt)\\.*(?:ew)*", "Matthew"],
41
41
  ["m(ar)*k", "Mark"],
42
42
  ["lu*k*e*\\.*", "Luke"],
43
43
  ["jo*h*n\\.*", "John"],
@@ -124,8 +124,8 @@ module.exports = {
124
124
  ["1\\s*(?:st)*\\s*v(?:ision)*", "First Vision"],
125
125
 
126
126
  ["W\\s*Moroni", "Words of Moroni"],
127
- ["s(?:ealed)*.*?moses", "Sealed Book of Moses"],
128
- ["3.*ne(phi)*(te)*.*?acts", "Acts of the Three Nephites"],
127
+ ["Sealed Book of Moses", "The Sealed Book of Moses"],
128
+ ["Acts of the Three Nephites", "The Acts of the Three Nephites"],
129
129
 
130
130
  ["qur['’ ]*(an)*", "Qur’an"],
131
131
  ["(?:al[ \\-––])*qur'*’*ani*c*(?:verses*)*", "Qur’an"],
@@ -193,7 +193,8 @@ module.exports = {
193
193
  ["([0-9]),\\s*([1-4]*\\s*[a-z])", "$1; $2"],
194
194
  ["o([nf])", "o$1"],
195
195
  ["([;,])", "$1 "],
196
- ["(the )*book of", ""]
196
+ ["(the )*book of", ""],
197
+ [",\\s*([0-9]+)\\s*:", "; $1:"]
197
198
  ],
198
199
 
199
200
  "post_rules":[
package/data/testdata.js CHANGED
@@ -140,6 +140,7 @@ module.exports = {
140
140
  ["ÊThe 1:1; MRNi 2:2; GLGƯ 3:3",{firstVerse:37111,lastVerse:37751,verseCount:3}, "Ether 1:1; Moroni 2:2; Galatians 3:3"],
141
141
  ["MôiSe 1:1; ARHam 2:2; JS—MTƠ 3:3",{firstVerse:41361,lastVerse:41749,verseCount:2}, "Moses 1:1; Abraham 2:2; JS—Matthew 3:3"],
142
142
  ["JS—LS 1:1- 3; NTĐ 1:1 - 3",{firstVerse:41908,lastVerse:41910,verseCount:3}, "JS—H 1:1-3; Aof 1:1-3"]
143
+ ["1 Nê Phi 1:16", {firstVerse:31628,lastVerse:31628,verseCount:1}, "Other Books"],
143
144
  ],
144
145
  id2ref:[
145
146
  [1, "Sáng Thế 1:1", "Genesis 1:1"],
@@ -153,6 +154,14 @@ module.exports = {
153
154
  [2062, "Xuất Ê Díp Tô 20:10", "Exodus 20:10"],
154
155
  [33263, "Mô Si A 19:24", "3 Nephi 1:1"],
155
156
  ]
157
+ },
158
+ fr:{
159
+ ref2id:[
160
+ ["2 Rois 23:27", {firstVerse:10193,lastVerse:10193,verseCount:1} , "Full book name and chapter"],
161
+ ["2 Chroniques 36:15"],
162
+
163
+ ["Joseph Smith, Histoire 1:45", {firstVerse:41952,lastVerse:41952,verseCount:1}, "Full book name, chapter, and verse"],
164
+ ]
156
165
  }
157
166
 
158
167
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scripture-guide",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "description": "A utility for biblical and scripture reference parsing that enables structured queries based on strings of traditional scripture references (e.g. John 3:16). ",
5
5
  "main": "scriptures-compiled.js",
6
6
  "scripts": {
package/release.md ADDED
@@ -0,0 +1,5 @@
1
+ Steps to Publish to NPM:
2
+
3
+ - Run `npm run build`
4
+ - Increment the version in `package.json`
5
+ - Run `npm publish`
@@ -28,7 +28,8 @@ var orginal_raw_regex = _objectSpread({}, raw_regex);
28
28
  var raw_lang = require('./data/scriptlang.js');
29
29
  var _require = require('./data/scriptdetect.js'),
30
30
  prepareBlacklist = _require.prepareBlacklist,
31
- preparePattern = _require.preparePattern;
31
+ preparePattern = _require.preparePattern,
32
+ processReferenceDetection = _require.processReferenceDetection;
32
33
  var setLanguage = function setLanguage(language) {
33
34
  var _raw_lang$lang, _raw_lang$lang2, _raw_lang$lang3, _raw_lang$lang4, _raw_lang$lang5;
34
35
  if (lang === language) return console.log("Language already set to ".concat(lang));
@@ -519,52 +520,17 @@ var loadMaxVerse = function loadMaxVerse(book, chapter) {
519
520
  return raw_index[book][parseInt(chapter) - 1];
520
521
  };
521
522
  var detectReferences = function detectReferences(content, callBack) {
522
- var _content$match;
523
- var wordBreak = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "\\b";
524
523
  callBack = callBack ? callBack : function (i) {
525
524
  return "[".concat(i, "]");
526
525
  };
527
- var trimExternalMatchStrings = function trimExternalMatchStrings(i) {
528
- return i.trim().replace(/^[^0-9]*\(/g, '').replace(/\)[^0-9]*$/g, '').replace(/[,;!?.()]+$/ig, "").replace(/^[,;!?.()]+/ig, " ").trim();
529
- };
530
- var hasBeyondAlpha = /[^\u0000-\u007F]/.test(content);
531
- if (hasBeyondAlpha && wordBreak) wordBreak = "";
532
526
  var src = raw_regex.books.map(function (i) {
533
527
  return i[0];
534
528
  });
535
529
  var dst = _toConsumableArray(new Set(raw_regex.books.map(function (i) {
536
530
  return i[1];
537
531
  })));
538
- var bookMatchList = [].concat(_toConsumableArray(dst), _toConsumableArray(src)).map(function (i) {
539
- return [i];
540
- });
541
- var pattern = preparePattern(bookMatchList, wordBreak, lang_extra);
542
- var blacklist_pattern = prepareBlacklist();
543
- var matches = ((_content$match = content.match(pattern)) === null || _content$match === void 0 ? void 0 : _content$match.filter(function (i) {
544
- return !blacklist_pattern.test(i);
545
- })) || [];
546
- matches = matches.map(trimExternalMatchStrings);
547
- matches = matches.filter(function (i) {
548
- return i.length <= 1000;
549
- });
550
-
551
- // split by matches
552
- var pieces;
553
- try {
554
- pieces = matches.length ? content.split(new RegExp("(".concat(matches.join("|"), ")"), "ig")) : [content];
555
- } catch (error) {
556
- console.error(error);
557
- console.log({
558
- matches: matches,
559
- pattern: pattern
560
- });
561
- return content;
562
- }
563
- content = pieces.map(function (i, j) {
564
- if (j % 2 == 0) return i;
565
- return callBack(i);
566
- }).join("").replace(/\s+/g, " ").trim();
567
- return content;
532
+ var books = [].concat(_toConsumableArray(dst), _toConsumableArray(src));
533
+ return processReferenceDetection(content, books, lang_extra, lookupReference, callBack);
568
534
  };
569
535
  module.exports = {
570
536
  lookupReference: lookupReference,
package/scriptures.js CHANGED
@@ -8,7 +8,7 @@ let verseIdIndex = null
8
8
  const orginal_raw_index = {...raw_index};
9
9
  const orginal_raw_regex = {...raw_regex};
10
10
  let raw_lang = require('./data/scriptlang.js');
11
- let {prepareBlacklist, preparePattern} = require('./data/scriptdetect.js');
11
+ let {prepareBlacklist, preparePattern,processReferenceDetection} = require('./data/scriptdetect.js');
12
12
 
13
13
 
14
14
  const setLanguage = function(language) {
@@ -518,45 +518,14 @@ const loadMaxVerse = function(book, chapter) {
518
518
 
519
519
 
520
520
 
521
- const detectReferences = (content,callBack,wordBreak="\\b") => {
521
+ const detectReferences = (content,callBack) => {
522
522
 
523
523
  callBack = callBack ? callBack : (i)=>{return `[${i}]`};
524
-
525
- const trimExternalMatchStrings = (i) => i.trim().
526
- replace(/^[^0-9]*\(/g, '').
527
- replace(/\)[^0-9]*$/g, '').
528
- replace(/[,;!?.()]+$/ig, "").
529
- replace(/^[,;!?.()]+/ig, " ").
530
- trim();
531
-
532
- const hasBeyondAlpha = /[^\u0000-\u007F]/.test(content);
533
- if(hasBeyondAlpha && wordBreak) wordBreak = "";
534
-
535
524
  const src = raw_regex.books.map(i => i[0]);
536
525
  const dst = [...new Set(raw_regex.books.map(i => i[1]))];
537
- const bookMatchList = [...dst, ...src].map(i => [i]);
538
- const pattern = preparePattern(bookMatchList,wordBreak,lang_extra);
539
- const blacklist_pattern = prepareBlacklist();
540
- var matches = content.match(pattern)?.filter(i => !blacklist_pattern.test(i)) || [];
541
- matches = matches.map(trimExternalMatchStrings)
542
- matches = matches.filter(i => i.length <= 1000);
543
-
544
- // split by matches
545
- let pieces;
546
- try {
547
- pieces = matches.length ? content.split(new RegExp(`(${matches.join("|")})`, "ig")) : [content];
548
- } catch (error) {
549
- console.error(error);
550
- console.log({matches,pattern});
551
- return content;
552
- }
553
-
554
- content = pieces.map((i, j) => {
555
- if (j % 2 == 0) return i;
556
- return callBack(i);
557
- }).join("").replace(/\s+/g, " ").trim();
526
+ const books = [...dst, ...src];
527
+ return processReferenceDetection(content,books,lang_extra,lookupReference,callBack);
558
528
 
559
- return content;
560
529
  }
561
530
 
562
531
 
File without changes
@@ -0,0 +1,6 @@
1
+ Alma 10:3 specifies that Lehi is of Manasseh.
2
+ see 3 Nephi 5:25 and 3 Nephi 20:13 to see
3
+ Thank you for sharing your word thoughts, Lyndon. It’s fascinating to explore the deeper meaning of words and their potential impact on our understanding of scripture. In 3 Nephi 16:4-5, the phrase “fulness of the Gentiles” is indeed significant. It refers to the time when the Gentiles, or nations, will receive the gospel of Jesus Christ and have the opportunity to come unto Him. This concept is further supported by other scriptures, such as 3 Nephi 21:6, which speaks of the Father showing forth His power to the Gentiles and inviting them to repent and be baptized. Additionally, 3 Nephi 5:25 and 3 Nephi 20:13 mention the gathering of scattered remnants and the restoring of the house of Jacob, which includes both the Israelites and the Gentiles who have embraced the gospel. The translation process was guided by the Spirit, ensuring that the essential teachings and principles are conveyed accurately. Whether we use the word “multitude” or “fullness” to describe the Gentiles, the central message remains the same – that all people, regardless of their lineage, have the opportunity to come unto Christ and be partakers of His blessings. In summary, the phrase “fulness of the Gentiles” in 3 Nephi 16:4-5 signifies the time when the Gentiles will have the chance to receive the gospel and be gathered in. It aligns with other scriptures that speak of the gathering of scattered remnants and the restoration of the house of Jacob.
4
+ It talks about the consequences of the fall of Adam and Eve. Before the fall, if they had not partaken of the forbidden fruit, they would have remained in a state of innocence and ignorance, without experiencing the joy and blessings that come from knowing good and evil (II Nephi 2:23). However, Heavenly Father, in His wisdom, allowed Adam to fall so that mankind could be created and experience the fullness of joy (2 Nephi 2:25). This passage is connected to other scriptures such as Genesis 3:16 and Moses 5:11, which further explain the consequences of the fall. In Genesis 3:16, Eve is told that because of the fall, she will experience sorrow in childbirth, indicating that the ability to have children is a result of the fall. In Moses 5:11, Eve expresses her gratitude for the fall, recognizing that without it, she and Adam would not have had children or known the joy of redemption. Understanding this passage helps us comprehend the purpose of life and the role of the fall in enabling us to experience joy and progression.
5
+ See John3:16 and, but not First John 1:9 for the same concept of the fall and the atonement.
6
+ The fruit mentioned in 1 Nephi 8:9-12 represents something desirable and joyous. It is described as being sweet and white, surpassing any other fruit in its goodness and purity. In the book of Genesis, there is mention of the tree of life and the tree of the knowledge of good and evil (Genesis 2:9, 3:6). These trees represent different choices and paths that humans can take. The fruit in Lehi’s dream could be seen as a representation of the blessings and joy that come from choosing the path of righteousness and partaking of the goodness of God. In the book of Revelation, there are references to the tree of life as well (Revelation 2:7, 22:2). This tree is associated with eternal life and the blessings of God. So, the fruit in Lehi’s dream may also symbolize the blessings of eternal life and joy that come from following the teachings of Jesus Christ.
@@ -0,0 +1,5 @@
1
+ Louis a lu 1 Néphi 5:3~4; Galates 1 et la comparrer a Luc 5:2 - 6, et a vut tout
2
+ Enos 1:2 is the only place where you will find Enos 1:2 at the same time.
3
+ C'est trouvé dans Enos 1:2, Genèse 3:15, et 1 Néphi 15:24.
4
+ 2eme rois 3:5
5
+ *Par exemple, dans 1 Néphi 5:5, Lehi exprime sa joie d’avoir obtenu une terre de promission et sa confiance que le Seigneur délivrera ses fils des mains de Laban. Cela souligne l’importance de la Terre promise et l’accomplissement des promesses faites à Lehi et à sa famille. De plus, dans 1 Néphi 8:13, Finalement, dans Mosiah 10:13, il est mentionné que Néphi était favorisé par le Seigneur en raison de sa fidélité à garder les commandements. Cette faveur divine a également joué un rôle dans la direction de leur voyage dans le désert, ce qui peut être considéré comme une préparation pour leur arrivée dans la Terre promise. En résumé, le point principal de ce passage est l’arrivée des voyageurs en Terre promise, marquant l’accomplissement des promesses divines et soulignant la fidélité du Seigneur envers son peuple. Ce passage peut être mis en relation avec d’autres Écritures qui parlent de la Terre promise et de la bénédiction accordée à ceux qui sont fidèles aux commandements du Seigneur.
@@ -0,0 +1,2 @@
1
+ 1836년, 커틀랜드 성전에 나타난 선지자 모세는 이스라엘 민족의 집합을 인도하도록 그 권능과 권세를 조셉 스미스에게 주었다.(교리와 성약 110:11 참조) 그때 이후로 항상 선지자들은 이스라엘 민족을 집합하기 위한 열쇠를 소유했고, 집합은 교회 사업에서 중요한 부분이 되어 왔다. 성약의 백성은 이제 그들이 회복된 복음을 받아들이고 아브라함과 이삭과 야곱의 하나님을 섬김으로써 집합되고 있다.(신명기 30:1~5 참조)
2
+ 이스라엘 백성은 먼저 영적으로 집합되며, 그런 다음에는 실제로 집합될 것이다. 그들은 예수 그리스도 후기 성도 교회에 가입하고 성스러운 성약을 맺고 지킬 때 영적으로 집합된다. 이 영적인 집합은 선지자 조셉 스미스 시대 때부터 시작되었으며, 오늘날 세계 도처에서 계속되고 있다. 교회로 개종한 사람들은 혈통으로, 또는 입양된 이스라엘 민족이다. 그들은 아브라함과 야곱의 가계에 속한다.(아브라함서 2:9~11; 비교 갈라디아서 3:26~29)
@@ -0,0 +1,11 @@
1
+ A Rôn, Con Trai của Mô Si A
2
+ Xem thêm Mô Si A, Các Con Trai của; Mô Si A, Con Trai của Bên Gia Min
3
+ Trong Sách Mặc Môn, con trai của Vua Mô Si A. A Rôn phục vụ với tư cách là một người truyền giáo và những cố gắng cần mẫn của ông đã giúp cải đạo nhiều người về với Đấng Ky Tô.
4
+ Là một kẻ vô tín ngưỡng đi tìm cách hủy diệt Giáo Hội, MôSiA 27:8–10, 34.
5
+ Một thiên sứ hiện ra cùng ông và các bạn đồng hành của ông, MôSiA 27:11.
6
+ Hối cải và bắt đầu thuyết giảng lời của Thượng Đế, MôSiA 27:32–28:8.
7
+ Từ chối không chịu để được chỉ định làm vua, thay vì vậy ông đã đi đến xứ của dân La Man để thuyết giảng lời của Thượng Đế, AnMa 17:6–9.
8
+ Nhịn ăn và cầu nguyện để xin sự soi dẫn, AnMa 17:8–11.
9
+ Giảng dạy phụ thân của Vua La Mô Ni, AnMa 22:1–26.
10
+ Đi thuyết giảng cho dân Giô Ram, AnMa 31:6–7.
11
+ Xem Gioan 3:16 và, nhưng không phải là 1 Gioan 1:9 cho cùng một khái niệm về sự rơi rớt và sự chuộc tội.
package/test-detect.js CHANGED
@@ -1,38 +1,36 @@
1
- const { ko } = require("./data/scriptlang.js");
2
- const {lookup, generateReference, setLanguage, detectReferences}= require("./scriptures.js");
3
-
4
-
5
- const lines = [
6
- "Please refer to Genesis 20 in the bible",
7
- "Please refer to 3 Nephi 5:1-3 in the Book of Mormon",
8
- "For example, in Matthew 27:51, the earth quakes and ro",
9
- "It aligns with other scriptures (3 Nephi 12:2, Mosiah 18:13, Moses 6:52).",
10
- ]
11
-
12
- lines.forEach(l=>{
13
- const result = detectReferences(l);
14
- console.log({result});
15
- });
16
-
17
- process.exit(0);
18
-
19
- setLanguage("ko");
20
-
21
- const ko_lines = [
22
- "성경의 창세기 20장을 참조하십시오.",
23
- "이제 제3니파이서 5:1-3을 참조하십시오.",
24
- "이제 제4니파이서 1:4~5절 참조하십시오.",
25
- "이제 제4니파이서 1장4~5절 참조하십시오.",
26
- "이제 제4니파이서 1장 4~5절 참조하십시오.",
27
- "이제 제4니파이서 1.4~5절 참조하십시오.",
28
- " 관련하여 힐라맨서 5장 24절에서는 불기둥이 불을 일으키지 않고",
29
- "이제 모세서 3장 참조하십시오.",
30
- "이제 니파이후서 12:5; 예레미야서 2:5; 앨마서 5:37 참조하십시오.",
31
- ]
32
- ko_lines.forEach(l=>{
33
- let callback = (string)=>{
34
- return `[${string}]`
1
+
2
+ const { setLanguage, detectReferences, lookupReference}= require("./scriptures.js");
3
+ const fs = require("fs");
4
+ const paramLang = process.argv[2] || "en";
5
+ const langs = fs.readdirSync(`${__dirname}/test/data`)
6
+ .filter(i=>/txt$/.test(i))
7
+ .map(i=>i.replace(".txt",""))
8
+ .filter(i=>{
9
+ if(!paramLang) return true;
10
+ if(paramLang && i===paramLang) return true
11
+ return false;
12
+ });
13
+
14
+ let callback = (string)=>{
15
+ const verse_ids = lookupReference(string);
16
+ console.log({string,verse_ids});
17
+ return `【❰ ${string} ❱】`
18
+ }
19
+
20
+
21
+ for(const lang of langs){
22
+ if(lang!=="en") setLanguage(lang);
23
+ let lines = fs.readFileSync(`${__dirname}/test/data/${lang}.txt`,"utf-8").split("\n").map(i=>i.trim()).filter(x=>!!x);
24
+ const hasAsterix = lines.some(i=>/^[*]/.test(i));
25
+ if(hasAsterix) lines = lines.filter(i=>/^[*]/.test(i)).map(i=>i.replace(/^[*]/,""))
26
+ for(const line of lines){
27
+ const i = detectReferences(line,callback);
28
+ console.log([i]);
35
29
  }
36
- const result = detectReferences(l,callback);
37
- console.log({result});
38
- });
30
+ }
31
+
32
+
33
+
34
+
35
+
36
+