Stories
Slash Boxes
Comments

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Wednesday April 26, 2006
03:22 AM

Google spelling API

[ #29449 ]

Instead of typing words into a Google web page to see how I should spell it, I'll just do it from the command line. I have a Google API key, so I might as well use it.

#!/usr/bin/perl
 
use Net::Google::Spelling;
 
my $spelling = Net::Google::Spelling->new(
    {
    key => $ENV{GOOGLE_KEY}
    },
    );
 
$spelling->phrase( "@ARGV" );
 
print do {
    my $suggestion = $spelling->suggest();
 
    $suggestion
        ?
    "Google suggests: $suggestion"
        :
    "Google has no suggestion"
    }, "\n";

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • If there are no suggestions, you might try searching again, but intentionally misspelling the term by appending an x. If the original term comes back as a suggestion, then it was correctly spelled (according to Google, anyway).
    • Ah, excellent idea! That makes the structure a bit more complicated though.

      I think I'll have to use a variation on that idea though. I tried a few by adding an "x" but get back the plural of the word instead (and hey, "x" is right next to "s" on the qwerty keyboard). I tried a few other things, such as removing the first or last letters, but those things came back without suggestions.

      Maybe I'm missing something. I'll have to check the API docs again.