scrabble_score 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +67 -0
- data/assets/dictionary.txt +267751 -0
- data/lib/scrabble_score/dictionary.rb +29 -0
- data/lib/scrabble_score/letters.rb +39 -0
- data/lib/scrabble_score/version.rb +3 -0
- data/lib/scrabble_score/word_finder.rb +23 -0
- data/lib/scrabble_score.rb +8 -0
- data/scrabble_score.gemspec +24 -0
- data/spec/assets/dictionary.txt +8 -0
- data/spec/lib/scrabble_score/dictionary_spec.rb +130 -0
- data/spec/lib/scrabble_score/letters_spec.rb +56 -0
- data/spec/lib/scrabble_score/word_finder_spec.rb +36 -0
- data/spec/spec_helper.rb +5 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e50682c71668ab9bfd50b6385b6aa79acbe8ab3d
|
4
|
+
data.tar.gz: 7d56df83c91e4d0f4244f789eeb385404c921c40
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0cff454cf66d6b5143319526257e16ae613fa0ae161502d22c947f784f85d42a07535e12cd049af832a2f65df545f562a575292a451042639a9b3b766321ab9e
|
7
|
+
data.tar.gz: 72ca303fd12ea911f60d44fb546cf80f8f6ed680bdb2e94cb8b195a4e9d9394435923e8b68c265112e9f922bc7d65f0baa7a8db0e86d1cd44dfb8b8959e4d6b9
|
data/.gitignore
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.idea/
|
24
|
+
coverage/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Nick Aschenbach
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# ScrabbleScore
|
2
|
+
|
3
|
+
A simple Scrabble cheating library that estimates word score. Given a set of letters, one can search for all
|
4
|
+
permutation against the SOWPODS dictionary. For example:
|
5
|
+
|
6
|
+
```
|
7
|
+
ScrabbleScore::WordFinder.new.search_with_score('uiqza')
|
8
|
+
```
|
9
|
+
|
10
|
+
Which returns:
|
11
|
+
|
12
|
+
```
|
13
|
+
{"qi"=>11, "za"=>11, "ai"=>2, "qua"=>12, "quiz"=>22, "quai"=>13}
|
14
|
+
```
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Add this line to your application's Gemfile:
|
19
|
+
|
20
|
+
gem 'scrabble_score'
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
$ gem install scrabble_score
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
One can search for words in the dictionary without score via:
|
33
|
+
|
34
|
+
```
|
35
|
+
ScrabbleScore::WordFinder.new.search('foobar')
|
36
|
+
```
|
37
|
+
|
38
|
+
While the WordFinder uses the SOWPODS dictionary, it's possible to replace it with your own:
|
39
|
+
|
40
|
+
```
|
41
|
+
dictionary = ScrabbleScore::Dictionary.new(%w[apple pear banana])
|
42
|
+
ScrabbleScore::WordFinder.new(dictionary)
|
43
|
+
```
|
44
|
+
|
45
|
+
The dictionary can be searched directly:
|
46
|
+
|
47
|
+
```
|
48
|
+
dictionary = ScrabbleScore::Dictionary.new
|
49
|
+
dictionary.contains('vermilion') # returns true
|
50
|
+
```
|
51
|
+
|
52
|
+
In addition the letter permutation can be used independently from the other components:
|
53
|
+
|
54
|
+
```
|
55
|
+
letters = ScrabbleScore::Letters.new('xyz')
|
56
|
+
letters.permutations # returns ["xy", "xz", "yx", "yz", "zx", "zy", "xyz", "xzy", "yxz", "yzx", "zxy", "zyx"]
|
57
|
+
```
|
58
|
+
|
59
|
+
Note that this will only show permutations from two letters up to the size of the input string.
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
1. Fork it ( https://github.com/[my-github-username]/scrabble_score/fork )
|
64
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
65
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
66
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
67
|
+
5. Create a new Pull Request
|