Skip to content

This repository is customized platform support of https://github.com/google/myanmar-tools to use in iOS and macOS by Swift language.

License

Notifications You must be signed in to change notification settings

lawinko/ZawgyiDetector

Repository files navigation

Zawgyi Detector Documentation

This documentation is for Swift specific usage of myanmar-tools.

Installation

Cocoapods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate ZawgyiDetector into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'zawgyidetector', '~> 1.2'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate ZawgyiDetector into your Xcode project using Carthage, specify it in your Cartfile:

github "lawinko/ZawgyiDetector" ~> 1.2

Usage

Create a singleton instance of ZawgyiDetector class and pass input string that you want to predict into predict function.

import zawgyidetector

let detector = ZawgyiDetector.shared
detector.predict(input: "မ္း")

// score is now 0.999772 (very likely Zawgyi)

Returns negative infinity when input is not burmese

let rawStr = "hello, world"
let probability = detector.predict(input: rawStr) // returns -Inf

if probability.isInfinite { 
    // Not burmese text. No need to convert
}

Zawgyi <-> Unicode conversion

You can check on this - https://github.com/Rabbit-Converter/Rabbit-Swift