Google spelling API

brian_d_foy on 2006-04-26T08:22:38

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";


Checking for correct spellings

markpasc on 2006-04-26T18:07:22

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).

Re:Checking for correct spellings

brian_d_foy on 2006-04-26T18:52:27

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.