From 654f7b6ee3332013d68b216ebaac971c3b964784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nezih=20A=C5=9Fula?= <90565940+anezih@users.noreply.github.com> Date: Tue, 22 Mar 2022 00:04:06 +0300 Subject: [PATCH] bugfix for oversight Use two separate lists(line 94, 95) for holding keys and values, respectively, instead of a dictionary in order to prevent last item in the loop to override the dictionary value. Now entries with more than one definition should display correctly. This change also required the removal of newline character in entry (line 122). Otherwise, Stardict editor will complain and will not build the dict files. However, this newline is necessary and it is handled in another loop in line 133. Added description to *.gls metadata. --- src/gts_stardict.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/gts_stardict.py b/src/gts_stardict.py index eac5f59..69eda5e 100644 --- a/src/gts_stardict.py +++ b/src/gts_stardict.py @@ -91,7 +91,8 @@ def create_gls(hunspell_dir=None): sys.exit(1) conn = sqlite3.connect("gts.sqlite3.db") conn.row_factory = sqlite3.Row - with_dups = dict() + with_dups_keys = list() + with_dups_values = list() wo_dups = dict() for it in conn.execute(sql): entry = f'
'
@@ -118,19 +119,23 @@ def create_gls(hunspell_dir=None):
entry += f'
▪ {it["ornek"]}
'
if it['tam_adi']:
entry += f'—{it["tam_adi"]}'
- entry += f"
————
{v}' else: wo_dups[k] = v + for key in wo_dups.keys(): + wo_dups[key] = wo_dups[key]+"\n" + fname = "Guncel_Turkce_Sozluk.gls" with open(fname, "w", encoding="utf-8", newline="") as f: - f.write("\n#stripmethod=keep\n#sametypesequence=h\n#bookname=Güncel Türkçe Sözlük\n#author=https://github.com/anezih\n\n") + f.write("\n#stripmethod=keep\n#sametypesequence=h\n#bookname=Güncel Türkçe Sözlük\n#author=https://github.com/anezih\n#description=TDK Güncel Türkçe Sözlük\n\n") for k,v in wo_dups.items(): if (stem := h.stem(k)) and k == stem[0] and (suffixes := h.suffix_suggest(k)): hw = f"{k}|"