thai-typo-check
utils for check Thai typo
TypeScript
import { thaiTypoCheck, thaiTypoCheckWords } from "thai-typo-check";
const goodSentence = "ฉันอยากกินยำ";
const typoSentence = "ฉันอยากกินผฟใก่ร์";
test("thaiTypoCheck", () => {
const sentenceIncludesCustomWords = "ฉันอยากกินยำซี้ดพัทยา";
expect(thaiTypoCheck(goodSentence)).toBe(true);
expect(thaiTypoCheck(typoSentence)).toBe(false);
expect(thaiTypoCheck(sentenceIncludesCustomWords, ["ซี้ด", "พัทยา"])).toBe(
true
);
});
test("thaiTypoCheckWords", () => {
expect(thaiTypoCheckWords(goodSentence)).toBe(undefined);
expect(thaiTypoCheckWords(typoSentence)).toEqual("ฉัน,อยาก,กิน>>ผฟใก่ร์<<");
});
License
MIT