Created
March 18, 2021 14:43
-
-
Save textarcana/ec569a36cd29e4a64702a159dd91f90a to your computer and use it in GitHub Desktop.
Spell check a word on the command line.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl -w | |
# Suggest alternate spellings for a word | |
use strict; | |
use Text::Aspell; | |
my $speller = Text::Aspell->new; | |
my $word = qq{$ARGV[0]}; | |
my @suggestions_raw = $speller->suggest( $word ); | |
my @suggestions = grep { $_ =~ /^\w+$/ } @suggestions_raw; | |
$speller->check( $word ) | |
and exit(0) | |
or print join(qq{\n}, @suggestions) | |
and exit(1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment