linkture 2.5.3__py3-none-any.whl

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/__init__.py ADDED
File without changes
@@ -0,0 +1,214 @@
1
+ Metadata-Version: 2.1
2
+ Name: linkture
3
+ Version: 2.5.3
4
+ Summary: PARSE and PROCESS BIBLE SCRIPTURE REFERENCES: extract, tag, link, rewrite, translate, BCV-encode and decode
5
+ Keywords: bible,scriptures,scripture-references,scripture-translation,scripture-parser,scripture-linker
6
+ Author-Email: "Eryk J." <infiniti@inventati.org>
7
+ License: MIT
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Environment :: Console
13
+ Project-URL: Homepage, https://github.com/erykjj/linkture
14
+ Requires-Python: >=3.9
15
+ Requires-Dist: setuptools>=59.6.0
16
+ Requires-Dist: argparse>=1.4.0
17
+ Requires-Dist: regex>=2023.8.8
18
+ Requires-Dist: unidecode>=1.3.8
19
+ Requires-Dist: pathlib
20
+ Requires-Dist: pandas==2.2.2
21
+ Description-Content-Type: text/markdown
22
+
23
+ # linkture
24
+
25
+
26
+ ## Purpose
27
+
28
+ This module contains functions to parse and process Bible scripture references.
29
+
30
+ The parser can work in **Cebuano, Chinese, Danish, Dutch, English, French, German, Greek, Hungarian, Italian, Japanese, Korean, Norwegian, Polish, Portuguese, Russian, Spanish, Tagalog and Ukrainian**. It will **recognize** such references and **validate** them to ensure the chapter(s) and/or verse(s) are within range.
31
+
32
+ It *does not* work with whole books (like "James") unless they are preceded by a number (like "1 John"); otherwise it would have to look up ever single word. Also, it will *not* find the multi-word book name "Song of Solomon" (and its variations), though this (and any other scripture) can be force-detected by tagging the desired reference "manually" within the source text (eg., "{{Song of Solomon 1:1}}") - *one book* per brace pair. These two limitations aside, it works with most book name variants in all the available languages (including common abbreviations): "2 Sam.", "2nd Samuel", "II Samuel", "2Sa", etc. Any special/unusual variants can be added to the *res/custom.json* list.
33
+
34
+ These found references can be **extracted** as a list of references, or a list of BCV-encoded ranges in the format `bbcccvvv` (where `b` is book, `c` is chapter, and `v` is verse). Or, they can be **tagged** (with '{{ }}') within the text, or replaced with HTML \<a> **links** (with custom prefix and suffix). All of these functions can also include a **rewrite** of the reference with either a full book name, or one of two abbreviation formats, along with **translation** into one of the available languages.
35
+
36
+ The parser tries to deal "intelligently" with different notations, but there are simply too many "edge-cases". If something isn't being parsed properly, try to rewrite the original reference(s) in a standard way or use {{ }} to force the detection.
37
+
38
+ A couple of auxiliary functions provide a verse number lookup (either by BCV reference or integer). These can be useful to calculate the number of verses between two references, etc.
39
+
40
+ ____
41
+ ## Installation
42
+
43
+ Download [latest source](https://github.com/erykjj/linkture/releases/latest) and `python3 -m pip install linkture-*.tar.gz`.
44
+
45
+ ____
46
+ ## Command-line usage
47
+
48
+ ```
49
+ > python3 linkture.py -h
50
+ usage: linkture.py [-h] [-v] [-q] [-f in-file | -r reference] [-o out-file]
51
+ [--language {Cebuano,Chinese,Danish,Dutch,English,French,German,Greek,Hungarian,Italian,Japanese,Korean,Norwegian,Polish,Portuguese,Russian,Spanish,Tagalog,Ukrainian}]
52
+ [--translate {Cebuano,Chinese,Danish,Dutch,English,French,German,Greek,Hungarian,Italian,Japanese,Korean,Norwegian,Polish,Portuguese,Russian,Spanish,Tagalog,Ukrainian}]
53
+ [-s separator] [-u] [--full | --official | --standard]
54
+ [-c | -d | -l [prefix [suffix ...]] | -t | -x]
55
+ [-sc BCV | -sv BCV | -cc chapter | -cv verse]
56
+
57
+ PARSE and PROCESS BIBLE SCRIPTURE REFERENCES: extract, tag, link, rewrite, translate, BCV-encode and decode.
58
+ See README for more information
59
+
60
+ options:
61
+ -h, --help show this help message and exit
62
+ -v show version and exit
63
+ -q don't show errors
64
+ -o out-file output file (terminal output if not provided)
65
+ --language {Cebuano,Chinese,Danish,Dutch,English,French,German,Greek,Hungarian,Italian,Japanese,Korean,Norwegian,Polish,Portuguese,Russian,Spanish,Tagalog,Ukrainian}
66
+ indicate source language for book names (English if unspecified)
67
+ --translate {Cebuano,Chinese,Danish,Dutch,English,French,German,Greek,Hungarian,Italian,Japanese,Korean,Norwegian,Polish,Portuguese,Russian,Spanish,Tagalog,Ukrainian}
68
+ indicate output language for book names (same as source if unspecified)
69
+ -s separator segment separator (space by default)
70
+ -u capitalize (upper-case) book names
71
+
72
+ data source (one required - except for auxiliary functions, which only take command-line arguments):
73
+ choose between terminal or file input:
74
+
75
+ -f in-file get input from file (UTF-8)
76
+ -r reference process "reference; reference; etc."
77
+
78
+ output format (optional):
79
+ if provided, book names will be rewritten accordingly:
80
+
81
+ --full output as full name - default (eg., "Genesis")
82
+ --official output as official abbreviation (eg., "Ge")
83
+ --standard output as standard abbreviation (eg., "Gen.")
84
+
85
+ type of conversion:
86
+ if not specified, references are simply rewritten according to chosen (or default) output format:
87
+
88
+ -c encode as BCV-notation ranges
89
+ -d decode list of BCV-notation ranges
90
+ -l [prefix [suffix ...]]
91
+ create <a></a> links; provide a "prefix" and a "suffix" (or neither for testing)
92
+ -t tag scriptures with {{ }}
93
+ -x extract list of scripture references
94
+
95
+ auxiliary functions:
96
+ -sc BCV return the serial number (1-1189) of the chapter with code "BCV" ("bbcccvvv")
97
+ -sv BCV return the serial number (1-31091) of the verse with code "BCV" ("bbcccvvv")
98
+ -cc chapter return the BCV range for serial chapter number "chapter" (integer value)
99
+ -cv verse return the BCV code for serial verse number "verse" (integer value)
100
+ ```
101
+
102
+ Or, make it executable first and run directly:
103
+ ```
104
+ $ chmod +x linkture.py
105
+ ```
106
+
107
+ Some examples:
108
+ ```
109
+ $ ./linkture.py -r "Joh 17:17; 2Ti 3:16, 17" --full -u
110
+ JOHN 17:17; 2 TIMOTHY 3:16, 17
111
+
112
+ $ ./linkture.py -r "Joh 17:17; 2Ti 3:16, 17" --standard
113
+ John 17:17; 2 Tim. 3:16, 17
114
+
115
+ $ ./linkture.py -r "Joh 17:17; 2Ti 3:16, 17" --official
116
+ Joh 17:17; 2Ti 3:16, 17
117
+
118
+ $ ./linkture.py -r "Joh 17:17; 2Ti 3:16, 17" -c
119
+ [('43017017', '43017017'), ('55003016', '55003017')]
120
+
121
+ $ ./linkture.py -r "[('43017017', '43017017'), ('55003016', '55003017')]" -d --translate German
122
+ ['Johannes 17:17', '2. Timotheus 3:16, 17']
123
+
124
+ $ ./linkture.py -r "Joh 17:17; 2Ti 3:16, 17" -l '<a href="https://my.website.com/' '/index.html" class="test">'
125
+ <a href="https://my.website.com/43:17:17/index.html" class="test">John 17:17</a>; <a href="https://my.website.com/55:3:16-55:3:17/index.html" class="test">2 Timothy 3:16, 17</a>
126
+
127
+ $ ./linkture.py -r "Joh 17:17; 2Ti 3:16, 17" --translate Chinese
128
+ 约翰福音 17:17; 提摩太后书 3:16, 17
129
+
130
+ $ ./linkture.py -r "约翰福音 17:17; 提摩太后书 3:16, 17" --language Chinese --translate Dutch
131
+ Johannes 17:17; 2 Timotheüs 3:16, 17
132
+
133
+ $ ./linkture.py -r "{{Jean 17:17}}; 2 Timothée 3:16, 17" --language French --translate Spanish --standard
134
+ Juan 17:17; 2 Tim. 3:16, 17
135
+
136
+ $ ./linkture.py -r "Mat 17:17; Paul 3:16, 17" --full -x
137
+ ['Matthew 17:17']
138
+
139
+ $ ./linkture.py -cc 2
140
+ ('01002001', '01002025')
141
+
142
+ $ ./linkture.py -cv 31091
143
+ ('66022021', '66022021')
144
+
145
+ $ ./linkture.py -sv '01001001'
146
+ 1
147
+
148
+ ./linkture.py -sc '66022001'
149
+ 1189
150
+
151
+ ./linkture.py -r '2Ti 3:16, 17' --full -s '_'
152
+ 2_Timothy_3:16,_17
153
+ ```
154
+
155
+ **Note**: The serial verse options (`-sv` and `-cv`) *do not* count Psalm headings as separate verses.
156
+
157
+ Of course, you can pass a whole text file to parse and process using the `-f in_file` flag, instead of `-r "references"`. And you can output to another text file (instead of the terminal) using `-o out_file`.
158
+
159
+ Unless you use `-q`, you will see in the terminal any out-of-range errors encountered while parsing. Of course, these entries will not be processed, but they will not affect the rest of the operation.
160
+
161
+ ## Script/import usage
162
+
163
+ Assume the text (short string or long document) you want to process is in the variable `txt`. It's in English, but you would like the scriptures to be in Spanish, with the full book name:
164
+ ```
165
+ from linkture import Scriptures
166
+
167
+ s = Scriptures(language="English", translate="Spanish", form="full")
168
+
169
+ lst = s.list_scriptures(txt)
170
+ # returns a list of (valid) extracted scriptures in the desired language and format
171
+
172
+ lst = s.code_scriptures(txt)
173
+ # returns a list of BCV-range tuples (start, end)
174
+
175
+ html = s.link_scriptures(txt, prefix='<a href="http://mywebsite.com/', suffix='" class="b"')
176
+ # this will turn all references into HTML links
177
+
178
+ tagged = s.tag_scriptures(txt)
179
+ # tagged will contain your document with the translated references enclosed within double braces
180
+
181
+ txt = s.rewrite_scriptures(txt)
182
+ # the references will simply be rewritten in the desired language and format
183
+
184
+ i = s.serial_chapter_number(txt)
185
+ # returns the serial number (1-1189) of the chapter identified by the provided BCV-format string; verse digits irrelevant
186
+
187
+ i = s.serial_verse_number(txt)
188
+ # returns the serial number (1-31091) of the verse identified by the provided BCV-format string
189
+
190
+ txt = s.code_chapter(i)
191
+ # returns a BCV-format range string for the whole chapter indicated by the provided integer (1-1189)
192
+
193
+ txt = s.code_verse(i)
194
+ # returns a BCV-format range string for the verse indicated by the provided integer (1-31091)
195
+ ```
196
+
197
+ Parameters:
198
+ * *language* - source language for Scripture parsing
199
+ * *translate* - language for Bible book name translation
200
+ * *form* - output format of Bible book names
201
+ * **"full"** for full name format (eg., "Genesis")
202
+ * **"standard"** for standard abbreviation format (eg., "Gen.")
203
+ * **"official"** for official abbreviation format (eg., "Ge")
204
+ * *None* or not supplied - no re-write will be performed, *unless* translation is performed or *linking* (in which case, "full" is the default)
205
+ * *separator* - character(s) to use instead of space (default) to separate the various segments of the scripture
206
+ * *upper* - if **True**, outputs book names in UPPER CASE (**False** by default)
207
+ * *verbose* - if **True**, show (in terminal) any out-of-range errors encountered while parsing (**False** by default)
208
+
209
+ ____
210
+ ## Feedback
211
+
212
+ Feel free to [get in touch and post any issues and suggestions](https://github.com/erykjj/linkture/issues).
213
+
214
+ [![RSS of releases](res/rss-36.png)](https://github.com/erykjj/linkture/releases.atom)
@@ -0,0 +1,5 @@
1
+ linkture-2.5.3.dist-info/METADATA,sha256=GKWPEAFsZyzI30JI8lULmXCM69mORnFWpdHvvv-9hz8,10815
2
+ linkture-2.5.3.dist-info/WHEEL,sha256=7sv5iXvIiTVJSnAxCz2tGBm9DHsb2vPSzeYeT7pvGUY,90
3
+ linkture-2.5.3.dist-info/licenses/LICENSE,sha256=kPqKoVmo3Tx1HgQvqfjBZuYkjT1mZXnQ5R0KBbEeFfs,1064
4
+ linkture/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ linkture-2.5.3.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: pdm-backend (2.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Eryk J.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.