Skip to content

Instantly share code, notes, and snippets.

@jonas054
Last active August 29, 2015 13:56
Show Gist options
  • Save jonas054/9290879 to your computer and use it in GitHub Desktop.
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
# -*- 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