Webmaster Key - Discussion Forums


Welcome, Guest. Please login or register.
Did you miss your activation email?
February 09, 2012, 09:39:35 AM

Login with username, password and session length
Welceome to Forums!

Important information for guests and new members:

In order to understand the full benefits of becoming an active member of this forum, please review the following information on guest and new member restrictions. These forum changes have been prompted by an overwhelming and unreasonable amount of bot postings and incoherent guest spam messages. We wish to prevent these events from happening in the future and make our community a more comfortable place for all of our members.

For guests:

Guests are not allowed to open new topics, polls, or posts attachments.
If you wish to open up new discussions on this forum, we encourage you to register.

For new members:

New members with less than five posts are not allowed to modify additional profile information such as avatars, contact information, biographies, and signatures. However, new members are encouraged to post their own topics or reply to topics initiated by other members. Become active on the forums and 5 posts should be an easy task!

We are a diverse community with members from all over the world. We encourage new ideas and interesting conversation. Do not be afraid to post webmaster/computer-related questions or problems, as our active members are always willing to help when they are able. Interested? Join us.

+ Webmaster Key Forums
|-+ General Discussion
| |-+ Tech Corner
| | |-+ spell checker program
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Stumble Upon! Digg It! del.icio.us! Add to Technorati! ReddIt!  Send this topic Print
Author Topic: spell checker program  (Read 5722 times)
Andy
Administrator
Veteran
*****
Posts: 5 752



« on: October 11, 2006, 11:50:43 AM »

I need help with this:

I have coded a spell checker but my code to provide the list of suggestions for a likely correct word is a bit lame. I couldn't find examples online.

What I did was grab a word list from wordlist.sourceforge.net Then I search the list for an exact match to my word. If the word is not in the list, I want to pick suggested words from the list to offer to the user of my application.

I was playing around with regular expressions to try and get some good match result. I just used the pattern: [word]{3,}

This just looks for at least 3 of any of the characters in my word being in a sequence in one of the words in the list.

What I need is code that equates to: this string is fairly similar to this string  Grin
Report to moderator   Logged

SensoVision
Administrator
Veteran
*****
Posts: 5 857


I'm proud user of Debian GNU/Linux OS


WWW
« Reply #1 on: October 19, 2006, 04:51:08 PM »

I've thought about your problem a bit, although can't think about good solution right now. I also thinking about examining code of Linux dictionary program which have spellchecker, but code is a bit big that's why I didn't it yet.
But as for now I'm not sure if using patterns would help, I think there should be some algo which would comare each word letter by letter.
Report to moderator   Logged

Denis
Andy
Administrator
Veteran
*****
Posts: 5 752



« Reply #2 on: November 02, 2006, 11:45:27 AM »

I started tackling this problem again and found a good solution in the form of Aspell http://aspell.net

I found this resource after much trawling around the web and finally landed on Aspell via:

From: http://www.thefreecountry.com/sourcecode/spellcheckers.shtml
Quote
GNU Aspell is an open source spell checker that can be used either as a library which you can integrate in your programs or as a standalone speller. It is able to suggest misspelled words (supposedly better than any other spell checker around, or so their site claims), check documents in UTF-8, supports multiple dictionaries simultaneously, handles personal dictionaries, etc. The code is in C++, but you can access the library via its various language bindings as well, so that it is possible to use from Perl, PHP and Ruby. Dictionaries are available for a wide variety of languages

I never realized how advanced a topic spell-checking can be. What I plan to do is link to the aspell-15.dll in windows from RealBasic. I don't think anybody has done it yet in RealBasic but it has been done in Delphi. Links to the windows related info can be found here: http://aspell.net/win32/

On my journey of discovery I also found these useful links:

http://www.catch22.net/tuts/cardtut.asp - example of how to use the Windows playing cards DLL for card games
http://www.nirsoft.net/utils/dll_export_viewer.html - a free utility to view the available functions of a DLL

btw a DLL is a Dynamic Link Library in Windows which is a blob of code that can be re-used by other programs via a set of function interfaces. So each function has a name and input/output parameters. To use the software you need to create a new object of the class that defines a big blob of functionality. Then you define methods that match the characteristics of the functional interfaces to the code of this big blobby object.  Then you can use and abuse it via the usual way you do via methods and passing/retrieving values to/from parameters.  Grin

p.s. I am not trained in computer science so my communication may be a bit odd but hopefully it makes some kind of sense.
« Last Edit: November 02, 2006, 11:51:51 AM by Andy » Report to moderator   Logged

SensoVision
Administrator
Veteran
*****
Posts: 5 857


I'm proud user of Debian GNU/Linux OS


WWW
« Reply #3 on: November 02, 2006, 05:12:44 PM »

Actually I was referring to Ispell or Aspell as it's used in Linux for spellchecking all around. Guess I should name them in previous post to save your time Tongue

