Skip Menu |

This queue is for tickets about the Text-Hunspell CPAN distribution.

Report information
The Basics
Id: 83765
Status: resolved
Worked: 1 hour (60 min)
Priority: 0/
Queue: Text-Hunspell

People
Owner: cosimo [...] cpan.org
Requestors: paul [...] frixxon.co.uk
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.05
Fixed in: (no value)



Subject: [PATCH] Please add support for add_dic()
The attached patch to Hunspell.xs works for me to add support for Hunspell's add_dic() method, which allows adding of supplemental dictionaries.
Subject: add-dic-patch.txt
diff -ruN Text-Hunspell-2.05/Hunspell.xs Text-Hunspell-2.05.new/Hunspell.xs --- Text-Hunspell-2.05/Hunspell.xs 2010-09-06 17:05:46.000000000 +0100 +++ Text-Hunspell-2.05.new/Hunspell.xs 2013-03-05 08:04:06.070719000 +0000 @@ -69,6 +69,15 @@ /* And return something to the caller too. */ RETVAL = 1; +int +Hunspell::add_dic(dic) + char *dic; + CODE: + handle = get_hunspell_handle(); + RETVAL = handle->add_dic(dic); + + OUTPUT: + RETVAL int Hunspell::check(buf)
Subject: Re: [rt.cpan.org #83765] [PATCH] Please add support for add_dic()
Date: Tue, 05 Mar 2013 10:40:45 +0100
To: bug-Text-Hunspell [...] rt.cpan.org
From: Cosimo Streppone <cosimo [...] streppone.it>
On 03/05/2013 10:23 AM, Paul Flo Williams via RT wrote: Show quoted text
> The attached patch to Hunspell.xs works for me to add support for > Hunspell's add_dic() method, which allows adding of supplemental > dictionaries.
Hi Paul, awesome, thanks! Would you mind adding a test case too? How is the new add_dic() function used? Thanks, -- Cosimo
From: paul [...] frixxon.co.uk
Show quoted text
> Would you mind adding a test case too? > How is the new add_dic() function used?
add_dic() lets you add a supplemental dictionary as well as your main language dictionary. It only takes the name of a '.dic' file because the main affix dictionary is used with it. I'm looking at adding a test case at the moment, but I'm not sure what the return value from add_dic() is supposed to be telling me! I'll update you later.
From: paul [...] frixxon.co.uk
Here is the test case and file. Oddly enough, add_dic() doesn't seem to fail, even if the dictionary file doesn't exist. Looking at Hunspell's source, I think it doesn't actually fail, but it creates a supplemental dictionary with no words.
Subject: 07-supp.t
use strict; use warnings; use Data::Dumper; use Test::More tests => 5; use Text::Hunspell; my $speller = Text::Hunspell->new(qw(./t/test.aff ./t/test.dic)); die unless $speller; ok($speller, qq(Created a Text::Hunspell object [$speller])); my $word = q(munkey); ok( !$speller->check($word), qq(Word '$word' shouldn't be in the test dictionary) ); ok( !$speller->add_dic(q(./t/supp.dic)), q(Added a supplemental dictionary) ); ok( $speller->check($word), qq(Word '$word' is in the supplemental dictionary) ); # Curtains down ok($speller->delete($speller), q(delete method presumably worked));
Subject: supp.dic
Download supp.dic
application/octet-stream 9b

Message body not shown because it is not plain text.

Just pushed 2.06 to CPAN. Thanks much for the patch and tests!