Skip to Content

Working with Thai

This guide covers Thai-specific features and patterns in GLOST.

Thai Language Characteristics

Thai has unique characteristics that GLOST handles:

  • No word spaces - Words run together without breaks
  • Tonal language - 5 tones affect meaning
  • Complex script - Consonants, vowels, tone marks combine
  • Multiple romanization systems - RTGS, AUA, Paiboon+

Creating Thai Words

Basic Thai Word

import { createThaiWord } from '@glotblocks/glost-th'; const word = createThaiWord({ text: "สวัสดี", rtgs: "sawatdi", partOfSpeech: "interjection", tone: 2, syllables: ["sa", "wat", "di"] }); // Minimal - just text const minimalWord = createThaiWord({ text: "สวัสดี" });

With Multiple Transcriptions

import { createGLOSTWordNode } from '@glotblocks/glost'; const word = createGLOSTWordNode({ value: "สวัสดี", transcription: { rtgs: { text: "sawatdi" }, ipa: { text: "sa.wàt.diː" }, paiboon: { text: "sa-wat-dii", tone: 2, syllables: ["sa", "wat", "dii"] }, aua: { text: "sàwàtdii" } }, metadata: { partOfSpeech: "interjection", formality: "formal" }, lang: "th", script: "thai" });

Transcription Systems

RTGS (Royal Thai General System)

Official government romanization:

{ rtgs: { text: "sawatdi" } }

Features:

  • Official standard
  • No tone marks
  • Used in road signs, official documents

IPA (International Phonetic Alphabet)

Precise phonetic representation:

{ ipa: { text: "sa.wàt.diː" } }

Features:

  • Universal standard
  • Includes tone diacritics
  • Precise vowel representation

Paiboon+

Popular learning system:

{ paiboon: { text: "sa-wat-dii", tone: 2, syllables: ["sa", "wat", "dii"] } }

Features:

  • Hyphen-separated syllables
  • Tone marks (optional)
  • Good for learners

AUA

Another learning-focused system:

{ aua: { text: "sàwàtdii" } }

Word Segmentation

Thai has no spaces, so word segmentation is needed.

Manual Segmentation

import { createThaiWord } from '@glotblocks/glost-th'; import { createSentenceFromWords } from '@glotblocks/glost'; const words = [ createThaiWord({ text: "สวัสดี", rtgs: "sawatdi", partOfSpeech: "interjection" }), createThaiWord({ text: "ครับ", rtgs: "khrap", partOfSpeech: "particle" }) ]; const sentence = createSentenceFromWords( words, "th", "thai", "สวัสดีครับ" // Store original unsegmented text );

Tone Information

Thai has 5 tones that change word meaning.

Storing Tone Data

import { createGLOSTWordNode } from '@glotblocks/glost'; const word = createGLOSTWordNode({ value: "มา", transcription: { rtgs: { text: "ma" }, ipa: { text: "maː", tone: 1 // Mid tone } }, metadata: { partOfSpeech: "verb" }, lang: "th", script: "thai" });

Tone Numbers

ToneNumberExamplePaiboon Mark
Mid1มา (ma)(none)
Low2หมา (maa)̀
Falling3ม้า (maa)̂
High4มา (maa)́
Rising5ม๊า (maa)̌

Polite Particles

Thai uses gendered politeness particles:

import { createThaiWord } from '@glotblocks/glost-th'; // Male speaker const khrap = createThaiWord({ text: "ครับ", rtgs: "khrap", partOfSpeech: "particle" }); // Female speaker const kha = createThaiWord({ text: "ค่ะ", rtgs: "kha", partOfSpeech: "particle" });

Gender Variants

import { createGLOSTWordNode } from '@glotblocks/glost'; const word = createGLOSTWordNode({ value: "ครับ/ค่ะ", transcription: { rtgs: { text: "khrap/kha", variants: [ { text: "khrap", context: "male" }, { text: "kha", context: "female" } ] } }, metadata: { partOfSpeech: "particle" }, lang: "th", script: "thai" });

Sentence Structure

Basic Thai Sentence

import { createThaiWord } from '@glotblocks/glost-th'; import { createSentenceFromWords } from '@glotblocks/glost'; const words = [ createThaiWord({ text: "ผม", rtgs: "phom", partOfSpeech: "pronoun" }), // I (male) createThaiWord({ text: "กิน", rtgs: "kin", partOfSpeech: "verb" }), // eat createThaiWord({ text: "ข้าว", rtgs: "khao", partOfSpeech: "noun" }), // rice createThaiWord({ text: "ครับ", rtgs: "khrap", partOfSpeech: "particle" }) // polite ]; const sentence = createSentenceFromWords( words, "th", "thai", "ผมกินข้าวครับ" );

With Translations

import { createGLOSTSentenceNode } from '@glotblocks/glost'; const sentence = createGLOSTSentenceNode({ originalText: "ผมกินข้าวครับ", lang: "th", script: "thai", children: words, extras: { translations: { en: "I eat rice.", ja: "私はご飯を食べます。" } } });

Document Example

import { createThaiWord } from '@glotblocks/glost-th'; import { createSentenceFromWords, createParagraphFromSentences, createDocumentFromParagraphs } from '@glotblocks/glost'; // Create a Thai lesson document const greeting = [ createThaiWord({ text: "สวัสดี", rtgs: "sawatdi", partOfSpeech: "interjection" }), createThaiWord({ text: "ครับ", rtgs: "khrap", partOfSpeech: "particle" }) ]; const response = [ createThaiWord({ text: "สวัสดี", rtgs: "sawatdi", partOfSpeech: "interjection" }), createThaiWord({ text: "ค่ะ", rtgs: "kha", partOfSpeech: "particle" }) ]; const sentences = [ createSentenceFromWords(greeting, "th", "thai", "สวัสดีครับ"), createSentenceFromWords(response, "th", "thai", "สวัสดีค่ะ") ]; const paragraph = createParagraphFromSentences(sentences); const document = createDocumentFromParagraphs( [paragraph], "th", "thai", { title: "Thai Greetings" } );

Processing Thai Documents

import { processGLOSTWithExtensionsAsync } from '@glotblocks/glost-plugins'; const result = await processGLOSTWithExtensionsAsync(document, [ transcriptionExtension, freqGen, freqEnh, diffGen, diffEnh ]); // Access processed document const processedDoc = result;
Last updated on