Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / V1.8, tier 1, "spelling checker" ... Can it be done?

Author
Message
miki
19
Years of Service
User Offline
Joined: 7th Jan 2005
Location:
Posted: 3rd Feb 2014 23:30
Hi,

I'm making a word game.
Is it possible to implement a spelling checker?

regards,
miki

in the end
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 4th Feb 2014 00:34
Yes - Off you go.

-- Jim - When is there going to be a release?
miki
19
Years of Service
User Offline
Joined: 7th Jan 2005
Location:
Posted: 4th Feb 2014 00:47
@Jim
??

in the end
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 4th Feb 2014 00:48
some background info you can find at wiki.
http://en.wikipedia.org/wiki/Spell_checker

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
miki
19
Years of Service
User Offline
Joined: 7th Jan 2005
Location:
Posted: 4th Feb 2014 01:03
Thanx Marcus.

in the end
easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 4th Feb 2014 02:41
You will need a wordlist, and thats about all

Just use GetStringToken( str, delimit, token ) (with " " as the delimit) to get each word and if it doesn't appear in the wordlist, then declare it as wrong

miki
19
Years of Service
User Offline
Joined: 7th Jan 2005
Location:
Posted: 4th Feb 2014 03:10
Yo,

thanks easter bunny... just the right command.

I have found a 850 words "word list".

Ah well, another long night. (this is fun)

in the end
miki
19
Years of Service
User Offline
Joined: 7th Jan 2005
Location:
Posted: 4th Feb 2014 05:02 Edited at: 4th Feb 2014 05:07
I got a complete word list from:

http://www.instructables.com/files/orig/FLU/YE8L/H82UHPR8/FLUYE8LH82UHPR8.txt

Attached to this post for download.

And the code, that works just fine




Easy!!

Thanks Marcus and easter bunny

in the end

Attachments

Login to view attachments
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 4th Feb 2014 08:27
ok
some faster way is to compare the len and later the chars.

if len(word$) = len("enthusiastic")
if word$ = "enthusiastic"

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 4th Feb 2014 10:56
Spelling checkers use some clever algorithms, including hashing. You can't just run down a huge list. That will bring the average Android tablet to its knees!

-- Jim - When is there going to be a release?
miki
19
Years of Service
User Offline
Joined: 7th Jan 2005
Location:
Posted: 4th Feb 2014 11:57


in the end
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 4th Feb 2014 12:33
That's an eternity in computer terms

But if it suits your needs then it's good enough. If you ever find it is too slow someone posted a tier 1 map(hash) implementation, this would probably speed it up a lot.

miki
19
Years of Service
User Offline
Joined: 7th Jan 2005
Location:
Posted: 4th Feb 2014 12:55
thanx,
i'll look it up

in the end
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th Feb 2014 15:41
Keep your word list alphabetized and use a binary search. A hash table would be better if possible. This will help to eliminate words quickly that are spelled correctly.

Then you need some kind of method to determine the closest match if a word is not found in your dictionary. A good spell checker is quite advanced really. If I type "thr", did I really mean "there" or "the"? Algorithms to determine what word most closely matches isn't all there is. Several words could be possible matches, so pick the word that is most commonly used. In this case, it's probably "the". Then you can look at possible typos based on how far off an incorrect letter is from the correct letter on a keyboard. I have no clue how to do any of this, but all these things are taken into consideration with the spell checker in iOS.

Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 6th Feb 2014 02:20
I'm having a tough time finding my original link, but here is the ENABLE word list
It has 172,000 words and is pretty extensive - it is what Words With Friends uses for their dictionary with some modifications to 2-letter words.
The way we handle it for Wordspionage is via a server database with tables for every letter and word length (i.e. a02,a03,b11, etc). It's very fast and you could do a similar method with local files.
Create a program that parses the list alphabetically and by word length and have it ouput into separate files (i.e. a02,a03,s10, etc.).
Now in your program you can simply look at the first letter of the word to be checked and the length of the word then check it against the corresponding file. Some files will be 1,000 lines or more, but this is much better than looking through 170,000 lines. If you want you could split them up even smaller by the first two letters of the word. When building Wordspionage I found that unnecessary and the performance was good enough (though it is nearly instantaneous when grabbing it from a MySQL database instead).

It's not a predictive spell checker, but it works for word games to verify spelling.

Auger
13
Years of Service
User Offline
Joined: 21st Aug 2011
Location: Out There
Posted: 6th Feb 2014 21:43
In my game I submitted to the Intel comp I read in a 85000 word list into an array when loading and then checked for matches. On my pc it takes about 0.008 of a second to search the array.

Auger
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th Feb 2014 21:01
Something that might help out, Levenshtein distance

Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 16th Feb 2014 23:45
I used a pretty big word list in my MIXMIX game. The searching that I use is very fast. The catch is loading in all the words when the game starts. On a PC, no problem. On an iPad, still very quick. On an iPhone, very slow load time. On an Android tablet or phone, the load time runs up to 12 minutes or so. So that didn't work for me.

I've thought about trying memblocks, but I'm hoping that load/save array in AGK2 will solve that sort of problem.

JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 16th Feb 2014 23:56
Rich - You need to use some smarter loading techniques. Don't try to load everything in one go. If possible load small chunks on demand.

-- Jim - When is there going to be a release?
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 17th Feb 2014 10:24
Quote: "If possible load small chunks on demand."


Good advice, except I need all the words loaded when the game starts. Due to the mechanics of my game, I've split the word list into 10 lists... a list for 1-letter words (small list) up through a tenth list for 10-letter words. But the player can input any word up to 10 letters long right from the start.

I firmly believe it's a problem with the Android implementation of AGK. Like maybe the packed file has to be unpacked every time the game is run. Even when I unpack and save the files the first time the game is run, well, it's still a 12 minute wait that first time - unacceptable.

As I said, the game loads fine on PC and iOS,=. My point was that a spelling checker is very possible in AGK. I don't want to hijack this thread.

JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 17th Feb 2014 13:56
Rich - I think that's more a problem of not very powerful processors and the mess that is Android. It could also be the string handling and file read implementations, the unzip characteristics etc.

-- Jim - When is there going to be a release?
miki
19
Years of Service
User Offline
Joined: 7th Jan 2005
Location:
Posted: 17th Feb 2014 17:22
I found that Naphier's system of breaking the wordlist into smaller parts works okay. On a cheap mini tablet. (Load on demand, local files.)

JimHawkins was right about the full wordlist crashing a tablet.
It's so much quicker via the wi-fi player.

in the end

Login to post a reply

Server time is: 2024-11-25 01:45:12
Your offset time is: 2024-11-25 01:45:12