collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18363
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: Smarter Bot :D  (Read 6834 times)

0 Members and 1 Guest are viewing this topic.

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Smarter Bot :D
« on: February 12, 2008, 05:28:15 am »
Changes
  • Check for match of 75% or better and uses best command it finds if not found exact (option to turn off in !set core
  • redone the Check Command Process to use isset instead of Checking all commands and comparing
  • Changed Size check so it doesnt check output from the cut function as it is already small enough
  • added Error output for denied Access to commands (turn off in !set core)
  • Fixed bug were Ext_privgroup output would output to normal privgroup if large enough to be split

This is in Normal Releases of Bebot
« Last Edit: March 30, 2009, 06:36:16 pm by Temar »

Offline Wolfbiter

  • Contributor
  • *******
  • Posts: 149
  • Karma: +0/-0
    • KAZE
Re: Smarter Bot :D
« Reply #1 on: February 12, 2008, 11:39:51 am »
Adding s at the non-found command doesn't make your bot smart at all.
Do some string compare instead, and if the result is over a certain %, and only one command is above that %, assume it's it.

Code: [Select]
function cmpr($one, $two) {
//How many % loss for each length difference? Substracted at the end.
$loss["diff"] = 10;
//How many % loss for a wrong char? It's 100-(this no.) for each wrong char.
$loss["char"] = 75;
//How many % loss for a wrong char, but the one before/after matches?
$loss["oneoff"] = 25;
$return = 0;

if (strlen($one) <= strlen($two)) {
$first = $one;
$second = $two;
$diff = strlen($two) - strlen($one);
}
else {
$first = $two;
$second = $one;
$diff = strlen($one) - strlen($two);
}
for ($i=0;$i<strlen($first);$i++) {
if ($first{$i} == $second{$i})
$return += 100;
elseif($first{$i} == $second{$i-1})
$return += 100-$loss["oneoff"];
elseif($first{$i} == $second{$i+1})
$return += 100-$loss["oneoff"];
else
$return += 100-$loss["char"];
}
return round(($return / strlen($first)) - ($loss["diff"] * $diff));
}

Ran a test on some different words (typos and different commands). A result of >75% should be accurate enough to assume it's a simple typo.
Code: [Select]
whois - ehois: 90%
items - item: 90%
items - tiems: 90%
alts - alt: 90%
items - tiem: 78%
xp - is: 50%
id - is: 75%
axp - apf: 75%
join - kick: 56%
level - guest: 60%
calc - city: 63%
tokens - whois: 50%
lvl - alts: 57%
cloak - calc: 59%
Too many toons.

Offline Tichy

  • BeBot User
  • **
  • Posts: 42
  • Karma: +0/-0
Re: Smarter Bot :D
« Reply #2 on: February 12, 2008, 06:13:38 pm »
Ever thought about the soundex or methaphone functions of php to compare the commands pronunciation? Never tried by myself...

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: Smarter Bot :D
« Reply #3 on: February 12, 2008, 06:25:20 pm »
wolf wont that have to compare every command to the word you used

Offline Blueeagle

  • Omnipotent
  • BeBot Hero
  • ******
  • Posts: 323
  • Karma: +0/-0
Re: Smarter Bot :D
« Reply #4 on: February 12, 2008, 08:13:22 pm »
I would suggest using similar_text(). Soundex and metaphone will most likely not catch instances where the first and second letter have been exchanged for example !tiem instead of !item.

For short commands like "is" typed as "si" all would fail. For longer commands like "member" vs "members" all would succeed.

There is some discussion as to the speed of similar_text() but that, as I understand it, is only relevant for really long (20000 characters+) texts.

The question is how one would go about implementing this. There are two scenarios that I see as fesable.

The first is to run trough the command list and check for an exact match like we're doing today. If no matches are found run trough again but this time check for the best match with similar text. If no command match more than 75% reply with a command not found. If one or more are matched with 75% or higher tell the user that we're assuming the best match. If two commands score exactly the same and both are above 75% tell the user that there are two possible matches and create a link to each of the two with the parameters as they were passed.

The second is to process commands with similar_text() and save the best match in a temporary variable array. If no 100% are found find the best match and if it's above 75% assume that it's the one the user wanted.


The danger here is when the command "lick" is removed and someone with access to the "kick" command hasn't been notified. So when that person tries to !lick someuser that user will be unexpectedly booted. To remedy this one can define a treshold for commands so that !kick will have to be 100% exact while !members can be 92% which is the difference between "member" and "members" (93% if you incude the command character)


The code I used to test this can be found on my server.

I hope that helps.
The only problem that can't be solved by adding another wrapper is having too many wrappers.

Offline Glarawyn

  • BeBot Hero
  • ******
  • Posts: 521
  • Karma: +0/-0
Re: Smarter Bot :D
« Reply #5 on: February 12, 2008, 09:21:30 pm »
Or you know...just trow an error message and make the user type the command as intended by the developer.  :P

Offline Wolfbiter

  • Contributor
  • *******
  • Posts: 149
  • Karma: +0/-0
    • KAZE
Re: Smarter Bot :D
« Reply #6 on: February 13, 2008, 12:03:47 am »
soundex() and metaphone is for illiterate problems, not typos.
similar_text() would be a lot better than mine, but I needed to kill some time and it gave me something to do ;).

