How to use the myanmar-tools.ZawgyiDetector function in myanmar-tools

To help you get started, we’ve selected a few myanmar-tools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github google / myanmar-tools / samples / node / index.js View on Github external
const assert = require("assert");
const google_myanmar_tools = require("myanmar-tools");

const detector = new google_myanmar_tools.ZawgyiDetector();
const converter = new google_myanmar_tools.ZawgyiConverter();

// Unicode string:
const input1 = "အပြည်ပြည်ဆိုင်ရာ လူ့အခွင့်အရေး ကြေညာစာတမ်း";
// Zawgyi string:
const input2 = "အျပည္ျပည္ဆိုင္ရာ လူ႔အခြင့္အေရး ေၾကညာစာတမ္း";

// Detect that the second string is Zawgyi:
const score1 = detector.getZawgyiProbability(input1);
const score2 = detector.getZawgyiProbability(input2);
assert(score1 < 0.001);
assert(score2 > 0.999);
console.log("Unicode Score:", score1.toFixed(6));
console.log("Zawgyi Score:", score2.toFixed(6));

// Convert the second string to Unicode:
github longjiang / zerotohero-cli / src / components / Annotate.vue View on Github external
convertBurmese(text) {
      console.log('converting burmese ' + text)
      const detector = new MyanmarTools.ZawgyiDetector()
      const score = detector.getZawgyiProbability(text)
      if (score > 0.5) {
        const converter = new MyanmarTools.ZawgyiConverter()
        console.log('Zawgyi detected')
        return converter.zawgyiToUnicode(text)
      } else {
        return text
      }
    },
    async recursive(node) {
github greenlikeorange / knayi-myscript / library / detector.js View on Github external
const library = {};
const mmCharacterRange = /[\u1000-\u109F]/;
const whitespace = '[\\x20\\t\\r\\n\\f]';

const globalOptions = require('./globalOptions');

let myanmartoolZawgyiDetector;
try {
  const myanmartools = require('myanmar-tools');
  myanmartoolZawgyiDetector = new myanmartools.ZawgyiDetector();
} catch (e) {

}

/** DETECTION Libarary **/
library.detect = {
  unicode: [
    '\u103e', '\u103f', '\u100a\u103a', '\u1014\u103a', '\u1004\u103a', '\u1031\u1038', '\u1031\u102c',
    '\u103a\u1038', '\u1035', '[\u1050-\u1059]', '^([\u1000-\u1021]\u103c|[\u1000-\u1021]\u1031)'
  ],
  zawgyi : [
    '\u102c\u1039', '\u103a\u102c', whitespace+'(\u103b|\u1031|[\u107e-\u1084])[\u1000-\u1021]'
    ,'^(\u103b|\u1031|[\u107e-\u1084])[\u1000-\u1021]', '[\u1000-\u1021]\u1039[^\u1000-\u1021]', '\u1025\u1039'
    ,'\u1039\u1038' ,'[\u102b-\u1030\u1031\u103a\u1038](\u103b|[\u107e-\u1084])[\u1000-\u1021]' ,'\u1036\u102f'
    ,'[\u1000-\u1021]\u1039\u1031' , '\u1064','\u1039'+whitespace, '\u102c\u1031'
    ,'[\u102b-\u1030\u103a\u1038]\u1031[\u1000-\u1021]', '\u1031\u1031', '\u102f\u102d', '\u1039$'

myanmar-tools

Tools for handling the Zawgyi font encoding in Myanmar.

Apache-2.0
Latest version published 4 years ago

Package Health Score

54 / 100
Full package analysis