John Bokma Perl
freelance Perl programmer

Net-Google spelling Perl example

To err is human | 0 comments

The following Perl program is a small example of using the spelling suggestion part of the Google API via the Net-Google module.

# gspelling.pl - Net-Google example
#
#  Copyright, 2004-2005 By John Bokma, http://johnbokma.com/
#
# $Id: gspelling.pl 1082 2008-09-30 19:05:16Z john $ 

use strict;
use warnings;

use Net::Google;

use constant GOOGLE_LICENSE_KEY =>
    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';


unless ( @ARGV ) {

    print "usage: gspelling.pl phrase\n";
    exit( 1 );
}

my $google = Net::Google->new( key => GOOGLE_LICENSE_KEY );
my $spelling = $google->spelling( phrase => \@ARGV );

my $result = $spelling->suggest;

print $result ? "Suggestion: $result\n" : "No suggestion\n";

Example of usage

Example of program usage and output:

gspelling.pl exmple
Suggestion: example
Please post a comment | read 0 comments | RSS feed