Pulling words from a database

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
sporcello
Posts: 2
Joined: Wed Sep 11, 2013 12:51 am

Pulling words from a database

Post by sporcello » Wed Sep 11, 2013 12:58 am

I am interested in creating a trivia type scenario where a user is asked a question and must type in the correct answer into a text box. My thought is that I would create a database within the file so that the information can be appropriately referenced. My question is this - is there any way that LiveCode can take a word and create variations of that word or accept variations of that word as a correct answer. For example, let's say the correct word is Ibuprofen, however, ibuprofen, or ibuprofin would also be acceptable. Is there a way to tell LiveCode that so long as 'buprof' is part of the answer, then it is correct? I hope that makes sense.

Thank you for your help!

Stephanie Smith

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Pulling words from a database

Post by Simon » Wed Sep 11, 2013 1:26 am

Hi Stephanie,
Welcome to the forum!

Here maybe this will help:
http://lessons.runrev.com/s/lessons/m/4 ... 716-arrays

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10354
Joined: Wed May 06, 2009 2:28 pm

Re: Pulling words from a database

Post by dunbarx » Wed Sep 11, 2013 4:19 am

Hi.

Firstly, how experienced are you with LiveCode?

Simon has pointed you towards a tool that can be used to associate one or more explicit variations of a word with the word itself. It is the most compact way to effect that, and finding such associated variants is straightforward.

But is that the entire scope? For example, would any variation that differed from the base word be acceptable? In other words, your example of "ibuprofen" showed a very reasonable misspelling, "ibuprofin". But would, in your scheme, ixuprofen also be possible, in that any single letter that was transposed also might be a candidate?

If so, then I am writing here only to find out if you are game for other possible attacks on your project. To write a routine that finds that sort of variant is a different task entirely.

Or something else?

EDIT: It is certainly possible to write a handler that would create an array containing all 25 variants of each letter in each word in your database. Just a thought. The goal here is to learn LC, after all. Plenty of fodder for that....

Craig Newman

dave_probertGA6e24
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 328
Joined: Mon Dec 05, 2011 5:34 pm
Contact:

Re: Pulling words from a database

Post by dave_probertGA6e24 » Wed Sep 11, 2013 6:04 am

Hi,

A simple(ish) way might be to assign a 'matching percentage' to each word. Such that a certain number of characters must be correct to assume that it is the correct word. 'ibuprofen' could be correct as long as 6 out of the 8 characters are the same (ie. in the correct sequence overall)

'ibprofen' would match
'ibuqrofin' would also match
.. and so on

But you are probably wanting a 'Soundex' implementation. This would match things that are incorrectly written, but kinda sound the same when spoken. No idea how you write one of these though. There is probably a lot of info on it found via Google ;)

Cheers,
Dave
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.

sporcello
Posts: 2
Joined: Wed Sep 11, 2013 12:51 am

Re: Pulling words from a database

Post by sporcello » Wed Sep 11, 2013 10:59 am

Thank you all for replying to my post. I have previously made a simple game in LiveCode, so this would be my second attempt at creating something. What I am wanting to make is more of a study aid where the user is asked a question and then has to respond by typing in an answer. The point of what I was asking for previously was to find a way to create the interaction so that the user isn't marked completely wrong if they happen to misspell a word. The words that will be used are all names of medicines, so it may be common for someone to not know an exact spelling and I don't want to discourage them from using the game. I wanted to see if something was possible prior to starting my work. I will have to play around with the suggestions you all made and come back if I expereince any issues. Any additional comments/suggestions are welcome.

Thanks,

Stephanie

Post Reply