Split Khmer sentence into an array of words.
npm i split-khmer
// Node.js 16+ ESM
import { split } from 'split-khmer'
// Browser Module
import { split } from 'https://unpkg.com/split-khmer@latest/dist/index.mjs'
// CommonJS
const { split } = require('split-khmer')
const values = split('កូនខ្មែរអាចធ្វើបាន');
console.log(values);
// [ 'កូន', 'ខ្មែរ', 'អាច', 'ធ្វើ', 'បាន' ]
Intl.Segmenter
is available only in Node.js 16 and latest Chrome browser. You need to use a polyfill to make it available to older browsers.
We provided a BreakIterator binary for you in order to create a polyfill for Khmer language. The binary file will be in ./dist/break_iterator_km.wasm
.
e.g. The distibuted url will be https://unpkg.com/[email protected]/dist/break_iterator_km.wasm
Use this library as a polyfill: intl-segmenter-polyfill
https://caniuse.com/mdn-javascript_builtins_intl_segmenter_segment
MIT