Created
April 27, 2010 08:21
-
-
Save yevgenko/380491 to your computer and use it in GitHub Desktop.
simultaneous spell checking for Russian and English
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/perl -ln | |
# aspell wrapper to have spell checking simultaneously for Russian and English | |
# from http://powerman.name/config/vim.html | |
# put this code into ~/bin/aspell and make executable | |
BEGIN { | |
($OPT = " @ARGV ") =~ s/\s+-d\s+\w+//g; | |
$IS_APPEND = $OPT =~ /\s-a\s/; | |
@ARGV = ('-'); | |
umask 077; | |
open $R,"| /usr/bin/aspell $OPT -d russian --ignore-accents >/tmp/aspell_ru.$$"; | |
open $E,"| /usr/bin/aspell $OPT -d english >/tmp/aspell_en.$$"; | |
} | |
if ($IS_APPEND) { | |
if (/^\*/) { | |
print { /[\xA3\xB3\xC0-\xFF]/ ? $R : $E } $_; | |
} | |
else { | |
print $R $_; | |
print $E $_; | |
} | |
} | |
else { | |
print { /[\xA3\xB3\xC0-\xFF]/ ? $R : $E } $_ | |
for split /[^\@0-9_a-zA-Z\xA3\xB3\xC0-\xFF]+/; | |
} | |
END { | |
close $R; | |
close $E; | |
system("cat /tmp/aspell_{en,ru}.$$ ; rm /tmp/aspell_{en,ru}.$$"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment