Skip to content

Latest commit

 

History

History
61 lines (43 loc) · 1.97 KB

README.md

File metadata and controls

61 lines (43 loc) · 1.97 KB

Myanmar Tools JavaScript Documentation

This documentation is for JavaScript specific usage of Myanmar Tools. For general documentation, see the top-level README.

Node.JS Usage

Add the dependency to your project:

$ npm install --save myanmar-tools

To detect Zawgyi, create an instance of ZawgyiDetector, and call getZawgyiProbability with your string.

const google_myanmar_tools = require("myanmar-tools"); 
const detector = new google_myanmar_tools.ZawgyiDetector();
const score = detector.getZawgyiProbability("မ္း");
// score is now 0.9994253818489524 (very likely Zawgyi)

Zawgyi can be converted to Unicode as follows:

const google_myanmar_tools = require("myanmar-tools");
const converter = new google_myanmar_tools.ZawgyiConverter();
const output = converter.zawgyiToUnicode("မ္း");
// output is now "မ်း"

You can use converter.unicodeToZawgyi("...") to convert in the opposite direction when possible.

For a complete working example, see samples/node/demo.js.

Browser Usage

Include the file zawgyi_detector.min.js. It is available on Google Hosted Libraries:

<script src="https://ajax.googleapis.com/ajax/libs/myanmar-tools/1.2.1/zawgyi_detector.min.js"></script>

After doing this, the ZawgyiDetector will be available as the global google_myanmar_tools.ZawgyiDetector, and you can use it the same way as above:

const detector = new google_myanmar_tools.ZawgyiDetector();
const score = detector.getZawgyiProbability("မ္း");
// score is now 0.0.9997572675217831 (very likely Zawgyi)

Likewise for the converter:

<script src="https://ajax.googleapis.com/ajax/libs/myanmar-tools/1.2.1/zawgyi_converter.min.js"></script>
const converter = new google_myanmar_tools.ZawgyiConverter();
const output = converter.zawgyiToUnicode("မ္း");
// output is now "မ်း"