« November 2007 | Main | January 2008 »

December 2007 Archives

December 11, 2007

Quick and Dirty Spell Correction

I was recently reading about Levenshtein string edit distance (edit distance, for short) and came across a nice little article by Peter Norvig about spelling correction. (Why doesn't he have a proper blog?)

The article discusses spelling correction and has some sample code written in Python. Python is a nice language, but these days I mainly use Ruby since it's the programming language of choice at Powerset, where I work. I found a Ruby implementation of Norvig's code, but I felt like it wasn't OO enough for my tastes, so I decided to reimplement it. All of the code is downlodable as a gzipped tarball here. Here's what one of the scripts looks like:


#!/usr/local/bin/ruby

require 'spell_checker'

def usage
STDERR.puts "#{$0} "; exit
end

def main
word = ARGV[0] || usage
spell = SpellChecker.new("holmes.txt")
candidates = spell.correct(word)
puts "Word: '#{word}'"
puts "Suggestions: #{candidates.map { |w| "'#{w}'"}.join(', ')}"
end

main

December 26, 2007

"It was probably surreal"

I just learned of the tragic events that unfolded at the SF zoo yesterday. In case you haven't heard, here's the quick summary: A tiger escaped at the SF zoo and killed one visitor and mauled two others (leaving them hospitalized). It's covered in the SF Chronicle. The understatement-of-the-year award goes to a police officer quoted in the article:

San Francisco Police Sgt. Neville Gittens said the officers did not want to shoot the animal while it was sitting next to the victim.
"I can only imagine the patrons walking around, and suddenly seeing this tiger," he said. "It was probably surreal."

Let's hope for the speedy recovery of the surviving victims.

About December 2007

This page contains all entries posted to Nerd Industries: Stuart Robinson's blog in December 2007. They are listed from oldest to newest.

November 2007 is the previous archive.

January 2008 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.35