From 8c3df8b589763968c88b58793d54213bd7abed40 Mon Sep 17 00:00:00 2001 From: Oliver Tseng Date: Fri, 30 Jun 2023 18:35:14 -0400 Subject: [PATCH] Ver 34.91; Added lexiconreverse to api server (#270) * Ver 34.91; Added lexiconreverse to api server * Update patches.txt --- UniqueBibleAppVersion.txt | 2 +- db/ToolsSqlite.py | 10 ++++++++++ latest_changes.txt | 3 +++ patches.txt | 10 +++++----- util/RemoteApiHandler.py | 15 +++++++++++++++ 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/UniqueBibleAppVersion.txt b/UniqueBibleAppVersion.txt index 250b382c80..e1b26f1b50 100755 --- a/UniqueBibleAppVersion.txt +++ b/UniqueBibleAppVersion.txt @@ -1 +1 @@ -34.90 +34.91 diff --git a/db/ToolsSqlite.py b/db/ToolsSqlite.py index c79a617e1b..2f0275ecbc 100644 --- a/db/ToolsSqlite.py +++ b/db/ToolsSqlite.py @@ -958,6 +958,16 @@ def getReverseContent(self, entry): contentText = re.sub("(" + entry + ")", r"\1", contentText, flags=re.IGNORECASE) return contentText + def getRawReverseContent(self, entry): + try: + search = "%{0}%".format(entry) + query = "SELECT Topic, Definition FROM Lexicon WHERE Definition LIKE ?" + self.cursor.execute(query, (search,)) + return self.cursor.fetchall() + except Exception as ex: + return "" + + class BookData: def __init__(self): diff --git a/latest_changes.txt b/latest_changes.txt index f5722629a1..69038f731e 100755 --- a/latest_changes.txt +++ b/latest_changes.txt @@ -1,3 +1,6 @@ +Changes in 34.91: +* Added lexiconreverse to api server + Changes in 34.90: * added support of gpt-3.5-turbo-16k diff --git a/patches.txt b/patches.txt index 7a92d3144a..7fed34437d 100755 --- a/patches.txt +++ b/patches.txt @@ -1222,9 +1222,7 @@ (33.20, "file", "util/PromptValidator.py") (33.25, "file", "util/LexicalData.py") (33.28, "file", ".gitignore") -(33.38, "file", "util/RemoteApiHandler.py") (33.48, "file", "gui/CentralWidget.py") -(33.50, "file", "db/ToolsSqlite.py") (33.50, "file", "gui/MiniControl.py") (33.50, "file", "gui/NoteEditor.py") (33.50, "file", "plugins/context/English Dictionaries_Ctrl+Shift+D.py") @@ -1388,6 +1386,8 @@ (34.89, "file", "util/AGBparagraphs_expanded.py") (34.89, "file", "marvelData/AGBTS_data.sqlite") (34.90, "file", "util/LocalCliHandler.py") -(34.90, "file", "latest_changes.txt") -(34.90, "file", "patches.txt") -(34.90, "file", "UniqueBibleAppVersion.txt") +(34.91, "file", "db/ToolsSqlite.py") +(34.91, "file", "util/RemoteApiHandler.py") +(34.91, "file", "latest_changes.txt") +(34.91, "file", "UniqueBibleAppVersion.txt") +(34.91, "file", "patches.txt") diff --git a/util/RemoteApiHandler.py b/util/RemoteApiHandler.py index 6d3d6092de..4a2930619b 100644 --- a/util/RemoteApiHandler.py +++ b/util/RemoteApiHandler.py @@ -124,6 +124,8 @@ def processRequest(self, request): self.processCommentaryCommand(cmd) elif command == "lexicon": self.processLexiconCommand(cmd) + elif command == "lexiconreverse": + self.processLexiconReverseCommand(cmd) elif command == "devotional": self.processDevotionalCommand(cmd) elif command == "dictionary": @@ -273,6 +275,19 @@ def processLexiconCommand(self, cmd): data = Lexicon(cmd[1]).getRawContent(cmd[2]) self.jsonData['data'] = data if data else ("[Not found]",) + # /lexiconreverse + # /lexiconreverse/TRLIT/love + def processLexiconReverseCommand(self, cmd): + CatalogUtil.reloadLocalCatalog() + if len(cmd) == 1: + self.jsonData['data'] = [lexicon for lexicon in LexiconData().lexiconList] + return + elif len(cmd) < 3: + self.sendError("Invalid Lexicon command") + return + data = Lexicon(cmd[1]).getRawReverseContent(cmd[2]) + self.jsonData['data'] = data if data else ("[Not found]",) + # /devotional # /devotional/Chambers+-+My+Utmost+For+His+Highest/12/25 def processDevotionalCommand(self, cmd):