require 'nano/string/to_arr' require 'nano/enumerable/probability' class String def probability(*args) to_arr(*args).probability end end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TCString < Test::Unit::TestCase def test_probability assert_equal( {'a'=>0.5,'b'=>0.5}, "ab".probability ) assert_equal( {'tom'=>0.5,'boy'=>0.5}, "tom boy".probability(:word) ) assert_equal( {'tom'=>0.5,'boy'=>0.5}, "tom\nboy".probability(:line) ) end end =end