From e9355cd058eb289a3f0d2ab0df5785638db4fcf7 Mon Sep 17 00:00:00 2001 From: Niskala Airaha <34799053+niskala5570@users.noreply.github.com> Date: Wed, 24 May 2023 08:07:48 +0800 Subject: [PATCH 1/2] Tukar regex --- alih-kata.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/alih-kata.py b/alih-kata.py index 367f8ac..d9a8711 100644 --- a/alih-kata.py +++ b/alih-kata.py @@ -52,7 +52,7 @@ def gantikan_tanda(padanan): ayat_diterjemah = re.sub(r'(? Date: Wed, 24 May 2023 09:56:49 +0800 Subject: [PATCH 2/2] Update alih-kata.py --- alih-kata.py | 54 +++++++++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/alih-kata.py b/alih-kata.py index d9a8711..339db4f 100644 --- a/alih-kata.py +++ b/alih-kata.py @@ -1,5 +1,8 @@ -# The code mostly generated by ChatGPT (I can't code and just stitch it together part by part) -# Even I don't understand much but I will explain what the code will do inside README.md +# Kod ni kebanyakkannya ditulis dengan ChatGPT sebab aku malas dan tak reti. +# Jadi aku camtum2 macam lego, kalau nampak cacat dan rajin nak tolong kemaskan, dipersilakan. +# Aku buat kod ni sebab nak percepatkan kerja sahaja, takdelah aku perlu tulis balik Jawi dari awal. +# Untuk perkataan bersengkang, kena buat masukan kamus baru sebab kod tak akan pisahkan(tokenize) Contohnya "Kazuki-kun" +# Ini supaya perkataan berganda seperti "apa-apa, اڤ٢" dapat dialih dengan sempurna import pysubs2 import os @@ -9,7 +12,7 @@ folder_keluar = "Keluar" folder_kamus = "Kamus" -def muat_katan(file_path): +def muatKamus(file_path): data = {} with open(file_path) as file: lines = file.readlines() @@ -22,7 +25,7 @@ def muat_katan(file_path): data[rumi] = [jawi] return data -def alih_kata(padanan, translations, chosen_translations, context): +def alihKata(padanan, translations, chosen_translations, context): katan = padanan.group(0) if katan.lower() in translations: translations_list = translations[katan.lower()] @@ -43,7 +46,7 @@ def alih_kata(padanan, translations, chosen_translations, context): return translations_list[0] return katan -def alih_ayat(ayat, translations, padanan_tanda, chosen_translations): +def alihAyat(ayat, translations, padanan_tanda, chosen_translations): def gantikan_tanda(padanan): tanda = padanan.group(0) if tanda in padanan_tanda: @@ -52,21 +55,21 @@ def gantikan_tanda(padanan): ayat_diterjemah = re.sub(r'(? 0: