class MyanmarTools::ZawgyiDetector
Uses a machine learning model to determine whether a string of text is Zawgyi or Unicode. For more details and documentation, see github.com/google/myanmar-tools
Public Class Methods
new()
click to toggle source
# File lib/myanmar-tools.rb, line 23 def initialize @model = ZawgyiUnicodeMarkovModel.new(stream_markov_model) end
Public Instance Methods
get_zawgyi_probability(input='', verbose = false)
click to toggle source
@param1 input The string on which to run detection. @param2 verbose If true, print debugging information to standard output. @return The probability that the string is Zawgyi (between 0 and 1), or -Infinity if the string
contains no Myanmar range code points.
# File lib/myanmar-tools.rb, line 37 def get_zawgyi_probability(input='', verbose = false) @model.predict(String(input), verbose) end
Private Instance Methods
stream_markov_model()
click to toggle source
Open markov model from the specified path
# File lib/myanmar-tools.rb, line 44 def stream_markov_model file_path = File.join(File.dirname(__FILE__), '/myanmar-tools/resources/zawgyiUnicodeModel.dat') if File.file?(file_path) begin File.open(file_path, File::RDONLY) rescue raise 'Could not open Markov Model file zawgyiUnicodeModel.dat.' end else raise 'Could not find Markov model file.' end end