Skip to content

Instantly share code, notes, and snippets.

@seungwon0
Created January 17, 2011 04:46
Show Gist options
  • Save seungwon0/782508 to your computer and use it in GitHub Desktop.
Save seungwon0/782508 to your computer and use it in GitHub Desktop.
Simple Korean Spell Checker using WebService::KoreanSpeller
#!/usr/bin/env perl
#
# kspeller - Korean Spell Checker
#
# Simple Korean Spell Checker using WebService::KoreanSpeller
#
# Seungwon Jeong <seungwon0@gmail.com>
#
# Copyright (C) 2011 by Seungwon Jeong
use strict;
use warnings;
use 5.010;
use WebService::KoreanSpeller;
use Encode qw< encode_utf8 decode_utf8 >;
use English qw< -no_match_vars >;
LINE:
while ( defined( my $line = <> ) ) {
chomp $line;
next LINE if $line =~ /^\s*$/xms; # Skip if only whitespace characters
my @results = WebService::KoreanSpeller->new( text => decode_utf8($line) )
->spellcheck;
for my $item (@results) {
my $position = encode_utf8( $item->{position} );
my $incorrect = encode_utf8( $item->{incorrect} );
my $correct = encode_utf8( $item->{correct} );
my $comment = encode_utf8( $item->{comment} );
say "${INPUT_LINE_NUMBER}:${position}: ${incorrect} => ${correct}";
say $comment;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment