Skip to content

seanghay/split-khmer

Repository files navigation

split-khmer

Split Khmer words

Split Khmer sentence into an array of words.

test version

Installation

npm i split-khmer

Usage

// 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);
// [ 'កូន', 'ខ្មែរ', 'អាច', 'ធ្វើ', 'បាន' ]

⚠️ Note

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/split-khmer@0.0.3/dist/break_iterator_km.wasm

Use this library as a polyfill: intl-segmenter-polyfill

Browser Supports

https://caniuse.com/mdn-javascript_builtins_intl_segmenter_segment

License

MIT