ffi-hunspell 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +8 -0
- data/README.md +29 -28
- data/gemspec.yml +1 -1
- data/lib/ffi/hunspell/dictionary.rb +24 -6
- data/lib/ffi/hunspell/hunspell.rb +3 -0
- data/spec/dictionary_spec.rb +14 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57957bc047538f1b983ecef0573c50b6989ac7bf
|
4
|
+
data.tar.gz: 173b95b98026f1988a4aeae6642afcf6135bfc67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aed5c80fb30d725cfdc62e10e150bb472b3f49c48552449fa31e3e904d52bc1818c16a96b730b47a731243dc04e85dd49de4d6077daa054dca534dcdd05abf64
|
7
|
+
data.tar.gz: 543846a757f85d057cc5c24bc2cda27a8a6676b7863b1ed5ae494249bd734fc32f66fdd8bc46e64b9cc162cb29dff49f2746bdc0c296327287f89a9b882220c1
|
data/ChangeLog.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
### 0.4.0 / 2017-04-21
|
2
|
+
|
3
|
+
* Added support for libhunspell-1.6.
|
4
|
+
* Added support for libhunspell-1.5 (@trench8891).
|
5
|
+
* Added support for libhunspell-1.4 (@willmoorefyi).
|
6
|
+
* Renamed `#add_affix` to {FFI::Hunspell::Dictionary#add_with_affix}
|
7
|
+
(@cdchapman).
|
8
|
+
|
1
9
|
### 0.3.1 / 2016-01-14
|
2
10
|
|
3
11
|
* Prefer loading hunspell-1.3 over hunspell-1.2, if both are installed.
|
data/README.md
CHANGED
@@ -14,48 +14,49 @@ Ruby FFI bindings for [Hunspell][libhunspell].
|
|
14
14
|
## Examples
|
15
15
|
|
16
16
|
Open a dictionary:
|
17
|
-
|
18
|
-
|
17
|
+
```rb
|
18
|
+
require 'ffi/hunspell'
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
FFI::Hunspell.dict do |dict|
|
21
|
+
# ...
|
22
|
+
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
FFI::Hunspell.dict('en_GB') do |dict|
|
25
|
+
# ...
|
26
|
+
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
dict = FFI::Hunspell.dict('en_GB')
|
29
|
+
# ...
|
30
|
+
dict.close
|
31
|
+
```
|
31
32
|
|
32
33
|
Check if a word is valid:
|
34
|
+
```rb
|
35
|
+
dict.check?('dog')
|
36
|
+
# => true
|
33
37
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
dict.check?('d0g')
|
38
|
-
# => false
|
39
|
-
|
38
|
+
dict.check?('d0g')
|
39
|
+
# => false
|
40
|
+
```
|
40
41
|
Find the stems of a word:
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
```rb
|
43
|
+
dict.stem('dogs')
|
44
|
+
# => ["dog"]
|
45
|
+
```
|
45
46
|
Suggest alternate spellings for a word:
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
```rb
|
48
|
+
dict.suggest('arbitrage')
|
49
|
+
# => ["arbitrage", "arbitrages", "arbitrager", "arbitraged", "arbitrate"]
|
50
|
+
```
|
50
51
|
## Requirements
|
51
52
|
|
52
53
|
* [libhunspell] >= 1.2.0
|
53
54
|
* [ffi] ~> 1.0
|
54
55
|
|
55
56
|
## Install
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
```sh
|
58
|
+
$ gem install ffi-hunspell
|
59
|
+
```
|
59
60
|
## License
|
60
61
|
|
61
62
|
Copyright (c) 2010-2016 Hal Brodigan
|
data/gemspec.yml
CHANGED
@@ -109,15 +109,33 @@ module FFI
|
|
109
109
|
#
|
110
110
|
# Adds a word to the dictionary.
|
111
111
|
#
|
112
|
-
# @param [
|
112
|
+
# @param [#to_s] word
|
113
113
|
# The word to add to the dictionary.
|
114
114
|
#
|
115
115
|
def add(word)
|
116
116
|
Hunspell.Hunspell_add(self,word.to_s)
|
117
117
|
end
|
118
118
|
|
119
|
+
#
|
120
|
+
# Adds a word to the dictionary with affix flags.
|
121
|
+
#
|
122
|
+
# @param [#to_s] word
|
123
|
+
# The word to add to the dictionary.
|
124
|
+
#
|
125
|
+
# @param [#to_s] example
|
126
|
+
# Affix flags.
|
127
|
+
#
|
128
|
+
# @since 0.4.0
|
129
|
+
#
|
130
|
+
def add_with_affix(word,example)
|
131
|
+
Hunspell.Hunspell_add_with_affix(self,word.to_s,example.to_s)
|
132
|
+
end
|
133
|
+
|
134
|
+
#
|
135
|
+
# @deprecated Please use {#add_with_affix} instead.
|
136
|
+
#
|
119
137
|
def add_affix(word,example)
|
120
|
-
|
138
|
+
add_with_affix(word,example)
|
121
139
|
end
|
122
140
|
|
123
141
|
alias << add
|
@@ -125,7 +143,7 @@ module FFI
|
|
125
143
|
#
|
126
144
|
# Removes a word from the dictionary.
|
127
145
|
#
|
128
|
-
# @param [
|
146
|
+
# @param [#to_s] word
|
129
147
|
# The word to remove.
|
130
148
|
#
|
131
149
|
def remove(word)
|
@@ -137,7 +155,7 @@ module FFI
|
|
137
155
|
#
|
138
156
|
# Checks if the word is validate.
|
139
157
|
#
|
140
|
-
# @param [
|
158
|
+
# @param [#to_s] word
|
141
159
|
# The word in question.
|
142
160
|
#
|
143
161
|
# @return [Boolean]
|
@@ -152,7 +170,7 @@ module FFI
|
|
152
170
|
#
|
153
171
|
# Finds the stems of a word.
|
154
172
|
#
|
155
|
-
# @param [
|
173
|
+
# @param [#to_s] word
|
156
174
|
# The word in question.
|
157
175
|
#
|
158
176
|
# @return [Array<String>]
|
@@ -176,7 +194,7 @@ module FFI
|
|
176
194
|
#
|
177
195
|
# Suggests alternate spellings of a word.
|
178
196
|
#
|
179
|
-
# @param [
|
197
|
+
# @param [#to_s] word
|
180
198
|
# The word in question.
|
181
199
|
#
|
182
200
|
# @return [Array<String>]
|
data/spec/dictionary_spec.rb
CHANGED
@@ -57,6 +57,20 @@ describe Hunspell::Dictionary do
|
|
57
57
|
expect(subject.valid?('dxg')).to be false
|
58
58
|
end
|
59
59
|
|
60
|
+
describe "#add" do
|
61
|
+
it "should add a word" do
|
62
|
+
expect(subject.add('cat')).to be 0
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#add_with_affix" do
|
67
|
+
it "should add a word with an example word" do
|
68
|
+
expect(subject.add_with_affix('cat', 'agree')).to be 0
|
69
|
+
expect(subject.valid?('disagreeable')).to be true
|
70
|
+
expect(subject.valid?('discatable')).to be true
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
60
74
|
describe "#stem" do
|
61
75
|
it "should find the stems of a word" do
|
62
76
|
expect(subject.stem('fishing')).to be == %w[fishing fish]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-hunspell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Postmodern
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
requirements:
|
114
114
|
- libhunspell >= 1.2.0
|
115
115
|
rubyforge_project:
|
116
|
-
rubygems_version: 2.
|
116
|
+
rubygems_version: 2.5.2
|
117
117
|
signing_key:
|
118
118
|
specification_version: 4
|
119
119
|
summary: FFI bindings for Hunspell
|