Package Exports
- knayi-myscript
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (knayi-myscript) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Knayi Myanmar Script
Standalone Myanmar languages js library, to build Myanmar Unicode standard web.
Announce on breaking API changes from 2.4.2 -> 2.5.0
- All throw Error are now become console.warn and console.error
- If content not found happens, #fontConvert, #spellingCheck, #syllBreak all return empty string
- If content not found happens, #fontDetect return fallback_font_type or 'en'
- You can set silent by setting
knayi.setGlobalOptions({silent_mode: true})
Node Version
- Required node version >= 4
Note: From version >=2.3.0 build step will only support for node >=6
Features
- Detector (Unicode and Zawgyi) Detection now
- Converter (Unicode and Zawgyi)
- SyallBreak (Unicode and Zawgyi)
- Spelling Check (Unicode and Zawgyi)
Installation
Using npm
npm install knayi-myscript --saveUsing yran
yarn add knayi-myscriptUsing CDN
<script src="https://unpkg.com/knayi-myscript@latest/dist/knayi-myscript.min.js"></script>API
| Method Name | Arguments | Return | Note |
|---|---|---|---|
fontDetect |
content: String(require), fallbackFontType:, options fontName(options), options: Object(options) |
String |
Font Detector, it will detect unicode/zawgyi of the content Text. If nothing is matched or possibility are equal, it will return as 'zawgyi' or specified font type in fallbackFontType, options params. |
fontConvert |
content: String(require),convertTo: fontName(require),convertFrom: fontName(optional) |
String |
Converting font to target font type. This method need spelling fix, so it gonna use spellingFix in default. convertFrom will be detect by fontDetect when you don't described.fontName must be one of unicode or zawgyi. |
syllBreak |
content: String(require),fontType: fontName(optional),breakPoint: String(optional) |
String |
To make systematic word break of Myanmar text. convertFrom will be detect by fontDetect when you don't described.fontName must be one of unicode or zawgyi. |
spellingFix |
content: String(require),fontType: fontName(optional) |
String |
convertFrom will be detect by fontDetect when you don't described. It fix spelling on Myanmar Text.fontName must be one of unicode or zawgyi. |
Usage
// ES5 Way
var knayi = require('knayi-myscript')
// ES6 Way
import knayi from 'knayi-myscript'Example
- fontDetect(content, [fallbackFontType], options)
knayi.fontDetect('မဂၤလာပါ') // zawgyi
knayi.fontDetect('မင်္ဂလာပါ') // unicode- fontConvert(content, convertTo, [convertFrom])
knayi.fontConvert('မဂၤလာပါ', 'unicode', 'zawgyi') // မင်္ဂလာပါ
knayi.fontConvert('မဂၤလာပါ', 'unicode') // မင်္ဂလာပါ- syllBreak(content, [fontType] [,breakPoint])
knayi.syllBreak('မင်္ဂလာပါ', null, '$$') // 'မင်္ဂလာ$$ပါ'- spellingFix(content, [fontType])
knayi.spellingFix('မင်္ဂလာာပါါ') // 'မင်္ဂလာပါ'Using googlei18n/myanmartools in detector.js
Now you can now use googlei18n/myanmartools library in detector.
By default use_myanmartools options is set to false.
// Add options for single process
knayi.fontDetect('မဂၤလာပါ', null, {use_myanmartools: true}) // this will use myanmartools
knayi.fontDetect('မင်္ဂလာပါ') // this will use default
// OR set for whole project
knayi.setGlobalOptions({
detector: {
use_myanmartools: true
}
})You can also set Probability threshold percentages of zawgyi predicting by
myanmartools_zg_threshold as [lower, higher]. Which mean if predicting
result of myanmartools is < 0.05 detector.js assume as **unicode** or > 0.95
it assume as zawgyi.
knayi.fontDetect('မင်္ဂလာပါ', null, {
use_myanmartools: true,
myanmartools_zg_threshold: [0.05, 0.95]
})Debugging of font converting
Visit http://tools.kny.co/knayi-myscript#debug_mode and select text to track how converting happened in background.
Build
- Required node >=6
npm run build
To build production runwebpack -p

