hunspell 0.1.2 → 0.1.4
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 +4 -4
- data/README.md +83 -0
- data/extconf.rb +26 -5
- data/hunspell.c +24 -2
- data/test/test_hunspell.rb +25 -0
- metadata +11 -9
- data/README +0 -99
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d322658793cc7c2808595f0dc0a2d8100ab54e6
|
4
|
+
data.tar.gz: 33a9631865e9e08398d3dc5d0c1aaae67a6e7913
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59efb47ef479d151348782d699415a970ba5dac92a72aaa91e07f3598eeb13068a4bf539d4b337d05cc410c2ed699f1dcda7573ccbe368db874bbb334897b427
|
7
|
+
data.tar.gz: 45b030ae8528f0933c0db4b2927092c5bbbc28274b3742fb79ff8d5a970090fe65b1c03d0db79638057507c0ca3c4e3a9cd4c3c46b17f9c8abdc471ffae5ad20
|
data/README.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# Hunspell
|
2
|
+
|
3
|
+
Ruby interface to hunspell spell checker
|
4
|
+
Copyright 2007, Gabor SEBESTYEN
|
5
|
+
|
6
|
+
## WHAT IS THIS?
|
7
|
+
|
8
|
+
Hunspell is an simple native Ruby interface to the famous [Hunspell](http://hunspell.sourceforge.net/) spell checker library which is part of [OpenOffice](http://openoffice.org/) and Mozilla products. With this bundle you can start to develop your own AJAX based spell checker service for Ruby on Rails.
|
9
|
+
|
10
|
+
## REQUIREMENTS
|
11
|
+
|
12
|
+
Before installing Hunspell ensure you have the following components already installed:
|
13
|
+
|
14
|
+
- Ruby >= 1.8
|
15
|
+
- rubygems
|
16
|
+
- hunspell native library >= 1.3 (libhunspell-1.3)
|
17
|
+
- dictionary files: download from [LibreOffice](http://cgit.freedesktop.org/libreoffice/dictionaries/tree/) or [OpenOffice](http://wiki.services.openoffice.org/wiki/Dictionaries) websites.
|
18
|
+
|
19
|
+
## INSTALLATION
|
20
|
+
|
21
|
+
The best way to get Hunspell is to use gem package manager
|
22
|
+
|
23
|
+
gem install hunspell
|
24
|
+
|
25
|
+
NOTE: if install fails on newer OSX versions, try this command
|
26
|
+
|
27
|
+
sudo ARCHFLAGS="-arch x86_64" gem install hunspell
|
28
|
+
|
29
|
+
If you want to build Hunspell from scratch grab the source from [here](https://github.com/segabor/Hunspell) and execute the
|
30
|
+
following command
|
31
|
+
|
32
|
+
ruby extconf.rb && make
|
33
|
+
|
34
|
+
|
35
|
+
FreeBSD gotcha: hunspell spell checker package does not deploy its header
|
36
|
+
files. Run gem or ruby command with an extra option:
|
37
|
+
|
38
|
+
gem install hunspell -- --with-include-dir=<incdir>
|
39
|
+
|
40
|
+
or
|
41
|
+
|
42
|
+
ruby extconf.rb --with-include-dir=<incdir> && make
|
43
|
+
|
44
|
+
Replace _incdir_ with the path pointing to hunspell includes.
|
45
|
+
|
46
|
+
## FIRST STEPS
|
47
|
+
|
48
|
+
Here's a basic example how to use Hunspell. Cut it and run in ruby.
|
49
|
+
|
50
|
+
### example.rb
|
51
|
+
|
52
|
+
```
|
53
|
+
require "rubygems" # import gem package manager
|
54
|
+
gem "hunspell" # load Hunspell module
|
55
|
+
require "Hunspell" # inject Hunspell class to Ruby namespace
|
56
|
+
|
57
|
+
# instantiate Hunspell with Hungarian affix and dictionary files
|
58
|
+
#
|
59
|
+
|
60
|
+
sp = Hunspell.new("hu.aff", "hu.dic")
|
61
|
+
|
62
|
+
# spell check Hungarian word 'ablak' (window) => true
|
63
|
+
#
|
64
|
+
puts "Is 'ablak' correct? #{sp.spellcheck('ablak')}"
|
65
|
+
|
66
|
+
# get suggestions for mispelled word 'paprika'
|
67
|
+
# => ["kaprica", "patrica", "paprika", "papcica",
|
68
|
+
# "papráca", "papruca", "paprima", "paprikáz",
|
69
|
+
# "paprikása", "paprikás", "Papradnó"
|
70
|
+
# ]
|
71
|
+
#
|
72
|
+
puts "Suggestions for 'paprica': " + sp.suggest("paprica").inspect
|
73
|
+
```
|
74
|
+
|
75
|
+
**Note** you might run this example with -Ke ruby option if you want to see accented letters instead of backslash prefixed utf codes.
|
76
|
+
|
77
|
+
## FEEDBACK
|
78
|
+
|
79
|
+
Any help or report are warmly appreciated. Please visit the project's homepage at https://github.com/segabor/Hunspell and open an issue.
|
80
|
+
|
81
|
+
## DISCLAIMER
|
82
|
+
|
83
|
+
This software is at an early stage. Use at own your risk! No warranty.
|
data/extconf.rb
CHANGED
@@ -1,10 +1,31 @@
|
|
1
1
|
require 'mkmf'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
LIBDIR = RbConfig::CONFIG['libdir']
|
4
|
+
INCLUDEDIR = RbConfig::CONFIG['includedir']
|
5
5
|
|
6
|
-
|
6
|
+
HEADER_DIRS = [
|
7
|
+
'/usr/local/include',
|
7
8
|
|
8
|
-
|
9
|
+
INCLUDEDIR,
|
10
|
+
|
11
|
+
'/usr/include'
|
12
|
+
]
|
13
|
+
|
14
|
+
LIB_DIRS = [
|
15
|
+
'/usr/local/lib',
|
16
|
+
|
17
|
+
LIBDIR,
|
18
|
+
|
19
|
+
'/usr/lib'
|
20
|
+
]
|
21
|
+
|
22
|
+
|
23
|
+
dir_config('hunspell-1.3', HEADER_DIRS, LIB_DIRS)
|
24
|
+
|
25
|
+
if have_library('hunspell-1.3', 'Hunspell_create', ['hunspell/hunspell.h'])
|
26
|
+
then
|
27
|
+
create_makefile('Hunspell')
|
28
|
+
else
|
29
|
+
puts('Missing hunspell library')
|
30
|
+
end
|
9
31
|
|
10
|
-
create_makefile("Hunspell")
|
data/hunspell.c
CHANGED
@@ -25,6 +25,26 @@
|
|
25
25
|
#include "ruby.h"
|
26
26
|
#include "hunspell/hunspell.h"
|
27
27
|
|
28
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
29
|
+
|
30
|
+
#include <ruby/encoding.h>
|
31
|
+
|
32
|
+
#define ENCODED_STR_NEW2(str, encoding) \
|
33
|
+
({ \
|
34
|
+
VALUE _string = rb_str_new2((const char *)str); \
|
35
|
+
int _enc = rb_enc_find_index(encoding); \
|
36
|
+
if (_enc != -1) { \
|
37
|
+
rb_enc_associate_index(_string, _enc); \
|
38
|
+
} \
|
39
|
+
_string; \
|
40
|
+
})
|
41
|
+
|
42
|
+
#else
|
43
|
+
|
44
|
+
#define ENCODED_STR_NEW2(str, encoding) \
|
45
|
+
rb_str_new2((const char *)str)
|
46
|
+
|
47
|
+
#endif
|
28
48
|
|
29
49
|
|
30
50
|
/*
|
@@ -116,11 +136,13 @@ static VALUE mHunspellSuggest(VALUE self, VALUE str) {
|
|
116
136
|
|
117
137
|
n = Hunspell_suggest(*ptr, &lst, (const char *)StringValueCStr(str));
|
118
138
|
if (n > 0) {
|
139
|
+
const char *enc = Hunspell_get_dic_encoding(*ptr);
|
140
|
+
|
119
141
|
// allocate enough space in new array
|
120
142
|
ret = rb_ary_new2(n);
|
121
143
|
for (i=0; i<n; i++) {
|
122
144
|
// add string to list
|
123
|
-
VALUE rb_str =
|
145
|
+
VALUE rb_str = ENCODED_STR_NEW2(lst[i], enc);
|
124
146
|
rb_ary_push(ret, rb_str);
|
125
147
|
}
|
126
148
|
} else {
|
@@ -153,7 +175,7 @@ static VALUE mHunspellEncoding(VALUE self) {
|
|
153
175
|
#ifdef DEBUG
|
154
176
|
printf("DEBUG: mHunspellEncoding: %s\n", enc);
|
155
177
|
#endif
|
156
|
-
return
|
178
|
+
return ENCODED_STR_NEW2(enc, "UTF-8");
|
157
179
|
}
|
158
180
|
|
159
181
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require "Hunspell"
|
3
|
+
|
4
|
+
class HunspellTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@sp = Hunspell.new("test/dict/hu_HU.aff", "test/dict/hu_HU.dic")
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_spellcheck
|
10
|
+
assert @sp.spellcheck('ablak')
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_false_spellcheck
|
14
|
+
assert !@sp.spellcheck("paprica")
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_suggestions
|
18
|
+
assert !@sp.spellcheck('paprica')
|
19
|
+
|
20
|
+
suggestions = @sp.suggest("paprica")
|
21
|
+
assert !suggestions.include?('paprica')
|
22
|
+
assert suggestions.include?('paprika')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hunspell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gábor SEBESTYÉN
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
Hunspell is an easy native Ruby interface to the famous Hunspell spell checker
|
@@ -21,13 +21,14 @@ extensions:
|
|
21
21
|
- extconf.rb
|
22
22
|
extra_rdoc_files: []
|
23
23
|
files:
|
24
|
+
- LGPL_LICENSE
|
25
|
+
- README.md
|
26
|
+
- TODO
|
27
|
+
- example.rb
|
24
28
|
- extconf.rb
|
25
29
|
- hunspell.c
|
26
30
|
- hunspell.rb
|
27
|
-
-
|
28
|
-
- README
|
29
|
-
- example.rb
|
30
|
-
- LGPL_LICENSE
|
31
|
+
- test/test_hunspell.rb
|
31
32
|
homepage: https://github.com/segabor/Hunspell
|
32
33
|
licenses: []
|
33
34
|
metadata: {}
|
@@ -47,10 +48,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
48
|
- !ruby/object:Gem::Version
|
48
49
|
version: '0'
|
49
50
|
requirements:
|
50
|
-
- hunspell 1.
|
51
|
+
- hunspell 1.3 or newer
|
51
52
|
rubyforge_project:
|
52
|
-
rubygems_version: 2.
|
53
|
+
rubygems_version: 2.4.8
|
53
54
|
signing_key:
|
54
55
|
specification_version: 4
|
55
56
|
summary: Ruby interface to hunspell spell checker
|
56
|
-
test_files:
|
57
|
+
test_files:
|
58
|
+
- test/test_hunspell.rb
|
data/README
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
Hunspell
|
2
|
-
Ruby interface to hunspell spell checker
|
3
|
-
|
4
|
-
Copyright 2007, Gabor SEBESTYEN
|
5
|
-
|
6
|
-
|
7
|
-
WHAT IS THIS?
|
8
|
-
-------------
|
9
|
-
|
10
|
-
Hunspell is an easy native Ruby interface to the famous Hunspell spell checker
|
11
|
-
library which is part of OpenOffice and Mozilla products. With this bundle
|
12
|
-
you can start to develop your own AJAX based spell checker service for
|
13
|
-
Ruby on Rails.
|
14
|
-
|
15
|
-
|
16
|
-
REQUIREMENTS
|
17
|
-
------------
|
18
|
-
|
19
|
-
Before install Hunspell be sure to have the following components:
|
20
|
-
|
21
|
-
- Ruby >= 1.8
|
22
|
-
- rubygems
|
23
|
-
- hunspell >= 1.2.x (libhunspell-1.2)
|
24
|
-
http://hunspell.sourceforge.net
|
25
|
-
- dictionary files for Hunspell
|
26
|
-
http://wiki.services.openoffice.org/wiki/Dictionaries
|
27
|
-
|
28
|
-
|
29
|
-
INSTALLATION
|
30
|
-
------------
|
31
|
-
|
32
|
-
The best way is to use gem package manager.
|
33
|
-
|
34
|
-
gem install hunspell
|
35
|
-
|
36
|
-
If you want to build Hunspell from scratch grab the source and issue the
|
37
|
-
following commands:
|
38
|
-
|
39
|
-
ruby extconf.rb && make
|
40
|
-
|
41
|
-
|
42
|
-
FreeBSD gotcha: hunspell spell checker package does not deploy its header
|
43
|
-
files. Run gem or ruby command with an extra option:
|
44
|
-
|
45
|
-
gem install hunspell -- --with-include-dir=...
|
46
|
-
|
47
|
-
or
|
48
|
-
|
49
|
-
ruby extconf.rb --with-include-dir=... && make
|
50
|
-
|
51
|
-
Replace ... to the path pointing to hunspell includes.
|
52
|
-
|
53
|
-
|
54
|
-
FIRST STEPS
|
55
|
-
-----------
|
56
|
-
|
57
|
-
Here's a very simple example how to use Hunspell. Cut it and run in ruby.
|
58
|
-
|
59
|
-
|
60
|
-
=== example.rb ===
|
61
|
-
|
62
|
-
require "rubygems" # import gem package manager
|
63
|
-
gem "hunspell" # load Hunspell module
|
64
|
-
require "Hunspell" # inject Hunspell class to Ruby namespace
|
65
|
-
|
66
|
-
# instantiate Hunspell with Hungarian affix and dictionary files
|
67
|
-
#
|
68
|
-
sp = Hunspell.new("hu.aff", "hu.dic")
|
69
|
-
|
70
|
-
# spell check Hungarian word 'ablak' (window) => true
|
71
|
-
#
|
72
|
-
puts "Is 'ablak' correct? #{sp.spellcheck('ablak')}"
|
73
|
-
|
74
|
-
# get suggestions for mispelled word 'paprika'
|
75
|
-
# => ["kaprica", "patrica", "paprika", "papcica",
|
76
|
-
# "papráca", "papruca", "paprima", "paprikáz",
|
77
|
-
# "paprikása", "paprikás", "Papradnó"
|
78
|
-
# ]
|
79
|
-
#
|
80
|
-
puts "Suggestions for 'paprica': " + sp.suggest("paprica").inspect
|
81
|
-
|
82
|
-
=== end of example ===
|
83
|
-
|
84
|
-
Note: you might run this example with -Ke ruby option if you want to
|
85
|
-
see accented letters instead of backslash prefixed utf codes.
|
86
|
-
|
87
|
-
|
88
|
-
FEEDBACK
|
89
|
-
--------
|
90
|
-
|
91
|
-
Any help or report warmly appreciated. Please visit the project's homepage at
|
92
|
-
https://github.com/segabor/Hunspell or write me to segabor@gmail.com
|
93
|
-
|
94
|
-
|
95
|
-
DISCLAIMER
|
96
|
-
----------
|
97
|
-
|
98
|
-
This software is at an early stage. Use at own your risk!
|
99
|
-
No warranty.
|