![]() |
19 Jul 2003 | Programming Adam wanted a spellchecker for his new blog without paying for it. I outlined a possible solution: if you want to do it with writing as little code as possible then you will want to do it in Bash where you have "spell" and "cat" already. www.cygwin.com And while he messed with how to get the spellchecked story to post from his local machine to his blog I wrote it (in ASP). Then it turns out that the blogger API is for XML-RPC which ASP can't do (easily). So he wants me to rewrite, preferably in PHP which is what he has the submission stuff in. I had never written any PHP before but I did the conversion which apart from a few sticking points was very easy (JSP/ASP/PHP are very very similar in the fundamentals). The code shortened to 298 lines (from 363) and no longer requires an external sorting library as there is one built in to PHP. Part of this reduction in size was due to the inlining of the ExtractWords function as with PHP's regular expression support (just like Perl's) it was a two-liner. BUT there is no equivalent of Option Explicit in PHP! The best you can do is set ERROR_ALL in php.ini which is not the same thing at all. I must be overlooking something but I can't find information about it anywhere on the web.I still have some kind of problem with escaped apostrophes (PHP'sbastard hack called magic_quotes which I was happier not to know about) and the sorting is irrelevant because the algorithm does not take advantage of it and stop searching the dictionary when there is no longer any chance the word is in there (for that matter the dictionary isn't sorted either!) |
No comments yet
All fields (except comment!) are optional. Email addresses will never be used for spam. IP is logged.
Other sites I am involved with: The Poor School - Acting Training in London | idRisk | Perspicientiae | The New Hacker's Dictionary (archived copy) | My Lomohome | Way Out Where Blog

