Sha256: a333c5c390b7afe9fafd86170f8af6e2d26b42f1585a0462c25784174e7de64b
Contents?: true
Size: 596 Bytes
Versions: 11
Compression:
Stored size: 596 Bytes
Contents
require 'facet/string/to_arr' require 'facet/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
Version data entries
11 entries across 11 versions & 1 rubygems