myanmartools

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

README

Build Status Go Report Card

Myanmar Tools Golang Documentation

This documentation is for Golang specific usage of Myanmar Tools.

Installation

$ go get -u github.com/ayeminag/go-myanmartools

Usage

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

import (
    "fmt"
    "github.com/ayeminag/go-mayanmartools"
)

func main() {
    zgDetector := myanmartools.NewZawgyiDetector()
    score := zgDetector.GetZawgyiProbability("မ္း")
    fmt.Printf("Score: %f\n", score) 
    // print Score: 0.9999772 to the console
    // it is very likely to be typed in zawgyi
}

To convert from Zawgyi to Unicode, you can use Rabbit Converter Go version. You can install it like this:

$ go get -u github.com/Rabbit-Converter/Rabbit-Go

You can now convert text Between Zawgyi <=> Unicode like this:

package main

import (
    "fmt"
    "github.com/Rabbit-Converter/Rabbit-Go"
)

func main() {
    fmt.Println(rabbit.Zg2uni(("သီဟိုဠ္မွ ဉာဏ္ႀကီးရွင္သည္ အာယုဝဍ္ဎနေဆးၫႊန္းစာကို ဇလြန္ေဈးေဘးဗာဒံပင္ထက္ အဓိ႒ာန္လ်က္ ဂဃနဏဖတ္ခဲ့သည္။"))
    // output is now "သီဟိုဠ်မှ ဉာဏ်ကြီးရှင်သည် အာယုဝဍ်ဎနဆေးညွှန်းစာကို ဇလွန်ဈေးဘေးဗာဒံပင်ထက် အဓိဋ္ဌာန်လျက် ဂဃနဏဖတ်ခဲ့သည်။")
    fmt.Println(rabbit.Unizg("သီဟိုဠ်မှ ဉာဏ်ကြီးရှင်သည် အာယုဝဍ်ဎနဆေးညွှန်းစာကို ဇလွန်ဈေးဘေးဗာဒံပင်ထက် အဓိဋ္ဌာန်လျက် ဂဃနဏဖတ်ခဲ့သည်။"))
    // output is now "သီဟိုဠ္မွ ဉာဏ္ႀကီးရွင္သည္ အာယုဝဍ္ဎနေဆးၫႊန္းစာကို ဇလြန္ေဈးေဘးဗာဒံပင္ထက္ အဓိ႒ာန္လ်က္ ဂဃနဏဖတ္ခဲ့သည္။")

}

Documentation

Overview

Package myanmartools Code generated by go-bindata. (@generated) DO NOT EDIT. sources: resources/compatibility.tsv resources/zawgyiUnicodeModel.dat

Index

Constants

View Source
const (
	//BinaryTag Magic number used to identify
	//this object in byte slice
	BinaryTag = 0x424D41524B4F5620

	//BinaryVersion current serial format
	//version number, used in assiciation with magic number
	BinaryVersion = 0
)
View Source
const (
	//ModelBinaryTag Magic number used to identify this object in byte streams. (Reads in ASCII as "UZMODEL")
	ModelBinaryTag = 0x555A4D4F44454C20
	//StdCp0 Standard Myanmar code point range before digits
	StdCp0 int = '\u1000'
	//StdCp1 Standard Myanmar code point range before digits
	StdCp1 int = '\u103F'
	//AftCp0 standard myanmar code point range after digits
	AftCp0 int = '\u104A'
	//AftCp1 standard myanmar code point range after digits
	AftCp1 int = '\u109F'
	//ExaCp0 extended myanmar code point range A
	ExaCp0 int = '\uAA60'
	//ExaCp1 extended myanmar code point range A
	ExaCp1 int = '\uAA7F'
	//ExbCp0 extended Myanmar code point range B
	ExbCp0 int = '\uA9E0'
	//ExbCp1 extended Myanmar code point range B
	ExbCp1 int = '\uA9FF'
	//SpcCp0 unicode space character
	SpcCp0 int = '\u2000'
	//SpcCp1 unicode space character
	SpcCp1 int = '\u200B'

	//StdOffset index into Markov Nodes
	StdOffset int = 1
	//AftOffset index into Markov Nodes
	AftOffset int = StdOffset + StdCp1 - StdCp0 + 1
	//ExaOffset index into Markov Nodes
	ExaOffset int = AftOffset + AftCp1 - AftCp0 + 1
	//ExbOffset index into Markov Nodes
	ExbOffset int = ExaOffset + ExaCp1 - ExaCp0 + 1
	//SpcOffset index into Markov Nodes
	SpcOffset int = ExbOffset + ExbCp1 - ExbCp0 + 1
	//EndOffset index into Markov Nodes
	EndOffset int = SpcOffset + SpcCp1 - SpcCp0 + 1

	//SsvStdExaExbSpc include Myanmar, Extended A, Extended B and space-like
	SsvStdExaExbSpc int = 0
	//SsvStdExaExb same as above but no space-like code points
	SsvStdExaExb int = 1
	//SsvCount ssv count
	SsvCount int = 2
)

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type BinaryMarkov

type BinaryMarkov interface {
	GetLogProbabilityDifference(i1 int, i2 int) float32
}

BinaryMarkov interface

func NewBinaryMarkov

func NewBinaryMarkov(datReader *bufio.Reader) BinaryMarkov

NewBinaryMarkov return new instance of BinaryMarkov implementation

type ZawgyiDetector

type ZawgyiDetector struct {
	// contains filtered or unexported fields
}

ZawgyiDetector struct

func NewZawgyiDetector

func NewZawgyiDetector() *ZawgyiDetector

NewZawgyiDetector return *NewZawgyiDetector

func (*ZawgyiDetector) GetZawgyiProbability

func (zd *ZawgyiDetector) GetZawgyiProbability(input string) float64

GetZawgyiProbability method

type ZawgyiUnicodeMarkovModel

type ZawgyiUnicodeMarkovModel interface {
	GetIndexForCodePoint(cp int, ssv int) int
	GetSize(ssv int) int
	Predict(input string) float64
}

ZawgyiUnicodeMarkovModel interface

func NewZawgyiUnicodeMarkovModel

func NewZawgyiUnicodeMarkovModel(classifier BinaryMarkov, ssv int) ZawgyiUnicodeMarkovModel

NewZawgyiUnicodeMarkovModel creates and returns ZawgyiUnicodeMarkovModel implementation for classifier and ssv

func NewZawgyiUnicodeMarkovModelFromReader

func NewZawgyiUnicodeMarkovModelFromReader(datReader *bufio.Reader) ZawgyiUnicodeMarkovModel

NewZawgyiUnicodeMarkovModelFromReader creates and returns ZawgyiUnicodeMarkovModel from specified dat file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL