dmarkow-raspell 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/ext/raspell.c +23 -23
- metadata +17 -6
data/CHANGELOG
CHANGED
data/ext/raspell.c
CHANGED
@@ -106,7 +106,7 @@ static void set_options(AspellConfig *config, VALUE hash) {
|
|
106
106
|
VALUE value = rb_funcall(hash, rb_intern("fetch"), 1, option);
|
107
107
|
if (TYPE(option)!=T_STRING) rb_raise(cAspellError, "Given key must be a string.");
|
108
108
|
if (TYPE(value )!=T_STRING) rb_raise(cAspellError, "Given value must be a string.");
|
109
|
-
set_option(config,
|
109
|
+
set_option(config, StringValuePtr(option), StringValuePtr(value));
|
110
110
|
c++;
|
111
111
|
}
|
112
112
|
}
|
@@ -161,7 +161,7 @@ static VALUE get_list(const AspellWordList *list) {
|
|
161
161
|
* @return regular expression, matching exactly the word as whole.
|
162
162
|
*/
|
163
163
|
static VALUE get_wordregexp(VALUE word) {
|
164
|
-
char *cword =
|
164
|
+
char *cword = StringValuePtr(word);
|
165
165
|
char *result = malloc((strlen(cword)+5)*sizeof(char));
|
166
166
|
*result='\0';
|
167
167
|
strcat(result, "\\b");
|
@@ -200,13 +200,13 @@ static VALUE aspell_s_new(int argc, VALUE *argv, VALUE klass) {
|
|
200
200
|
rb_scan_args(argc, argv, "04", &vlang, &vjargon, &vsize, &vencoding);
|
201
201
|
|
202
202
|
//language:
|
203
|
-
if (RTEST(vlang)) set_option(config, "lang",
|
203
|
+
if (RTEST(vlang)) set_option(config, "lang", StringValuePtr(vlang));
|
204
204
|
//jargon:
|
205
|
-
if (RTEST(vjargon)) set_option(config, "jargon",
|
205
|
+
if (RTEST(vjargon)) set_option(config, "jargon", StringValuePtr(vjargon));
|
206
206
|
//size:
|
207
|
-
if (RTEST(vsize)) set_option(config, "size",
|
207
|
+
if (RTEST(vsize)) set_option(config, "size", StringValuePtr(vsize));
|
208
208
|
//encoding:
|
209
|
-
if (RTEST(vencoding)) set_option(config, "encoding",
|
209
|
+
if (RTEST(vencoding)) set_option(config, "encoding", StringValuePtr(vencoding));
|
210
210
|
|
211
211
|
//create speller:
|
212
212
|
ret = new_aspell_speller(config);
|
@@ -293,7 +293,7 @@ static VALUE aspell_s_list_dicts(VALUE klass) {
|
|
293
293
|
*/
|
294
294
|
static VALUE aspell_set_option(VALUE self, VALUE option, VALUE value) {
|
295
295
|
AspellSpeller *speller = get_speller(self);
|
296
|
-
set_option(aspell_speller_config(speller),
|
296
|
+
set_option(aspell_speller_config(speller), StringValuePtr(option), StringValuePtr(value));
|
297
297
|
return self;
|
298
298
|
}
|
299
299
|
|
@@ -304,7 +304,7 @@ static VALUE aspell_set_option(VALUE self, VALUE option, VALUE value) {
|
|
304
304
|
*/
|
305
305
|
static VALUE aspell_remove_option(VALUE self, VALUE option) {
|
306
306
|
AspellSpeller *speller = get_speller(self);
|
307
|
-
aspell_config_remove(aspell_speller_config(speller),
|
307
|
+
aspell_config_remove(aspell_speller_config(speller), StringValuePtr(option));
|
308
308
|
return self;
|
309
309
|
}
|
310
310
|
|
@@ -314,7 +314,7 @@ static VALUE aspell_remove_option(VALUE self, VALUE option) {
|
|
314
314
|
*/
|
315
315
|
static VALUE aspell_set_suggestion_mode(VALUE self, VALUE value) {
|
316
316
|
AspellSpeller *speller = get_speller(self);
|
317
|
-
set_option(aspell_speller_config(speller), "sug-mode",
|
317
|
+
set_option(aspell_speller_config(speller), "sug-mode", StringValuePtr(value));
|
318
318
|
return self;
|
319
319
|
}
|
320
320
|
|
@@ -372,7 +372,7 @@ static VALUE aspell_clear_session(VALUE self) {
|
|
372
372
|
*/
|
373
373
|
static VALUE aspell_suggest(VALUE self, VALUE word) {
|
374
374
|
AspellSpeller *speller = get_speller(self);
|
375
|
-
return get_list(aspell_speller_suggest(speller,
|
375
|
+
return get_list(aspell_speller_suggest(speller, StringValuePtr(word), -1));
|
376
376
|
}
|
377
377
|
|
378
378
|
/**
|
@@ -382,7 +382,7 @@ static VALUE aspell_suggest(VALUE self, VALUE word) {
|
|
382
382
|
*/
|
383
383
|
static VALUE aspell_add_to_personal(VALUE self, VALUE word) {
|
384
384
|
AspellSpeller *speller = get_speller(self);
|
385
|
-
aspell_speller_add_to_personal(speller,
|
385
|
+
aspell_speller_add_to_personal(speller, StringValuePtr(word), -1);
|
386
386
|
check_for_error(speller);
|
387
387
|
return self;
|
388
388
|
}
|
@@ -393,7 +393,7 @@ static VALUE aspell_add_to_personal(VALUE self, VALUE word) {
|
|
393
393
|
*/
|
394
394
|
static VALUE aspell_add_to_session(VALUE self, VALUE word) {
|
395
395
|
AspellSpeller *speller = get_speller(self);
|
396
|
-
aspell_speller_add_to_session(speller,
|
396
|
+
aspell_speller_add_to_session(speller, StringValuePtr(word), -1);
|
397
397
|
check_for_error(speller);
|
398
398
|
return self;
|
399
399
|
}
|
@@ -407,7 +407,7 @@ static VALUE aspell_add_to_session(VALUE self, VALUE word) {
|
|
407
407
|
static VALUE aspell_conf_retrieve(VALUE self, VALUE key) {
|
408
408
|
AspellSpeller *speller = get_speller(self);
|
409
409
|
AspellConfig *config = aspell_speller_config(speller);
|
410
|
-
VALUE result = rb_str_new2(aspell_config_retrieve(config,
|
410
|
+
VALUE result = rb_str_new2(aspell_config_retrieve(config, StringValuePtr(key)));
|
411
411
|
if (aspell_config_error(config) != 0) {
|
412
412
|
rb_raise(cAspellError, aspell_config_error_message(config));
|
413
413
|
}
|
@@ -428,7 +428,7 @@ static VALUE aspell_conf_retrieve_list(VALUE self, VALUE key) {
|
|
428
428
|
const char *option_value;
|
429
429
|
|
430
430
|
//retrieve list
|
431
|
-
aspell_config_retrieve_list(config,
|
431
|
+
aspell_config_retrieve_list(config, StringValuePtr(key), container);
|
432
432
|
//check for error
|
433
433
|
if (aspell_config_error(config) != 0) {
|
434
434
|
char *tmp = strdup(aspell_config_error_message(config));
|
@@ -474,7 +474,7 @@ static VALUE aspell_dump_config(VALUE self) {
|
|
474
474
|
static VALUE aspell_check(VALUE self, VALUE word) {
|
475
475
|
AspellSpeller *speller = get_speller(self);
|
476
476
|
VALUE result = Qfalse;
|
477
|
-
int code = aspell_speller_check(speller,
|
477
|
+
int code = aspell_speller_check(speller, StringValuePtr(word), -1);
|
478
478
|
if (code == 1)
|
479
479
|
result = Qtrue;
|
480
480
|
else if (code == 0)
|
@@ -524,7 +524,7 @@ static VALUE aspell_correct_lines(VALUE self, VALUE ary) {
|
|
524
524
|
//save line
|
525
525
|
sline = rb_funcall(vline, rb_intern("dup"), 0);
|
526
526
|
//c representation
|
527
|
-
line =
|
527
|
+
line = StringValuePtr(vline);
|
528
528
|
//process line
|
529
529
|
aspell_document_checker_process(checker, line, -1);
|
530
530
|
//iterate over all misspelled words
|
@@ -540,14 +540,14 @@ static VALUE aspell_correct_lines(VALUE self, VALUE ary) {
|
|
540
540
|
//chomp the string
|
541
541
|
rb_funcall(rword, rb_intern("chomp!"), 0);
|
542
542
|
//empty string -> do nothing
|
543
|
-
if(strlen(
|
543
|
+
if(strlen(StringValuePtr(rword)) == 0) continue;
|
544
544
|
//remember word for later suggestion
|
545
|
-
aspell_speller_store_replacement(speller,
|
545
|
+
aspell_speller_store_replacement(speller, StringValuePtr(word), -1, StringValuePtr(rword), -1);
|
546
546
|
//substitute the word by replacement
|
547
547
|
rb_funcall(sline, rb_intern("[]="), 3, INT2FIX(token.offset+offset), INT2FIX(token.len), rword);
|
548
548
|
//adjust offset
|
549
|
-
offset += strlen(
|
550
|
-
//printf("replace >%s< with >%s< (offset now %d)\n",
|
549
|
+
offset += strlen(StringValuePtr(rword))-strlen(StringValuePtr(word));
|
550
|
+
//printf("replace >%s< with >%s< (offset now %d)\n", StringValuePtr(word), StringValuePtr(rword), offset);
|
551
551
|
}
|
552
552
|
//push the substituted line to result
|
553
553
|
rb_ary_push(result, sline);
|
@@ -570,7 +570,7 @@ static VALUE aspell_correct_lines(VALUE self, VALUE ary) {
|
|
570
570
|
*/
|
571
571
|
static VALUE aspell_store_replacement(VALUE self, VALUE badword, VALUE rightword) {
|
572
572
|
AspellSpeller *speller = get_speller(self);
|
573
|
-
aspell_speller_store_replacement(speller,
|
573
|
+
aspell_speller_store_replacement(speller, StringValuePtr(badword), -1, StringValuePtr(rightword), -1);
|
574
574
|
return self;
|
575
575
|
}
|
576
576
|
|
@@ -585,7 +585,7 @@ static VALUE aspell_correct_file(VALUE self, VALUE filename) {
|
|
585
585
|
if (rb_block_given_p()) {
|
586
586
|
VALUE content = rb_funcall(rb_cFile, rb_intern("readlines"), 1, filename);
|
587
587
|
VALUE newcontent = aspell_correct_lines(self, content);
|
588
|
-
VALUE file = rb_file_open(
|
588
|
+
VALUE file = rb_file_open(StringValuePtr(filename), "w+");
|
589
589
|
rb_funcall(file, rb_intern("write"), 1, newcontent);
|
590
590
|
rb_funcall(file, rb_intern("close"), 0);
|
591
591
|
} else {
|
@@ -613,7 +613,7 @@ static VALUE aspell_list_misspelled(VALUE self, VALUE ary) {
|
|
613
613
|
while(c<count) {
|
614
614
|
//process line
|
615
615
|
vline = RARRAY_PTR(ary)[c];
|
616
|
-
aspell_document_checker_process(checker,
|
616
|
+
aspell_document_checker_process(checker, StringValuePtr(vline), -1);
|
617
617
|
//iterate over all misspelled words
|
618
618
|
while (token = aspell_document_checker_next_misspelling(checker), token.len != 0) {
|
619
619
|
//extract word by start/length qualifier
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dmarkow-raspell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 2
|
8
|
+
- 2
|
9
|
+
version: 1.2.2
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Evan Weaver
|
@@ -10,11 +15,11 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date:
|
18
|
+
date: 2010-06-16 00:00:00 -07:00
|
14
19
|
default_executable:
|
15
20
|
dependencies: []
|
16
21
|
|
17
|
-
description: Update of Evan Weaver's raspell gem to support Ruby 1.9.
|
22
|
+
description: Update of Evan Weaver's raspell gem to support Ruby 1.9.2
|
18
23
|
email: dylan@dylanmarkow.com
|
19
24
|
executables: []
|
20
25
|
|
@@ -34,6 +39,8 @@ files:
|
|
34
39
|
- ext/raspell.c
|
35
40
|
has_rdoc: true
|
36
41
|
homepage: http://github.com/dmarkow/raspell
|
42
|
+
licenses: []
|
43
|
+
|
37
44
|
post_install_message:
|
38
45
|
rdoc_options:
|
39
46
|
- --charset=UTF-8
|
@@ -41,21 +48,25 @@ require_paths:
|
|
41
48
|
- lib
|
42
49
|
- ext
|
43
50
|
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
44
52
|
requirements:
|
45
53
|
- - ">="
|
46
54
|
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 0
|
47
57
|
version: "0"
|
48
|
-
version:
|
49
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
50
60
|
requirements:
|
51
61
|
- - ">="
|
52
62
|
- !ruby/object:Gem::Version
|
63
|
+
segments:
|
64
|
+
- 0
|
53
65
|
version: "0"
|
54
|
-
version:
|
55
66
|
requirements: []
|
56
67
|
|
57
68
|
rubyforge_project:
|
58
|
-
rubygems_version: 1.
|
69
|
+
rubygems_version: 1.3.7
|
59
70
|
signing_key:
|
60
71
|
specification_version: 2
|
61
72
|
summary: An interface binding for the Aspell spelling checker.
|