From 3dbf285244ef615e73f18dd5da305068e1fc63d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20Kubo=C5=84?= <g_kubon@e-science.pl> Date: Fri, 17 Mar 2023 11:37:18 +0100 Subject: [PATCH] changed lu/synsets.UUID and dependent methods to proper format --- plwn/storages/sqlite.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/plwn/storages/sqlite.py b/plwn/storages/sqlite.py index 4405789..7d41138 100644 --- a/plwn/storages/sqlite.py +++ b/plwn/storages/sqlite.py @@ -377,6 +377,7 @@ class PLWordNet(bs.PLWordNetBase): def lexical_unit_by_id(self, id_): if isinstance(id_, str): + uuid = "X'" + id_.replace('-', '').upper() + "'" with closing(self._db.cursor()) as cur: cur.execute( u""" @@ -384,7 +385,7 @@ class PLWordNet(bs.PLWordNetBase): FROM tbl_lexicalunit WHERE quote(tbl_lexicalunit.id) = ? """, - ("X'" + id_ + "'",) + (uuid,) ) temp_id = cur.fetchone() if temp_id is None: @@ -491,6 +492,7 @@ class PLWordNet(bs.PLWordNetBase): def synset_by_id(self, id_): if isinstance(id_, str): + uuid = "X'" + id_.replace('-', '').upper() + "'" with closing(self._db.cursor()) as cur: cur.execute( u""" @@ -498,7 +500,7 @@ class PLWordNet(bs.PLWordNetBase): FROM tbl_synset WHERE quote(tbl_synset.id) = ? """, - ("X'" + id_ + "'",) + (uuid,) ) temp_id = cur.fetchone() if temp_id is None: @@ -789,7 +791,10 @@ class LexicalUnit(bs.LexicalUnitBase): ) temp = cur.fetchone()[0] if isinstance(temp, str): - self._uuid = temp[2:-1] + indices = [2, 10, 14, 18, 22] + self._uuid = ('-').join([temp[i:j] for i, j in + zip(indices, indices[1:] + [None]) + ]).lower()[:-1] else: self._uuid = temp return self._uuid @@ -1156,7 +1161,10 @@ class Synset(bs.SynsetBase): ) temp = cur.fetchone()[0] if isinstance(temp, str): - self._uuid = temp[2:-1] + indices = [2, 10, 14, 18, 22] + self._uuid = ('-').join([temp[i:j] for i, j in + zip(indices, indices[1:] + [None]) + ]).lower()[:-1] else: self._uuid = temp return self._uuid -- GitLab