Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

adding to an ispell dictionary

by CodeJunkie (Monk)
on Apr 15, 2003 at 13:50 UTC ( #250568=perlquestion: print w/replies, xml ) Need Help??

CodeJunkie has asked for the wisdom of the Perl Monks concerning the following question:

Sorry to have to ask what may be a stupid question but I was hoping someone might be able to help me work out why I can't add something to my ispell dictionary using Lingua::Ispell add_word(word) or add_word_lc(word)? I've read through all the documentation I can find for both ispell and Lingua::Ispell but still it does not add the value to the dictionary as the function suggests it should...

Could this be a file permissions problem maybe? I am running this common via a web browser interface, and I have installed ispell as root... could this be the 'root' of the problem?

It also doesn't help that I can't get it to complain if it doesn't work. I.e. add_word($word) or die "Failed to add to dictionary: $!"; does not die, but still does not add to dictionary as far as I can tell!

Thoughts and ideas very welcome.


Replies are listed 'Best First'.
Re: adding to an ispell dictionary
by tall_man (Parson) on Apr 15, 2003 at 14:38 UTC
    The following (adapted from the man page) works for me from the command line:
    use strict; use Lingua::Ispell qw( :all ); # import all symbols add_word_lc("shrdlu"); for my $r ( spellcheck( "hello hacking perl shrdlu 42" ) ) { print "$r->{'type'}: $r->{'term'}\n"; }
    When I go to my home directory, I find that "shrdlu" has been added to the file .ispell_english.

    I think what you will need is to specify a use_personal_dictionary, giving a file that can be written from your web browser interface, before attempting to add words.

      And if what tall_man wrote is the only (or best) fix for you, here's a link that explains the use_dictionary, and use_personal_dictionary function.

      Ok yeah that sounds possible, i've tried running the script you have above but it doesn't add to my personal dictionary.

      The code I have is a follows

      #!/usr/bin/perl -w use strict; use Lingua::Ispell qw( :all ); # import all symbols use_personal_dictionary('.ispell_english'); add_word_lc("shrdlu"); save_dictionary(); for my $r ( spellcheck( "hello hacking perl shrdlu 42" ) ) { print "$r->{'type'}: $r->{'term'}\n"; }

      Unfortunately this does not add to the empty .ispell_english file in my home directory. Even with permissions set to chmod 666 and user: nobody, group: other (i.e. same as web server)

      Do I need to set a personal_dictionary variable in my ispell local.h file and re- 'make' the ispell installation?

      I hate this sys-admin stuff :-( Appreciate the help though thanks!

        What about using an absolute path to the personal dictionary? The user the web browser runs scripts with isn't you (it might be "apache").
Re: adding to an ispell dictionary
by cbro (Pilgrim) on Apr 15, 2003 at 14:22 UTC
    Hello Tom,
    I would check the file permissions, just as you suggested.
    See 'who' the ownwer of your httpd (or like process) process is, and change the permissions of your dictionary to match. I've had to do something similar many times to execute root owned scripts or write to root owned files through my CGI programs.
    If that doesn't work...
    Run the script in debug mode (-d) and/or check your web logs (error_log for Apache). Maybe the answer to your question has already been logged.

    Just some of which was yours to begin with <g>.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://250568]
Approved by pfaut
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2020-05-29 01:14 GMT
Find Nodes?
    Voting Booth?
    If programming languages were movie genres, Perl would be:

    Results (166 votes). Check out past polls.