Last active
August 29, 2015 13:56
-
-
Save jonas054/9290879 to your computer and use it in GitHub Desktop.
A wrapper around aspell for finding spelling mistakes using a dictionary and a whitelist
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
# -*- coding: utf-8 -*- | |
# | |
# Usage spell.rb <files...> | |
require 'open3' | |
found_words = ARGV.map { |path| IO.read(path).scan(/[A-Z]?[a-z]+/) } | |
whitelist = IO.read('.dictionary').split | |
stdout, _ = Open3.capture2('aspell -l en_US list', stdin_data: found_words) | |
misspelled_according_to_aspell = stdout.split.uniq.sort | |
unrecognized_words = misspelled_according_to_aspell - whitelist | |
puts unrecognized_words.sort |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment