Created
January 17, 2011 04:46
-
-
Save seungwon0/782508 to your computer and use it in GitHub Desktop.
Simple Korean Spell Checker using WebService::KoreanSpeller
This file contains 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 | |
# | |
# kspeller - Korean Spell Checker | |
# | |
# Simple Korean Spell Checker using WebService::KoreanSpeller | |
# | |
# Seungwon Jeong <[email protected]> | |
# | |
# 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