Looking for way to match variations of text ...

Old posts that have not been replied to for several years.
Locked
User avatar
Souperman
Halfop
Posts: 69
Joined: Sat Feb 02, 2002 8:00 pm
Location: Cape Town, South Africa
Contact:

Looking for way to match variations of text ...

Post by Souperman »

Hey guys

I'm rewriting my trivia script and I'm looking for some way to match answers on a less strict basis. Does anyone know of a Tcl or module which will match text for different spelling (e.g. it will see "color" and "colour" as equivalents, etc.)?
Quick! Somebody get me a new ink cartridge
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

There are afew ways to to this.

You could use a multiple answer database.

Depending on how you store your questions, you would store multiple answers to the question.

EG

Code: Select all

set Q1 "Orange is a:color,colour,fruit"
proc matchanswer {text} {
  global Q1
  foreach a [split [lindex [split $Q1] 1] ,] {
    if {[string tolower $a] == [string tolower $$text]} {
      return 1
    }
  }
  return 0
}
User avatar
Souperman
Halfop
Posts: 69
Joined: Sat Feb 02, 2002 8:00 pm
Location: Cape Town, South Africa
Contact:

Post by Souperman »

Yes, I'm probably going to include support for multiple answers as a lot of people have asked about it.

I'm thinking maybe some sort of "dictionary" where I can map words like color=colour and maybe common misspellings as well. Trivia shouldn't be a spelling contest in my opinion, if someone essentially has the right answer, they should get credited for it, not lose out because of minor spelling errors.
Quick! Somebody get me a new ink cartridge
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

For misspellings you can use something like the metaphone algorithm.
User avatar
Souperman
Halfop
Posts: 69
Joined: Sat Feb 02, 2002 8:00 pm
Location: Cape Town, South Africa
Contact:

Post by Souperman »

Sounds good indeed. Any idea if there's a Tcl implementation somewhere out there? I saw that there was an implementation in C ... now if only I knew C, I could make an eggdrop metaphone.mod :P
Quick! Somebody get me a new ink cartridge
Locked