Published
Edited
Aug 10, 2022
Importers
1 star
Insert cell
Insert cell
Intl
Insert cell
Intl.Collator // ไว้ sort string
Insert cell
Intl.Segmenter // ยังไม่มีการ implement
Insert cell
Intl.v8BreakIterator // ตัวที่มีแล้ว อยู่ใน v8 engine
Insert cell
Insert cell
iter = new Intl.v8BreakIterator(['th'])
Insert cell
Insert cell
{
iter.adoptText(text)
var pos = iter.first()
return iter.next() // สวัสดี
}

Insert cell
Insert cell
Insert cell
Insert cell
function* gen_words(text){
const it = new Intl.v8BreakIterator(['th'])
it.adoptText(text)
let start = it.first()
while (true) {
let end = it.next()
if (end === -1) break
yield text.slice(start, end);
start = end
}
}
Insert cell
function segment(text){
return [...gen_words(text)]
}
Insert cell
segment('สวัสดีครับ สบายดีไหมครับ')
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more