Public Speaking in Thai

This weekend Thailand hosted its first ever PyCon: a conference dedicated to the Python programming language. This was a great opportunity to meet fellow developers in the region and learn more about topics like Deep Learning, Natural Language Processing, Graph Theory and more. I even contributed with a talk on Teaching and Learning with Python. Another fun part of the conference is the lightning talk session. Lightning talks are 5 minute talks that anyone can sign up for that happened at the end of each day in the main hall. It’s a chance for people to dip into speaking at a conference or to test the water for new ideas or just to share something cool they’ve been working on. While I already have some experience in that arena, I have zero experience speaking in public in Thai. I decided to take the risk of trying my hand at it. I’d say around half or more of the audience understood Thai, but definitely a large part that did not so I made slides in English and Thai but made a goal of only speaking Thai during the presentation. There were a couple times when I couldn’t think of the word I wanted to say in Thai and was tempted to just say it in English but didn’t, I either found another way to express myself or just left the comment out. Below are the slides I created and used for the talk:

I already started realizing how hard translating this all would be by slide 1. For the first word should I use เรียน (riian – to study at the elementary level), เรียนรู้ (riian rúu – to undertake to study; learn; study), ศึกษา (sʉ̀k sǎa – to study; to be educated; to receive education; to go to school; to learn (at higher levels such as college)) or something else? And the connecting word, am I learning/studying with/by/through programming? What’s the most Thai way to express it? And it seems I was so focused on getting the Thai correct that I forgot to capitalize the ‘p’ in Programming for my title in English.

When I actually gave the talk, I was thinking “should I explain what I’m doing in English, that I’m learning Thai and want to practice speaking or should I just start speaking in Thai, I’m sure it won’t be very hard for them to figure out I’m just learning…” I jumped right in with an unsure “สวัสดีครับ… ทุกคน ยินดีต้อนรับ” (sà wát dii kráp… túk kon, yin dii dtɔ̂ɔn ráp – Hello… everyone. Welcome.”

After the initial awkwardness, I felt a little more comfortable. Sure, I’m speaking a new language and I might mess up but there are slides to help people figure out what’s going on even if I mispronounce something. I push my students who are English Language Learners to take risks and make an attempt. It’s more about pushing yourself out of your comfort zone and learning and getting your point across than delivering a perfect speech.

“วันนี้ผมจะพูดเกี่ยวกับ…” (wan níi pǒm jà pûut gìao gàp – Today I will speak about…)

Now for introductions. Pretty standard for a presentation, but it did feel rather like day 1 in a language class.

ประมาณ (bprà maan – approximately) was a new word for me. I’ve heard it before but I’ve never actually used it in conversation. I think the experience of using it in a talk in front of a large audience will help it stick in my memory pretty well.

Got my first laugh here. There’s a term for people who are half Thai, ลูกครึ่ง (lûuk krʉ̂ng – half child).

“ไม่ใช่ลูกครึ่ง เป็นลูกครึ่งครึ่ง” (mâi châi lûuk krʉ̂ng bpen lûuk krʉ̂ng krʉ̂ng) – “I’m not half Thai, I’m half half Thai”

The term for people like me who have 1 Thai grandparent and 3 non-Thai grandparents is “ลูกเสี้ยว” (lûuk sîao – crescent child) a reference to the crescent moon.

An interesting tidbit about the Thai language is that there are different words for maternal and paternal grandparents, so by using the word คุณย่า (kun yâa – paternal grandmother) instead of คุณยาย (kun yaai – maternal grandmother) it can be inferred that it’s my dad’s mom who is Thai, not my mom’s mom without me needing to elaborate.

After introductions I showed a few of the programs I made to help me learn Thai and explained briefly what they did. The first one was my program to help tell the time. This came from one of my first posts on this blog, Telling Time in Thai.

Second program, my Days of the Week quiz, also about something I made for the blog. I did say the English words “Saturday, Sunday, Friday” here because I was explaining that you have to select the correct English word in this example. Though my childlike enthusiasm when saying “ถูก!” (tùuk – correct, can also mean inexpensive) got me another laugh from the crowd.

This is the only example I shared that isn’t from the blog, JamDai, the Vocabulary Card Matching Game I made. Instead of ถูก, this one ends with a supportive เก่งมาก (gèng mâak – very good, clever, skillful, superbly performed).

The final example I shared was the Thai Chat Bot I made recently. Got a couple more laughs here excitedly reading the chat between myself and the bot and explaining that the bot is male since he uses the polite term “ครับ” (kráp) instead of “ค่ะ” (kâ).

Though, if I end up adding text-to-speech that may change since all the existing Thai text-to-speech tools I can find only have a female voice. I have noticed that general service messages, or posted announcements tend to be either gender neutral or use female terms. Another interesting difference between Thai and English is that there’s no difference between she and he, it’s the same word (เขา – kǎo) so no need to worry about misgendering someone because you don’t need to refer to people by their gender. Though you do gender yourself by the self-referential pronouns you use, ผม (pǒm – I (male)) and ฉัน (chǎn – I (female)). There are instances when speakers will use the opposite gender terms such as a male using female terms with close family members or intimate partners to show softness/gentleness (it’s common for male singers to use ฉัน in love songs for example) or women might use male terms to show harshness or to be stern. Reveals some of the cultural connotations surrounding gender.

I’m very glad I took this risk even though it was scary, I’m happy with how it went. I hope to continue growing and using my Thai language skills. It would be great to be able to speak directly to the parents of my students who speak Thai instead of relying on a translator (though, the Thai staff that helps us with that are awesome!) And of course, the most rewarding way in which I use this skill is getting to connect more with my family members on this side of the globe. Even though initially, I barely knew any Thai, they’ve been so kind, welcoming and warm to me.

I have to give a special shout-out to my wonderful girlfriend, Mild, who took a look over my slides for me and offered suggestions to improve them. In general, she’s been a huge factor in helping me learn and pushed me take chances like this.

Making a Thai Chat Bot

An assignment I’ve seen several Computer Science teachers give their students is to write a chat bot. I thought that could be cool to do with my students and I always run though assignments myself before assigning them to a class. So, for my take on the assignment, I decided to make a chat bot that speaks Thai. For the code, check it out on codepen. Note that the bot only knows the Thai script, phonetic transcription won’t work. To chat with it visit this page or try it out below:

 

 

 

 

 

 

 

There are lots of Natural Language Processing (NLP) tools out there for English but there aren’t as many in Thai. I took a pretty naive approach to my implementation since there are several challenges in NLP unique to Thai (even tokenizing words is nontrivial since there aren’t spaces between words in the Thai script).

The relevant function in the code is the one that determines what the bot’s response will be to what the user types. To start, lets just have it respond with ไม่เข้าใจ (mai kao jai – I don’t understand) to anything said. Our bot just arrived in Thailand and doesn’t know any phrases other than this.


function chatbotResponse() {
  botMessage = "ไม่เข้าใจ";
}

Alright, we have something going. Next, let’s teach our bot some basic greetings. How do we know if someone is greeting us? We could check to see if the user includes “สวัสดี” or “หวัดดี” anywhere in their message. That covers formal or informal and whatever articles someone may add at the end. It would catch user messages like “หวัดดี” (wat dee – hi) and “สวัสดีค่ะ/ครับ” (sawatdee ka/khrab – Hello) or as my first student tester entered: “สวัสดีจ้าาา” (sawatdee jaaaa – more colloquial way of saying hello in chat) Let’s respond with a random greeting such as สวัสดี (sa wat dee – hello) or สวัสดีครับ (sa wat dee khrab – hello). I’ve chosen to make my bot male so I’ll use particles like ครับ instead of ค่ะ. I’ll remember that going forward to stay consistent.


if (lastUserMessage.includes('สวัสดี') || lastUserMessage.includes('หวัดดี')) {
  /* randomElement is a custom function to pick one of the words in the given list */
  botMessage = randomElement(['สวัสดี','วัสดีครับ','สวัสดีครับ']);
}

Cool, now maybe we should give our bot a name. “Bot” seems appropriate, but let’s write it in Thai:


botName = 'บอท';
if (lastUserMessage.includes('ชื่อ')) {
  botMessage = 'ผมชื่อ' + botName;
}

Again, บอท is male, so we used ผม (pom) for I instead of ฉัน (chan). Next, we should check if the user is asking how we are. Since Bot is a pretty chill guy let’s have him always give a positive response.


  if (lastUserMessage.includes('เป็นอย่างไรบ้าง') || lastUserMessage.includes('สบายดีไหม') || lastUserMessage.includes('สบายดีมั้ย')) {
    botMessage = 'สบายดีมากครับ';
  }

Alright, we’re beefing up Bot’s vocabulary. How about another easy one, “Thank you” and “You’re welcome”. In Thai we might say thank you with either ขอบคุณ ครับ/ค่ะ (kop khun khrap/ka) or the more casual ขอบใจ (kop jai). We could respond with ยินดีครับ (yin dee khrap – you’re welcome) or ไม่เป็นไร (mai bpen rai – no problem/no worries), and of course we could always throw a ครับ (khrap) at the end to add some politeness.


  if (lastUserMessage.includes('ขอบคุณ') || lastUserMessage.includes('ขอบใจ')) {
    botMessage = randomElement([
      'ยินดีครับ',
      'ไม่เป็นไร',
      'ไม่เป็นไรครับ'
    ]);

Let’s give our bot a useful feature. How about telling you the time if you ask? กี่โมง (gee mong (long ‘o’ sound)) is how to ask what time it is so let’s check if the user writes that. And if so, we’ll print out the current time.


/* what time is it? */
if (lastUserMessage.includes('กี่โมง')) {
  botMessage = new Date().toLocaleTimeString();
}

Now, how about a sense of humor? When chatting in Thai, it’s common to see the number 5 (pronounced ‘ha’ in Thai) used for laughter. Maybe 555 or even more 5’s if it’s really funny. So, if we see the word ตลก (talok – funny) in the user’s message let’s output a string of 5’s (anywhere from 3 to 9) to indicate Bot’s amusement.


if (lastUserMessage.includes('ตลก')) {
  let extra_fives = Math.floor(Math.random()*6);
  botMessage = '555';
  for (var i=0; i < extra_fives; ++i) {
    botMessage += '5';
  }
}

Alright, let’s try something a bit more complicated. Let’s try to detect if the user is asking a question and respond either positively or negatively. ไหม (mai, also written as มั้ย) is a particle added to the end of a statement to make it a question. i.e.

เอาไหม (ow mai – do you want it?)
or
ไปไหม (pai mai – do you want to go?)

To respond positively we just chop off the question particle and use the verb i.e.

เอา (ow – I want it)
or
ไป (pai – let’s go)

To respond negatively we still chop off the particle but also add a negation (ไม่ – mai, with a falling tone) in front i.e.

ไม่เอา (mai ow – I don’t want it) or
ไม่ไป (mai pai – let’s not go).


if (lastUserMessage.includes('ไหม')) {
  let i = lastUserMessage.search('ไหม')
  botMessage = lastUserMessage.substr(0,i);
  let coinflip = Math.floor(Math.random()*2);
  if (coinflip) {
    botMessage = 'ไม่' + botMessage;
  }
}

if (lastUserMessage.includes('มั้ย')) {
  let i = lastUserMessage.search('มั้ย')
  botMessage = lastUserMessage.substr(0,i);
  let coinflip = Math.floor(Math.random()*2);
  if (coinflip) {
    botMessage = 'ไม่' + botMessage;
  }
}

I won’t list every single thing I put into the program here but I’ve added more stuff to it. Feel free to chat with บอท to find more messages I’ve added. Or peek at the code. If you’ve got more suggestions for what to teach him, let me know!

What Color is Saturday?

Purple! And Sunday is Red. In Thai culture, each day of the week is associated with a color. Here’s a breakdown of each day and their color:

วันอาทิตย์ (wan ah-tit): Sunday – สีแดง (see daang): Red
วันจันทร์ (wan jan): Monday – สีเหลือง (see leuang): Yellow
วันอังคาร (wan ang-khan): สีชมพู (see champoo): Tuesday – Pink
วันพุธ (wan poot): Wednesday – สีเขียว (see kiaw): Green
วันพฤหัสบดี (wan pa-ru-hat): Thursday -สีส้ม(see som): Orange
วันศุกร์ (wan suk): Friday – สีฟ้า (see fah): Sky Blue
วันเสาร์ (wan sao): Saturday – สีม่วง (see muang): Purple

Each day of the week begins with วัน (wan) which means “day.” If you want to say today, you would add the word for “this.” So it’s วันนี้ (wan nee). Sunday and Monday have similar etymology to the English names of these days. พระอาทิตย์ (phra ah-tit) means “sun “and พระจันทร์ (phra jan) means “moon.” พระ- is a prefix for divine or sacred things in Thai. You can use it to refer to a Buddhist monk.

Similar to how each day starts with วัน (wan), each color starts with สี (see) which means “color.” If you wanted to ask what color something is you could add “what” to the end: สีอะไร (see a-rai). Some other colors that aren’t association with one of the days are:

สีขาว (see khao): white
สีดำ (see dtum): black
สีน้ำเงิน (see nahm ngern): dark blue
สีเทา (see tao): gray
สีน้ำตาล (see nahm dtan): brown

Beyond the connections between specific colors and days of the week, the day of the week that you were born on holds significance in Thai culture similar to how the month or year you were born on is important in some systems like Western astrology or the Chinese Zodiac.  Because of this, many Thai people know the day of the week they were born on whereas I and others I asked from the U.S. did not know without looking it up.

Learning about this actually solved a small personal mystery I encountered growing up and visiting my grandma’s temple in South Carolina. Just like many temples here in Thailand, there were 7 small statues of Buddha lined up with jars beneath them, each in a different pose. Visitors make donations to just one of these jars, but how they chose which jar eluded me until a cousin of mine in Thailand explained it to me during a trip we took together. Each posture is associated with a different day of the week and you should place your offering in the jar below the one that is associated with the day you were born. I had always been partial to the seated Buddha being protected by the Naga (A 7 headed serpent king) because it looked the coolest but it turns out that’s also the one associated with my day of birth. If you’d like to learn more about this, check out this blog post.

Practice matching up colors and days of the week in Thai and English using this tool I made to remember them:

Choose the match:

By the way, I’m a Capricorn , born in the year of the Dragon on a Saturday.

Thai Chess (หมากรุก: Makruk)

It’s always awesome when seemingly unrelated interests collide. That happened for me last summer when I visited Thailand for the first time. I had brought my chessboard because I’m a huge nerd. One of my Thai co-workers  told me he was a former chess champion so we decided to play a match against one another. We ended up setting the pieces up differently and after some discussion, realized we played two different versions of chess. I ended up learning the rules for Thai chess (หมากรุก: Makruk) along with some new Thai words. I also taught him the rules of International Chess and the English names of the pieces. We played each other in both versions and unsurprisingly I won in the version I knew and he won in the version he knew.  Makruk is said to be the closest modern chess variant to the ancient game from which all known versions are derived (Chaturanga from 6th century India). Here are the names of the pieces in Makruk (along with their literal translation and corresponding chess piece):

เบี้ย (bia) – cowry shell – pawn
เม็ด (met) – seed – queen
โคน (khon) – nobleman or mask – bishop
ม้า (ma) – horse – knight
เรือ (ruea) – boat – rook
ขุน (khun) – lord – king

Differences between International Chess and Thai Chess:

  • Pawns start on the 3rd and 6th ranks instead of the 2nd and 7th (therefore, there is no en passant and no moving forward 2 on their first move)
  • The white king and queen have their starting location swapped, so black and white do not have mirrored positions at the beginning
  • Pawns promote automatically when reaching the 3rd or 6th rank instead of the 1st and 8th and always become a queen (called เบี้ยหงาย [bia-ngai: overturned cowry shell] as opposed to เม็ด )
  • Queens can only move to the squares diagonally adjacent to them, making them arguably the weakest pieces in the game
  • Bishops move like the queens (diagonally adjacent) or to the square directly in front of them
  • There is no castling
  • There are a long set of counting rules similar to the 50-move rule in International Chess, you can read about them here.

You can say รุก (ruk: penetrate) instead of check and just add the word ฆาต (khat: kill) to make รุกฆาต (ruk khat: checkmate). Another fun word to use is กิน (gin: eat) when you capture a piece. For example: ม้ากินเรือ (ma gin ruea: the horse eats the boat, I bet that horse would have a bit of a ปวดท้อง [stomach ache] afterward!).

I modified a couple of javascript libraries made to implement chess to work for Makruk instead, try it out:


The libraries I modified:

  • chess.js by Jeff Hlywa released under the BSD license
  • chessboard.js by Chris Oakman released under MIT license (While working with this one I actually discovered a bug, fixed it and submitted a pull request which was accepted. Technically, my first open source contribution!)
    Original copyrights left in the source code

Telling Time in Thai

In my journey to learn Thai there have been words or phrases I’ve needed since my first day living in Thailand and I learned immediately (like telling a taxi driver to turn left, right or go straight) and there have been others that I thought “That’s a little too complicated for now” and I didn’t remember. One of those “too complicated” concepts for me at first was telling time. I’ve decided to finally tackle it and I’ve done so by doing what any good constructionist would do and built on already existing knowledge. I am a computer programmer who teaches computational thinking skills. So I wrote a program to take a given time and tell the user how to say that time in Thai (both in Thai script and roman transliteration). I’ll break down how it works, then let you play with it yourself. Actually, a lesson I’ve learned from teaching is that if you tell someone you’ll let them play after your lecture, they’ll ignore the lecture and just wait for the part where they get to play. So, here, play away!

Enter a time:

Okay, if you liked that and you’re still here I’m assuming you want to know more about how it works. First of all, the ‘time’ input type will give us a value in the format HH:MM anywhere from 00:00 to 23:59 (12:00 a.m. – 11:59 p.m.). To speak about the time in Thai, you need to know what time of day it is:

เที่ยงคืน (tiâng keun): midnight (00:00-00:59)
ตี (dtee): early hours (01:00-05:59)
เช้า (cháo): morning (06:00-11:59)
เที่ยง[วัน] (tiâng [wan]): (12:00-12:59)
บ่าย (bài): afternoon (13:00-15:59)
เย็น (yen): evening (16:00-18:59)
ทุ่ม (tûm): late hours (19:00-23:59)

The next thing to know is that when saying the hour, we work in mod 6 instead of mod 12 (If you’re unfamiliar with modular arithmetic, keep reading and it should make sense). You know how we count up from 1 o’clock, 2 o’clock, …, 12 o’clock, then start over again at 1 o’clock p.m.? Well, in Thai we can count up from 1 o’clock, 2 o’clock, …, 6 o’clock and go back to 1 o’clock. So you “roll over” 3 times in a day instead of just once (a.m. to p.m.). One thing to note is that Thai can be a pretty forgiving language. If you say 7 in the morning instead of 1 in the morning, it will still make sense.

Some more important words:

โมง (mong, long ‘o’ sound like in go or row): hour
นาที (na tee): minute

Also, the numbers 1-59. I’ll do a separate post about numbers in Thai (Until then, here’s a good reference). Here are the first 6 since they’ll be the most common since we need them for the hours:

หนึ่ง (neung): one
สอง (song): two
สาม (saam): three
สี่ (see): four
ห้า (ha): five
หก (hok, again, long ‘o’ sound): six

Saying the hour portion is different during the different parts of day. For noon and midnight, we just say เที่ยงคืน/เที่ยง. Early hours it’s the time of day then the hour number (1 .a.m. = ตีหนึ่ง ). In the morning and evening it’s [hour number] + โมง + [time of day] (6 a.m. = หกโมงเช้า, 6 p.m. = หกโมงเย็น). Afternoon, it’s บ่าย + [hour number] +โมง (3 p.m. = บ่ายสามโมง ) but you don’t have to put the number if it’s one (1 p.m. = บ่ายโมง ). Late hours, it’s [hour number] + ทุ่ม (11 p.m. = ห้าทุ่ม).

Minutes are easy enough, unless you’re at minute zero (*:00), just add the number and the word for minutes (2:03 p.m. = บ่ายสองโมงสามนาที: bai song mong saam na tee ). Now, just like in English, we could say things like ครึ่ง (kreung: half) instead of *:30, or 5/10/15 ’til the next hour but I haven’t included those in this program. We could also say [hour number] + [the Thai word for clock] the same way you use “o’clock” in English but you need to switch to a 24 hour system (ex. 6 o’clock am = หกนาฬิกา: hok na lee gah but 6 o’clock pm would be “18 o’clock” = สิบแปดนาฬิกา: sib bad na lee gah ).

By coding this up, I had to think about the patterns and rules for when to say what when talking about time in Thai which has definitely helped my understanding. Thanks for checking it out!

Featured Image originally posted on Flickr by Jorge Láscar  licensed under the Creative Commons Attribution 2.0 Generic license.