0.0
No commit activity in last 3 years
No release in over 3 years
An engine that finds words from a set of letters and calculates the scrabble score
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
= 3.0.0
= 0.9.1
 Project Readme

ScrabbleScore

A simple Scrabble cheating library that estimates word score. Given a set of letters, one can search for all permutation against the SOWPODS dictionary. For example:

ScrabbleScore::WordFinder.new.search_with_score('uiqza')

Which returns:

{"qi"=>11, "za"=>11, "ai"=>2, "qua"=>12, "quiz"=>22, "quai"=>13}

Also, there is a command line interface:

> scrabble_score dafs
fads, 8
fad, 7
fas, 6
fa, 5
sad, 4
das, 4
ads, 4
da, 3
ad, 3
as, 2

Installation

Add this line to your application's Gemfile:

gem 'scrabble_score'

And then execute:

$ bundle

Or install it yourself as:

$ gem install scrabble_score

Usage

One can search for words in the dictionary without score estimates via the following Ruby script:

require 'scrabble_score'

finder = ScrabbleScore::WordFinder.new
p finder.search('foobar')

While the WordFinder uses the SOWPODS dictionary, it's possible to replace it with your own:

dictionary = ScrabbleScore::Dictionary.new(%w[apple pear banana])
ScrabbleScore::WordFinder.new(dictionary)

The dictionary can be searched directly:

dictionary = ScrabbleScore::Dictionary.new
dictionary.contains('vermilion') # returns true

In addition the letter permutation can be used independently from the other components:

letters = ScrabbleScore::Letters.new('xyz')
letters.permutations # returns ["xy", "xz", "yx", "yz", "zx", "zy", "xyz", "xzy", "yxz", "yzx", "zxy", "zyx"]

Note that this will only show permutations from two letters up to the size of the input string.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/scrabble_score/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request