Permalink
Browse files

Initial import of CPAN version 1.3

  • Loading branch information...
0 parents commit fb739dcd5acb5e25c54f230cdbe022533dbced41 @cosimo committed Sep 4, 2010
Showing with 2,235 additions and 0 deletions.
  1. +2 −0 Changes
  2. +180 −0 Hunspell.pm
  3. +140 −0 Hunspell.xs
  4. +12 −0 MANIFEST
  5. +11 −0 META.yml
  6. +17 −0 Makefile.PL
  7. +227 −0 README
  8. +134 −0 README_1
  9. +1,085 −0 hunspell.h
  10. +23 −0 makeso.sh
  11. +106 −0 perlobject.map
  12. +3 −0 t/01-use.t
  13. +9 −0 t/02-pod.t
  14. +40 −0 t/05-core.t
  15. +22 −0 t/test.aff
  16. +3 −0 t/test.dic
  17. +98 −0 t/test.pl
  18. +98 −0 test.pl
  19. +25 −0 typemap
@@ -0,0 +1,2 @@
+Revision history for Perl extension Text::Hunspell.
+
@@ -0,0 +1,180 @@
+package Text::Hunspell;
+
+# $Id: Hunspell.pm,v 2.1 2007/07/08 20:28:00 Eleonora Exp $
+
+require DynaLoader;
+
+use vars qw/ @ISA $VERSION /;
+@ISA = 'DynaLoader';
+
+$VERSION = '1.21';
+
+bootstrap Text::Hunspell $VERSION;
+
+# Preloaded methods go here.
+
+1;
+__END__
+
+=head1 NAME
+
+Text::Hunspell - Perl interface to the GNU Hunspell library
+
+=head1 SYNOPSIS
+
+ use Text::Hunspell;
+ my $speller = Text::Hunspell->new("/../language.aff","/../language.dic");
+
+ die unless $speller;
+
+
+ # Set some words
+ my $word = "lótól";
+ my $word1 = "lóotól";
+ my $misspelled = "lóo";
+
+
+ # check a word
+ print $speller->check( $word )
+ ? "$word found\n"
+ : "$word not found!\n";
+
+ # check a word
+ print $speller->check( $word )
+ ? "$word found\n"
+ : "$word not found!\n";
+ print $speller->check( $word1 )
+ ? "$word1 found\n"
+ : "$word1 not found!\n";
+
+ # lookup up words
+ my @suggestions;
+ @suggestions = $speller->suggest( $misspelled );
+ print Data::Dumper::Dumper( \@suggestions );
+
+ @suggestions = $speller->analyze($word);
+ print Data::Dumper::Dumper( \@suggestions );
+
+ @suggestions = $speller->stem($word);
+ print Data::Dumper::Dumper( \@suggestions );
+
+
+ # Test here generator for morphological modification (NOM->ACC)
+ @suggestions = $speller->analyze($stem);
+ $count = @suggestions;
+
+ # modify analyze output for required class (ACC)
+ for($i = 0; $i < $count; $i++){
+ $res = @suggestions[$i];
+ $res =~ s/NOM/ACC/g;
+ @suggestions[$i] = $res;
+ }
+ # generate ACC class of stem
+ @suggestions = $speller->generate2($stem, \@suggestions);
+ # end of generator for morphological modification (NOM->ACC) test
+
+ # test generator for mrphological modification, modify $stem like $word
+ @suggestions = $speller->generate($stem, $word);
+
+ # delete speller class
+ $speller->delete($speller);
+
+=head1 DESCRIPTION
+
+This module provides a Perl interface to the Oo Hunspell library. This module
+is to meet the need of looking up many words, one at a time, in a single
+session, such as spell-checking a document in memory.
+
+
+The example code describes the interface on http://hunspell.sf.net
+
+
+=head1 DEPENDENCIES
+
+You MUST have installed GNU Hunspell library version 1.0 or higher on your
+system before installing this Text::Hunspell Perl module.
+
+hunspell location is:
+
+ http://hunspell.sf.net
+
+
+There have been a number of bug reports because people failed to install hunspell before installing this module. This is an interface to the hunspell library installed on your system, not a replacement for hunspell.
+
+You must also have one hunspell dictionary installed when running the module's
+test suite.
+
+Also, please see the README and Changes files. README may have specific
+information about your platform.
+
+
+
+=head1 METHODS
+
+The following methods are available:
+
+=over 4
+
+=item $speller = Text::Hunspell->new(full_path_to_affix, full_path_to_dic);
+
+Creates a new speller object. New takes the parameters full_path_of_affix file and full_path_of_dic file
+Returns C<undef> if the object could not be created, which is unlikely.
+
+Internally, new() creates the hunspell class.
+
+=item $speller->check($word);
+check the word. Passes back 1, if the word found, 0 otherwise.
+
+=item $speller->suggest($misspelled_word);
+
+Passes back the list of suggestions for the misspelled word.
+
+=item $speller->analyze($word);
+
+Passes back the analyzis list for the word.
+
+=item $speller->stem($word);
+
+Passes back the stem list for the word.
+
+=item $speller->generate2($stem, \@suggestions);
+
+Passes back morphologically modified stem as defined in @suggestions (got by analyzis)
+
+=item $speller->generate($stem, $word);
+
+Passes back morphologically modified stem like $word
+
+=item $string = $speller->delete($speller);
+
+deletes the speller class.
+
+
+=head1 BUGS
+
+Probably.
+
+
+=head1 COPYRIGHT
+
+This library is free software; you can redistribute it
+and/or modify it under the same terms as Perl itself.
+
+
+=head1 AUTHOR
+
+Eleonora eleonora46_at_gmx_dot_net
+
+This module is based on a perl module (Text::Aspell) written by Bill Moseley moseley@hank.org.
+
+Hunspell is written as myspell by Kevin B. Hendricks, hunspell is maintained by Németh László
+
+Please see:
+
+ http://hunspell.sf.net
+for the dictionaries:
+ http://lingucomponent.openoffice.org/spell_dic.html
+ http://magyarispell.sf.net for Hungarian dictionary
+
+
+=cut
@@ -0,0 +1,140 @@
+#include "hunspell.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+#ifdef __cplusplus
+}
+#endif
+
+
+using namespace std;
+/*using namespace Hunspell;*/
+
+/* $Id: Hunspell.xs,v 1.5 2002/08/29 20:28:00 moseley Exp $ */
+
+static void * get_mortalspace ( size_t nbytes ) {
+ SV * mortal;
+ mortal = sv_2mortal( NEWSV(0, nbytes ) );
+ return (void *)SvPVX(mortal);
+}
+
+MODULE = Text::Hunspell PACKAGE = Text::Hunspell
+
+PROTOTYPES: ENABLE
+
+# Make sure that we have at least xsubpp version 1.922.
+REQUIRE: 1.922
+
+Hunspell *
+Hunspell::new(aff,dic )
+ char *aff;
+ char *dic;
+ CODE:
+ RETVAL = new Hunspell(aff, dic);
+
+ OUTPUT:
+ RETVAL
+
+
+void
+Hunspell::delete(pMS)
+ Hunspell *pMS;
+ CODE:
+ delete pMS;
+
+int
+Hunspell::check(buf)
+ char *buf;
+ CODE:
+ RETVAL = THIS->spell(buf);
+
+ OUTPUT:
+ RETVAL
+
+void
+Hunspell::suggest( buf)
+ char *buf;
+ PREINIT:
+ char **wlsti;
+ int i, val;
+ PPCODE:
+ val = THIS->suggest(&wlsti, buf);
+ for (int i = 0; i < val; i++) {
+ PUSHs(sv_2mortal(newSVpv( wlsti[i] ,0 )));
+ free(wlsti[i]);
+ }
+
+void
+Hunspell::analyze( buf)
+ char *buf;
+ PREINIT:
+ char **wlsti;
+ int i, val;
+ PPCODE:
+ val = THIS->analyze(&wlsti, buf);
+ for (int i = 0; i < val; i++) {
+ PUSHs(sv_2mortal(newSVpv( wlsti[i] ,0 )));
+ free(wlsti[i]);
+ }
+
+void
+Hunspell::stem( buf)
+ char *buf;
+ PREINIT:
+ char **wlsti;
+ int i, val;
+ PPCODE:
+ val = THIS->stem(&wlsti, buf);
+ for (int i = 0; i < val; i++) {
+ PUSHs(sv_2mortal(newSVpv( wlsti[i] ,0 )));
+ free(wlsti[i]);
+ }
+
+
+void
+Hunspell::generate( buf, sample)
+ char *buf;
+ char *sample;
+ PREINIT:
+ char **wlsti;
+ int i, val;
+ PPCODE:
+ val = THIS->generate(&wlsti, buf, sample);
+ for (int i = 0; i < val; i++) {
+ PUSHs(sv_2mortal(newSVpv( wlsti[i] ,0 )));
+ free(wlsti[i]);
+ }
+
+
+void
+Hunspell::generate2( buf, avref)
+ AV * avref;
+ char *buf;
+ PREINIT:
+ char ** array;
+ char **wlsti;
+ int len;
+ SV ** elem;
+ int i, val;
+ PPCODE:
+ len = av_len( avref ) + 1;
+ /* First allocate some memory for the pointers */
+ array = (char **) get_mortalspace( len * sizeof( *array ));
+ /* Loop over each element copying pointers to the new array */
+ for (i=0; i<len; i++) {
+ elem = av_fetch( avref, i, 0 );
+ array[i] = SvPV( *elem, PL_na );
+ }
+ val = THIS->generate(&wlsti, buf, array, len);
+ for (int i = 0; i < val; i++) {
+ PUSHs(sv_2mortal(newSVpv( wlsti[i] ,0 )));
+ free(wlsti[i]);
+ }
+
+
+
+
+
@@ -0,0 +1,12 @@
+Changes
+MANIFEST
+README
+Makefile.PL
+Hunspell.pm
+Hunspell.xs
+hunspell.h
+typemap
+t/01-use.t
+t/02-pod.t
+t/05-core.t
+META.yml Module meta-data (added by MakeMaker)
@@ -0,0 +1,11 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
+name: Text-Hunspell
+version: 1.20
+version_from: Hunspell.pm
+installdirs: site
+requires:
+ Test::More: 0
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17
@@ -0,0 +1,17 @@
+use ExtUtils::MakeMaker;
+
+my $CC = $ENV{"CXX"} || 'g++';
+
+# $Id: Makefile.PL,v 1.3 2002/08/26 02:40:25 moseley Exp $
+
+WriteMakefile(
+ NAME => 'Text::Hunspell',
+ VERSION_FROM => 'Hunspell.pm',
+ LIBS => ['-lhunspell'],
+ 'CC' => $CC,
+ 'LD' => '$(CC)',
+ PREREQ_PM => {}, # e.g., Module::Name => 1.1
+ 'XSOPT' => '-C++',
+ 'TYPEMAPS' => ['perlobject.map', 'typemap' ],
+ test => {'TESTS' =>'t/test.pl'},
+);
Oops, something went wrong.

0 comments on commit fb739dc

Please sign in to comment.