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

Version Path
facets-1.0.0 lib/facet/string/probability.rb
facets-1.0.3 packages/core/lib/facet/string/probability.rb
facets-1.1.0 lib/facet/string/probability.rb
facets-1.2.0 lib/facets/core/string/probability.rb
facets-1.2.1 lib/facets/core/string/probability.rb
facets-1.3.0 lib/facets/core/string/probability.rb
facets-1.3.1 lib/facets/core/string/probability.rb
facets-1.3.2 lib/facets/core/string/probability.rb
facets-1.3.3 lib/facets/core/string/probability.rb
facets-1.4.0 lib/facets/core/string/probability.rb
facets-1.4.1 lib/facets/core/string/probability.rb