Good luck with DLL, hope you'll make it work for you without big hassle!
Report to moderator   Logged

Denis
Andy
Administrator
Veteran
*****
Posts: 5 752



« Reply #4 on: November 04, 2006, 12:19:25 AM »

I guess you didn't expect it to be available on the Windows platform?

I have managed to interface to the DLL but I haven't got it fully working. I plan to seek expert help on the RealBasic support forum.

The header file is very complicated and full of C++ typedefs and structures etc. so it is too much work for me to understand it all. One of the reasons I have avoided coding in C++

For example:
Code:
typedef struct AspellSpeller AspellSpeller;


struct AspellCanHaveError * new_aspell_speller(struct AspellConfig * config);

struct AspellSpeller * to_aspell_speller(struct AspellCanHaveError * obj);

void delete_aspell_speller(struct AspellSpeller * ths);

unsigned int aspell_speller_error_number(const struct AspellSpeller * ths);

const char * aspell_speller_error_message(const struct AspellSpeller * ths);

const struct AspellError * aspell_speller_error(const struct AspellSpeller * ths);

struct AspellConfig * aspell_speller_config(struct AspellSpeller * ths);

Try translating that into Basic LOL
Report to moderator   Logged

SensoVision
Administrator
Veteran
*****
Posts: 5 857


I'm proud user of Debian GNU/Linux OS


WWW
« Reply #5 on: November 03, 2006, 10:03:13 PM »

Quote
I guess you didn't expect it to be available on the Windows platform?
actually yes, I've don't even thought that someone may need to port it there, not sure why Tongue

Quote
Try translating that into Basic LOL
no, thanks Smiley I actually hate Basic for some reason(not sure why actually, maybe because I've had some bad expeience with Visual basic which keep crashing when I was writing homework with it) and try to avoid it when possible.
But maybe it would help if I can find out what doing particular functions or how to use it? Just let me know what you can't find out if you wish.
Report to moderator   Logged

Denis
Andy
Administrator
Veteran
*****
Posts: 5 752



« Reply #6 on: November 04, 2006, 06:17:09 AM »

Actually, I almost gave up but with one last attempt got it to work  Smiley

I just had to use an integer to store the windows file handles and link directly to the DLL in the Aspell program area. Here'a a typical RealBasic function declaration I used (I will use the Soft Declare function later):

Code:
Declare Function aspell_config_replace Lib "C:\Program Files\Aspell\bin\aspell-15"_
 ( handle as Integer, key as CString, value as CString ) As Integer

I'm not too keen on using a fixed path to the dll but it requires a string constant value. To avoid this, I would have to copy the dll to my program directory and configure it with the paths to the Aspell data and dictionary directory.

Nearly all the C++ functions return a handle which is easily stored and passed back via a RealBasic integer.

I didn't bother trying to make a structure to mimic the header or anything like that though.

There is no spell checker in the Windows OS as far as I can tell. You only get one when you install Office or MS Works or some other commercial software.

A sneaky idea I had would be to use an online source of spell checking such as Google search suggestions but this would not be ethical.

Quote
But maybe it would help if I can find out what doing particular functions or how to use it? Just let me know what you can't find out if you wish.
Thanks.

btw I chose to use RealBasic rather than C since I believe it is a much quicker way to build a GUI application. I may be wrong, but I thought I would be able to debug things faster if I avoided C++/.net etc. So far I am very happy with it. It seems very stable.
Report to moderator   Logged

Andy
Administrator
Veteran
*****
Posts: 5 752



« Reply #7 on: December 17, 2006, 10:58:53 AM »

I actually released my code at: http://www.sitesugu.com/geekzone/20/ Spell Checking Code with Real Basic to anyone that is interested. I was incentivised by a reader that has been struggling to code this kind of solution for a few years now. But of course things like spell checking can appear to be easy tasks at first but like I eventually realised this kind of thing is best entrusted to the realm of university research boffins. So my code is only an interface to ASpell (hard-enough for me!).

Now I moved on to Syntax Highlighting of text-based code. Wow that's fun! I posted about this elsewhere under if's and buts etc.
« Last Edit: December 17, 2006, 11:09:11 AM by Andy » Report to moderator   Logged

Pages: [1] Go Up Stumble Upon! Digg It! del.icio.us! Add to Technorati! ReddIt!  Send this topic Print 
+ Webmaster Key Forums
|-+ General Discussion
| |-+ Tech Corner
| | |-+ spell checker program

Jump to:  
« previous next »


Our Partners
RelmaxTOP Ranking System Web Hosting RelmaxTOP Ranking System
Staff Sites
12Noon[12Noon Gallery] Andy[Urgentclick]
Tamuril[Tamuril's Digital Art Exhibit] Sensovision
Powered by MySQL Powered by PHP We are hosted by Relmax Inc. |Our Privacy Policy | Sitemap
Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC
Forum design by Tamuril © 2005.
Valid XHTML 1.0! Valid CSS!