Jump to content

Recommended Posts

Hey there!
 

I was studying about algorithms of machine learning and artificial intelligence inner systems, in specific, i would like to create a similar system like AIML and A.L.I.C.E., but in AU3.

I can re-create pretty much all the functions in AIML by myself, except for "any (*)", which is really useful for pattern detection.

 

Example:

Spoiler
<AIML version :"1.0.1" encoding:"UTF-8"?>
<category>
<pattern> WHO IS ABRAHAM LINCOLN</pattern>
<template>Abraham Lincoln was the US President during American civil war.</template>
</category>



<category>
<pattern>DO VOU KNOW WHO * IS</pattern>
<template>
<srai>WHD IS <star/></srai>
</template>
</category>
</aiml>

That's in AIML, Basically what it does is find the pattern in user sentence and get an answer depending if it was found or not.

 

How i could re-create it in Au3?

Any help is really appreciated!

Link to comment
Share on other sites

This is a whole world unto itself, but you are going to need regular expressions for this. I am no expert, but I created an example. I'm sure it can be improved.

Local $sPattern = "(?i)(.*)(\bdo you know who )(.+)( is\b)(.*)"
MsgBox(0, "Detected:", StringRegExpReplace("Hi, do you know who Abraham Lincoln is?", $sPattern, '$3'))

This is just one of many possible ways to detect patterns using regular expressions.

Edited by czardas
Link to comment
Share on other sites

Yeah, i thought about RegExp, but what i need is the basis of the question, then just fill with user's topic.

 

I.e. : Do you know who * is?

List Array:

Abraham Lincoln: Was a USA president

Barack Obama: Was a USA president

Steve Jobs: Was the founder of Apple

Bill Gates: Is the founder of Microsoft

 

So that it will search for any of those persons in list array and get the concept, then answer to it.

 

¡And thanks for ur help!

Link to comment
Share on other sites

Funny play - with extreme limitations of course  :)
A possible way : detect the "who...is" pattern, check both array and question, return the answer
Here is a simple example (with no error checking)
 

Local $who_is[4] = ["Abraham Lincoln: Was a USA president", _
    "Barack Obama: Was a USA president", _
    "Steve Jobs: Was the founder of Apple", _
    "Bill Gates: Is the founder of Microsoft"] 

;$question = "Hi, do you know who Abraham Lincoln is?"
;$question = "Hi, do you know who this crazy Steve Jobs really is?"
;$question = "Hi, do you know who in the world is this damn Bill Gates over there ?"
$question = "Hi, do you know who czardas is ?"


If StringRegExp($question, '(?i)\bwho\b.*?\bis\b') Then Msgbox(0,"", _WhoIs($question))
  
Func _WhoIs($test)
   For $i = 0 to UBound($who_is)-1
         $name = StringRegExpReplace($who_is[$i], '^[^:]+\K.*', "")
         If StringInStr($test, $name) Then Return $who_is[$i]
   Next
   Return "Sorry, I don't know this one ..."
EndFunc

 

Edited by mikell
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...