linkture 4.1.0__tar.gz → 4.2.0__tar.gz
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.
- {linkture-4.1.0 → linkture-4.2.0}/PKG-INFO +2 -1
- {linkture-4.1.0 → linkture-4.2.0}/pyproject.toml +2 -1
- {linkture-4.1.0 → linkture-4.2.0}/src/linkture/linkture.py +47 -26
- {linkture-4.1.0 → linkture-4.2.0}/LICENSE +0 -0
- {linkture-4.1.0 → linkture-4.2.0}/README.md +0 -0
- {linkture-4.1.0 → linkture-4.2.0}/src/linkture/__init__.py +0 -0
- {linkture-4.1.0 → linkture-4.2.0}/src/linkture/__main__.py +0 -0
- {linkture-4.1.0 → linkture-4.2.0}/src/linkture/res/custom.json +0 -0
- {linkture-4.1.0 → linkture-4.2.0}/src/linkture/res/resources.db +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: linkture
|
3
|
-
Version: 4.
|
3
|
+
Version: 4.2.0
|
4
4
|
Summary: PARSE and PROCESS BIBLE SCRIPTURE REFERENCES: extract, tag, link, rewrite, translate, BCV-encode and decode
|
5
5
|
Keywords: bible,scriptures,scripture-references,scripture-translation,scripture-parser,scripture-linker
|
6
6
|
Author-Email: "Eryk J." <infiniti@inventati.org>
|
@@ -11,6 +11,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.10
|
12
12
|
Classifier: Programming Language :: Python :: 3.11
|
13
13
|
Classifier: Programming Language :: Python :: 3.12
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
14
15
|
Classifier: Development Status :: 5 - Production/Stable
|
15
16
|
Classifier: Environment :: Console
|
16
17
|
Classifier: Topic :: Religion
|
@@ -21,6 +21,7 @@ classifiers = [
|
|
21
21
|
"Programming Language :: Python :: 3.10",
|
22
22
|
"Programming Language :: Python :: 3.11",
|
23
23
|
"Programming Language :: Python :: 3.12",
|
24
|
+
"Programming Language :: Python :: 3.13",
|
24
25
|
"Development Status :: 5 - Production/Stable",
|
25
26
|
"Environment :: Console",
|
26
27
|
"Topic :: Religion",
|
@@ -35,7 +36,7 @@ keywords = [
|
|
35
36
|
"scripture-parser",
|
36
37
|
"scripture-linker",
|
37
38
|
]
|
38
|
-
version = "4.
|
39
|
+
version = "4.2.0"
|
39
40
|
|
40
41
|
[project.license]
|
41
42
|
text = "MIT"
|
@@ -27,7 +27,7 @@
|
|
27
27
|
"""
|
28
28
|
|
29
29
|
__app__ = 'linkture'
|
30
|
-
__version__ = 'v4.
|
30
|
+
__version__ = 'v4.2.0'
|
31
31
|
|
32
32
|
|
33
33
|
import json, regex, sqlite3
|
@@ -97,19 +97,16 @@ class Scriptures():
|
|
97
97
|
normalized = regex.sub(r'\p{P}|\p{Z}', '', item.upper())
|
98
98
|
self._src_book_names[normalized] = row[0]
|
99
99
|
|
100
|
-
# Ranges: {(book, chapter): last} (chapter 0 -> num of chapters in book)
|
101
100
|
self._ranges = {}
|
102
101
|
for book, chapter, last in cur.execute("SELECT Book, Chapter, Last FROM Ranges;"):
|
103
102
|
self._ranges[(book, chapter)] = last
|
104
103
|
|
105
|
-
# Chapters: two-way mappings
|
106
104
|
self._chapters = {}
|
107
105
|
self._chapters_id = {}
|
108
106
|
for chapter_id, book, chapter in cur.execute("SELECT ChapterId, Book, Chapter FROM Chapters;"):
|
109
107
|
self._chapters[(book, chapter)] = chapter_id
|
110
108
|
self._chapters_id[chapter_id] = (book, chapter)
|
111
109
|
|
112
|
-
# Verses: two-way mappings
|
113
110
|
self._verses = {}
|
114
111
|
self._verses_id = {}
|
115
112
|
for verse_id, book, chapter, verse in cur.execute("SELECT VerseId, Book, Chapter, Verse FROM Verses;"):
|
@@ -276,27 +273,29 @@ class Scriptures():
|
|
276
273
|
def _code_scripture(self, scripture, bk_num, rest, last):
|
277
274
|
|
278
275
|
def reform_series(txt): # rewrite comma-separated consecutive sequences (1, 2, 3) as ranges (1-3)
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
276
|
+
numbers = []
|
277
|
+
for match in regex.finditer(r'\d+', txt):
|
278
|
+
numbers.append((int(match.group()), match.start(), match.end()))
|
279
|
+
if not numbers:
|
280
|
+
return txt
|
281
|
+
sequences = []
|
282
|
+
current_seq = [numbers[0]]
|
283
|
+
for i in range(1, len(numbers)):
|
284
|
+
current_num = numbers[i][0]
|
285
|
+
prev_num = current_seq[-1][0]
|
286
|
+
if current_num == prev_num + 1:
|
287
|
+
current_seq.append(numbers[i])
|
288
|
+
else:
|
289
|
+
if len(current_seq) >= 3:
|
290
|
+
sequences.append(current_seq)
|
291
|
+
current_seq = [numbers[i]]
|
292
|
+
if len(current_seq) >= 3:
|
293
|
+
sequences.append(current_seq)
|
294
|
+
for seq in sorted(sequences, key=lambda x: x[0][1], reverse=True):
|
295
|
+
start_pos = seq[0][1]
|
296
|
+
end_pos = seq[-1][2]
|
297
|
+
replacement = f"{seq[0][0]}-{seq[-1][0]}"
|
298
|
+
txt = txt[:start_pos] + replacement + txt[end_pos:]
|
300
299
|
return txt
|
301
300
|
|
302
301
|
def validate(b, ch, vs):
|
@@ -435,6 +434,26 @@ class Scriptures():
|
|
435
434
|
|
436
435
|
return None, None
|
437
436
|
|
437
|
+
def merge_ranges(ranges):
|
438
|
+
if not ranges:
|
439
|
+
return []
|
440
|
+
merged = []
|
441
|
+
current_start, current_end = ranges[0]
|
442
|
+
for start, end in ranges[1:]:
|
443
|
+
end_bk = int(current_end[:2])
|
444
|
+
end_ch = int(current_end[2:5])
|
445
|
+
end_vs = int(current_end[5:])
|
446
|
+
next_bk = int(start[:2])
|
447
|
+
next_ch = int(start[2:5])
|
448
|
+
next_vs = int(start[5:])
|
449
|
+
if (end_bk == next_bk and ((end_ch == next_ch and end_vs + 1 == next_vs) or (end_ch + 1 == next_ch and end_vs == self._ranges.get((end_bk, end_ch), 0) and next_vs == 1))):
|
450
|
+
current_end = end
|
451
|
+
else:
|
452
|
+
merged.append((current_start, current_end))
|
453
|
+
current_start, current_end = start, end
|
454
|
+
merged.append((current_start, current_end))
|
455
|
+
return merged
|
456
|
+
|
438
457
|
lst = []
|
439
458
|
if rest == '': # whole book
|
440
459
|
v = self._ranges.get((bk_num, last))
|
@@ -444,6 +463,7 @@ class Scriptures():
|
|
444
463
|
rest = f'1:1-{last}:{v}'
|
445
464
|
else:
|
446
465
|
rest = reform_series(rest)
|
466
|
+
all_ranges = []
|
447
467
|
for chunk in rest.split(';'):
|
448
468
|
ch = None
|
449
469
|
for bit in chunk.split(','):
|
@@ -454,7 +474,8 @@ class Scriptures():
|
|
454
474
|
if not tup:
|
455
475
|
self._error_report(scripture, f'"{bit.strip()}" OUT OF RANGE')
|
456
476
|
return None
|
457
|
-
|
477
|
+
all_ranges.append(tup)
|
478
|
+
lst = merge_ranges(all_ranges)
|
458
479
|
return lst
|
459
480
|
|
460
481
|
def code_scriptures(self, text):
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|