If an exact match is found, another loop would go over using similar_text() compare, and any match over set % is stored, and when it's done the highest (if any) will be used. More with same, just output a blob as Blue said.
It shouldn't be hard to implement it either, and don't think it would be slow, not hard to try.

And Glara... this is a post about a smarter bot, not smarter user... and it's so much easier to make the bot smarter. The users will always be dimwits...
« Last Edit: February 13, 2008, 12:10:18 am by Wolfbiter »
Too many toons.

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Smarter Bot :D
« Reply #7 on: February 13, 2008, 06:11:36 pm »
The option to use something like similar_text() doesn't sound bad.

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: Smarter Bot :D
« Reply #8 on: February 13, 2008, 06:26:48 pm »
ive done it ill be posting code in about 5 min :p

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: Smarter Bot :D
« Reply #9 on: February 13, 2008, 06:51:24 pm »
Done

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: Smarter Bot :D
« Reply #10 on: February 15, 2008, 05:20:11 am »
Corrected a Spelling Error
Added option to Turn off Disabled Commands Errors msg
Fixed bug were it did a search even tho it had found the command but user didnt have permission to use

This post = Total Posts: 8000 ;D
« Last Edit: February 15, 2008, 05:29:19 am by Temar »

Offline Blueeagle

  • Omnipotent
  • BeBot Hero
  • ******
  • Posts: 323
  • Karma: +0/-0
Re: Smarter Bot :D
« Reply #11 on: February 15, 2008, 12:06:31 pm »
Or you know...just trow an error message and make the user type the command as intended by the developer.  :P

Well technically this sort of thing wouldn't have been neccessary if a codingstandard has been set so that there wouldn't be mixed single and plural. (ie. all would have been !alt and !member and so on or all would have been !alts and !members) (I would advocate the first)
The only problem that can't be solved by adding another wrapper is having too many wrappers.

Offline porter

  • BeBot User
  • **
  • Posts: 28
  • Karma: +0/-0
Re: Smarter Bot :D
« Reply #12 on: February 16, 2008, 01:05:22 am »
And Glara... this is a post about a smarter bot, not smarter user... and it's so much easier to make the bot smarter. The users will always be dimwits...

Then again, if people learn to expect a bot to understand any mistyped command they throw at it they will get even more lazy and dimwitted and make their friends the same by telling them to use an essentially wrong command to achieve something "because it is close enough" and "it works".

You know the apparently American habit of typing something that maybe resembles a word and adding a (sp?) after it to show your ignorance while at the same time making believe it is OK... ;)

[edit] And I agree with Blueeagle above, as well.

[edit2] "help" is your friend, if the choice was mine I'd focus more on up to date help files of all the bot commands instead of adding an AI to parse users trying to guess what that undocumented feature was... That would be a smart bot, one that actually knows all its commands and can tell the user how to use them.
« Last Edit: February 16, 2008, 01:12:49 am by porter »

Offline Blueeagle

  • Omnipotent
  • BeBot Hero
  • ******
  • Posts: 323
  • Karma: +0/-0
Re: Smarter Bot :D
« Reply #13 on: February 16, 2008, 05:28:10 am »
Don't get me wrong. I don't think cleaning the mess up with such a feature is good. However we should go trough the commands and change them so that none are plural and tell the users that the command now has changed.

One could do this by returning a blob telling the person the correct command and throwing in a link that would execute the command the user wanted instead of just giving the person the result they tried to achieve in the first place.

That would limit forcing users to re-type but still be annoying enough that the next time the user would use the correct command.
The only problem that can't be solved by adding another wrapper is having too many wrappers.

Offline Wolfbiter

  • Contributor
  • *******
  • Posts: 149
  • Karma: +0/-0
    • KAZE
Re: Smarter Bot :D
« Reply #14 on: February 16, 2008, 06:52:30 pm »
The idea is to make the bot react to simple typos (ehois, tiems, etc) and not to make people lazy and dumber, even if that's a side effect. Nothing in this world is perfect.
But it's really hard to make a function (unless you predefine all typos) that'll know when it's a typo or when it's a dumb user.
Too many toons.

 

* Recent Posts
[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm]


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 721
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal