g;ode's Adventure EP1: Beginning

Oct 04, 2021

3 min read

API
Python
Flask
g;ode
Blog Thumbnail

"l;ylfu" is what you get for typing "สวัสดี" on QWERTY/Kedmanee keyboard without switching your layout. Also "้ำสสน" and "hello" when you're on Thai keyboard and typing English.

Lullar's de = กำ has been around for years and that's what Thais use most when they forget to change their layout. The story began when I saw my girlfriend's tweet in the wrong layout and I want to do something about that. What came to my mind immediately is Twitter bot that reply to you when got mentioned in the replies with the converted phrase. I go back to Lullar's website to see if there's an API that I can use and there isn't one. That's why I decided to make my own.

As Python being my comforted programming language, I decided to make my own API with Flask and Waitress. My API features a loop with simple if-else statement and 2 big arrays (or for Python it's called list) that determine if a character supposed to convert from English to Thai or Thai to English. As I'm not that experience in programming the way I chose to do it is mapping both keyboard layouts into arrays with the same order and check for it's position in it's supposed array. Then replace it with a character with the same index in another array.

gode-ep1-code

Difficulties faced while making this has to do with QWERTY and Kedmanee both have some duplicated characters such as `,` `.` `?` `-` `(` `)` which make converting sometimes inaccurate. The solution I came up isn't really great but it works for now. I make a few more if-else statement to catch those duplicated characters and convert it case-by-case. Most of them will check for the previous character's language and assume it's in the same language. There're some exceptions though, For example `-` will convert to `3` if there's space in front of and behind them assuming that it's from Kedmanee. There's a lot of tweaking went into it and sure enough, it will never be perfect.

What am I going to do with the API you may ask. For me seeing Lullar's de = กำ' problems, I have a plan to make g;ode website that do similar things to Lullar's one but with more keyboard layout supported, more modernized and probably will be maintained. Twitter bot will also be on the list but that will be for later.

โนพ ืนไม ฆำำ ันีสฟะำพ ฟืก ้ฟอำ ดีื แนกรืเใ

p.s. try convert that with my api. :)

GuntxJakka's logo

© 2022 - 2024 Jakkaphat Ch.

Currently at

Links