SWATH(1)
π SWATH β the Thai word segmentation queen π
okay bestie, pull up a chair, because swath(1) is about to become your new obsession. it's the general-purpose Thai word segmentation utility, it lives in the General Commands Manual, and it is literally the moment.
β¨ NAME β¨
swath β general-purpose Thai word segmentation utility π¦
πΈ SYNOPSIS πΈ
swath [options] < infile > outfile
that's it. that's the whole vibe. in goes text, out comes text with words actually separated. slay. π
π DESCRIPTION π
so here's the tea, bestie: Thai script has no word delimitor. none. zero. it's giving "figure it out yourself." and apps kinda need to know where words end before they can do anything useful with Thai text β like, idk, line wrapping? basic stuff? π
Swath is here to fix that. it provides a word analysis filter that inserts word delimitors into a given text stream. it reads text from standard input, analyzes it for word boundaries by consulting a Thai word list, and outputs to standard output the same text with the predefined word delimitors inserted. no cap.
currently, it can read plain text, HTML, RTF, LaTeX and Lambda (that's the Unicode version of LaTeX with the Omega typesetter kernel, iykyk) documents and insert common word delimitors for each format β pipe | for plain text, obviously. but you can always override this with a preferred delimitor. main character energy fr fr. β¨
π OPTIONS π
-b [delimitor]β define the string to be inserted as word delimitor in the output text. your delimitor, your rules. π-d [dict-path]β specify an alternative dictionary location.dict-pathmust be either a directory containing the swath dictionary fileswathdic.tri, or a path to the dictionary file itself. the dictionary file must be a trie file prepared usingtrietool(1)utility from thelibdatriepackage. if this option is given, swath will override normal dictionary search and will exit if the given dictionary cannot be found. otherwise, ifSWATHDICTenvironment is set, it will try to open the dictionary from the location specified by its value. otherwise, it will try the current working directory, and finally the usual installed location. the search order is that girl. π-f [format]β specify format of the input. possible formats are:html,rtf,latex,lambda. pick your fighter. π₯-m [scheme]β choose word matching scheme when analyzing word boundaries. possible schemes arelong(for longest or greedy matching) andmax(for maximal matching, with least words preferred). maximal matching is the default value.maxis the default bestie, don't forget. π-u input-enc,output-encβ specify encodings of the input and the output.input-encandoutput-enccan be one of'u'(for UTF-8 encoding) and't'(for TIS-620 encoding). Swath will convert the character encoding as necessary. if this option is omitted, TIS-620 encodings on both input and output are assumed. yes, both. default. noted. π-v,--verboseβ turn on verbose mode. she's chatty now. π£οΈ-help,--helpβ show help. a little help, as a treat. π«Ά
π§ ENVIRONMENT VARIABLES π§
SWATHDICTβ if specified, swath will search for the dictionary from this location before the usual places (current working directory and usual installed directory, respectively). this value is overridden by the-doption. so like,-dis the louder sibling. π
π₯ EXAMPLES π₯
for LaTeX (to be used with babel-thai package):
$ swath -f latex < thaifile.tex > thaifile.ttex
$ latex thaifile.ttex
for HTML (to provide web pages to web browsers that cannot wrap Thai lines properly, but support the <wbr> tag):
$ swath -f html < myweb.html > myweb-wbr.html
to preprocess a Thai UTF-8 encoded LaTeX file for babel-thai with tis620 inputenc:
$ swath -f latex -u u,t < thaifile.tex > thaifile.ttex
$ latex thaifile.ttex
this is equivalent to filtering with iconv(1):
$ iconv -f UTF-8 -t TIS-620 thaifile.tex | swath -f latex >
thaifile.ttex
$ latex thaifile.ttex
to use longest matching scheme with a LaTeX document:
$ swath -f latex -m long < thaifile.tex > thaifile.ttex
$ latex thaifile.ttex
to use an alternative dictionary from libthai:
$ swath -f latex -d /usr/share/libthai/thbrk.tri < thaifile.tex >
thaifile.ttex
look at those pipelines go. ate. π β¨
π AUTHOR π
this manual page was written by Theppitak Karoonboonyanan <theppitak@gmail.com>. iconic behavior, honestly. π
and that's the whole page, bestie!! π¦ this one's from January 2008 and it's the SWATH(1) page, and yes we are still stanning it all these years later. go segment some Thai text, you absolute legend. mwah. πππΈ
π¦ where this page comes from
- debian bookworm: swath 0.6.1-3 Β· GPL-2.0-or-later
- debian trixie: swath 0.6.1-4 Β· GPL-2.0-or-later
- ubuntu jammy: swath 0.6.1-2build1 Β· GPL-2.0-or-later
- ubuntu noble: swath 0.6.1-3 Β· GPL-2.0-or-later
- ubuntu questing: swath 0.6.1-4
- ubuntu resolute: swath 0.6.1-4build1 Β· GPL-2.0-or-later
- ubuntu stonking: swath 0.6.1-5 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms