spell 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ced55319ca8557405a6924cdb1b44d8f9b7cc1c
4
- data.tar.gz: 2d8e7811a225f6ef5ad3eb0f302b7ecfcbec53fd
3
+ metadata.gz: 3c75c56dd802edc8ce8503b0f2dea60fa7772c6a
4
+ data.tar.gz: a990eb804ea93c0a70286a6591e4216de557f6cb
5
5
  SHA512:
6
- metadata.gz: 7b0d2f24e3351687ab6db89414c41f726e7a73a3ee8d4379ac51b06db6a25ed33a081ca3754521fd3eb482ed74aa92e74672652fec91cccd3361b061f230ec0d
7
- data.tar.gz: ff69fb892e76be991b0452e073ac6d82829519db3a36b90d41aa09113d4050fe3fb686387ac68118d7da1f37283ef0863b9da865f00f84eb649d86a7cbaa2915
6
+ metadata.gz: 3066bc4978257194be0af3b667dbd8a53ab12f18d4ce8a8909723798b72e7291a4f2d8962fdcbac054605618899ed2cef5fce22d212fb2580fbfbcbb1a98adac
7
+ data.tar.gz: 2a12cdb8674385cbf0af9717b96f4dffad4d22cad22abb504a58f00eff42353e8b3c9c971988b5bcf8bdcb9375acd593aef74b2bfc95924e3ddbd5aa4d3be337
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format doc
data/README.md CHANGED
@@ -42,7 +42,7 @@ spell.best_match('alphabet') #=> "alpha"
42
42
 
43
43
  Or, if you'd rather specify a custom word weight, you can specify it like this:
44
44
  ```ruby
45
- word_list = { "alpha" => 8, "beta" => 2 }
45
+ word_list = { "alpha" => 2, "beta" => 20 }
46
46
  spell = Spell::Spell.new(word_list, 0.5)
47
47
  spell.best_match('alphabet') #=> "beta"
48
48
  ```
@@ -7,17 +7,13 @@ module Spell
7
7
  @word_list = args[0]
8
8
  @alpha = args[1] || 0.3
9
9
  elsif args[0].is_a? Array
10
+ fail "Word usage weights do not make sense with an Array" if args[1]
10
11
  @word_list = args[0]
11
12
  else
12
13
  fail "First argument must be an Array or Hash"
13
14
  end
14
15
  end
15
16
 
16
- # Return a value from 0.0-1.0 of how similar these two words are
17
- def compare(word1, word2)
18
- bigram_compare(bigramate(word1), bigramate(word2))
19
- end
20
-
21
17
  # Returns the closest matching word in the dictionary
22
18
  def best_match(given_word)
23
19
  words = (@word_list.is_a? Array) ? @word_list : @word_list.keys
@@ -33,6 +29,20 @@ module Spell
33
29
  word_hash.max_by { |key, value| value }.first
34
30
  end
35
31
 
32
+ # Returns a boolean for whether or not 'word' is in the dictionary
33
+ def spelled_correctly?(word)
34
+ if @word_list.is_a? Hash
35
+ @word_list.keys.include?(word)
36
+ else
37
+ @word_list.include?(word)
38
+ end
39
+ end
40
+
41
+ # Return a value from 0.0-1.0 of how similar these two words are
42
+ def compare(word1, word2)
43
+ bigram_compare(bigramate(word1), bigramate(word2))
44
+ end
45
+
36
46
  private
37
47
 
38
48
  # Returns the number of matching bigrams between the two sets of bigrams
@@ -86,15 +96,5 @@ module Spell
86
96
 
87
97
  weighted_array.to_h
88
98
  end
89
-
90
- # Returns a boolean for whether or not 'word' is in the dictionary
91
- def spelled_good?(word)
92
- @word_list.keys.include?(word)
93
- end
94
-
95
- # Increment count on each utterance
96
- def add_count(word)
97
- @word_list[word] += 1
98
- end
99
99
  end
100
100
  end
@@ -1,3 +1,3 @@
1
1
  module Spell
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_development_dependency "bundler", "~> 1.10"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
24
25
  end
metadata CHANGED
@@ -1,43 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Arnett
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-05 00:00:00.000000000 Z
11
+ date: 2015-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: 'Spell checker written in pure Ruby, implementing a simple bigram comparison
42
56
  algorithm. Spell has no external dependencies (including aspell or ispell). '
43
57
  email:
@@ -46,8 +60,9 @@ executables: []
46
60
  extensions: []
47
61
  extra_rdoc_files: []
48
62
  files:
49
- - .gitignore
50
- - .travis.yml
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".travis.yml"
51
66
  - CODE_OF_CONDUCT.md
52
67
  - Gemfile
53
68
  - LICENSE.txt
@@ -69,17 +84,17 @@ require_paths:
69
84
  - lib
70
85
  required_ruby_version: !ruby/object:Gem::Requirement
71
86
  requirements:
72
- - - '>='
87
+ - - ">="
73
88
  - !ruby/object:Gem::Version
74
89
  version: '0'
75
90
  required_rubygems_version: !ruby/object:Gem::Requirement
76
91
  requirements:
77
- - - '>='
92
+ - - ">="
78
93
  - !ruby/object:Gem::Version
79
94
  version: '0'
80
95
  requirements: []
81
96
  rubyforge_project:
82
- rubygems_version: 2.4.6
97
+ rubygems_version: 2.4.3
83
98
  signing_key:
84
99
  specification_version: 4
85
100
  summary: A customizable spell checker, written in pure Ruby