PHP + AJAX + Dictd Interface

Lots of my geek friends have already had a preview of this feature, but we’ve launched it on the live site and now I can tell everyone about eNotes.com‘s new Dictionary/Thesaurus Lookup feature. Below are instructions for looking up a definition or finding synonym’s for any word on any of eNotes.com’s pages.

  1. Go to eNotes.com
  2. Select a word (any word, or even parts of word) with your mouse
  3. Hit SHIFT+D for a definition or SHIFT+T for a list of synonyms from the thesaurus

Being an educational site this is going to be an amazing feature for our users. Considering we have over 50 full books and plays online and over 70,000 pages of premium educational content it’s going to be great for users to be able to look up definitions and synonyms for any word on our web pages with little effort.

I’m sure everyone is wondering how we went about putting together this great feature. Surprisingly, it wasn’t really that hard. When the owners first came to me with this idea I instantly thought of AJAX. I contacted Ian Eure who is my go to Javascript guru. We talked through the options and decided that we needed some Javascript that used XMLHttpRequest to interface with a PHP script that, in turn, would perform the lookups over the TCP/IP enabled dictd. Below is a list of ingredients we used.

  • 1 Javascript guru
  • PEAR’s Net_Dict to interface with our dictd server
  • dictd installed with the WorldNet dictionary and Moby thesaurus
  • Some PHP code to parse the dictd response and convert it into XHTML
  • Some Javascript/XMLHttpRequest magic to capture the selected text and query the PHP dictd interface

We’ve spent a few weeks perfecting the interface and making it pretty, but Ian had the bulk of the prototype code done in a few hours. I’d like to thank Ian for his superb and highly professional coding skills and eNotes.com for letting us do cool stuff like this. In addition to being a great company to work for, eNotes has also agreed to release some of the library code that parses dictd responses into HTML back to the community. I would assume in the coming months HTML_Dict and Net_Dict_Parser will be released either via PEAR or, possibly, an eNotes PEAR channel.

2 thoughts on “PHP + AJAX + Dictd Interface

Leave a Reply

Your email address will not be published. Required fields are marked *