From 64df20c77ae44191ca1ec4a4ef493bcdf98588b3 Mon Sep 17 00:00:00 2001 From: Eryk J Date: Tue, 14 Feb 2023 20:44:26 -0500 Subject: [PATCH] Fix space stripping --- linkture.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/linkture.py b/linkture.py index 9c981ba..df0b270 100755 --- a/linkture.py +++ b/linkture.py @@ -26,7 +26,7 @@ SOFTWARE. """ -VERSION = '2.0.1' +VERSION = '2.0.2' import argparse, json, regex, sqlite3 @@ -70,7 +70,7 @@ def __init__(self, language='English', translate=None, form=None, verbose=False) self._tr_book_names.insert(rec[2], rec[form]) for rec in cur.execute(f"SELECT * FROM Books WHERE Language = '{language}';").fetchall(): for i in range(3,6): - normalized = unidecode(rec[i].replace(' ', '').replace('.', '').replace('-', '').upper()) + normalized = unidecode(rec[i].replace(' ', ' ').replace('.', '').replace('-', '').upper()) # non-breaking space self._src_book_names[normalized] = rec[2] with open(path / 'res/custom.json', 'r', encoding='UTF-8') as json_file: b = json.load(json_file) @@ -78,7 +78,7 @@ def __init__(self, language='English', translate=None, form=None, verbose=False) for row in b[language]: names = row[1].split(', ') for item in names: - normalized = unidecode(item.replace(' ', '').replace('.', '').replace('-', '').upper()) + normalized = unidecode(item.replace(' ', ' ').replace('.', '').replace('-', '').upper()) # non-breaking space self._src_book_names[normalized] = row[0] self._ranges = pd.read_sql_query("SELECT * FROM Ranges;", con) cur.close() @@ -92,7 +92,8 @@ def __init__(self, language='English', translate=None, form=None, verbose=False) # no capitals required (bit slower) self._first_pass = regex.compile(r'(?![^{]*})((?:(?:(?:[1-5]\p{L}{0,2}|[iIvV]{1,3})[—–\-\.   ]*)?\p{L}[\p{L}\.—–\-]+(?![,—–\-])[:\.—–\-\d,   ;]*(?