Archives‎ > ‎

AI_Tutorials

Here we will be building an artificial intelligence chat bot application: each stage we shall cover a single task or operation. code will be given at the bottom of the page to be downloaded so that you can follow along.

We shall be using Visual studio 2013, in the visual basic language. although it can be created in any programming language as the principles are the same.  feel free to use the code as you wish and we supply the code to be used freely without copyright.



  • Creating a chatbot - Adding a plugin mechanism In this lesson , you will be shown how to create an interface to allow for external plugins to be added to your AI, Compile on the fly. A DLL file ...
    Posted Dec 13, 2014, 9:35 AM by Leroy Dyer
  • Creating the chat bot 3 - The speech Addon  Speech is an important part of communication, the microsoft speech API offers all we need to consume. Lets Use it!The speech add on : here we add Microsoft speech to ...
    Posted Oct 26, 2014, 5:30 AM by Leroy Dyer
  • Creating a chatbot 2 Creating a GUI for the artificial intelligence is an important part of the design process. the look and feel of the app can also give you the feeling and look ...
    Posted Oct 26, 2014, 5:08 AM by Leroy Dyer
  • Regular Expression Syntax (Scripting) A regular expression describes one or more strings to match when you search a body of text. The expression serves as a template for matching a character pattern to the ...
    Posted Oct 21, 2014, 6:38 PM by Leroy Dyer
  • Creating the chatbot Chat botsAs you know, the chat-bot is a chatting robot that can understand what you are saying, analyse it and give you a suitable response. It's considered ...
    Posted Oct 20, 2014, 5:32 AM by Leroy Dyer
Showing posts 1 - 5 of 5. View more »

Recent Announcements

  • Home Automation HomeSeer includes a built-in web server, giving you access to all your devices from anywhere in the world using any web browser. The program works great if you have ...
    Posted Oct 21, 2014, 6:57 PM by Leroy Dyer
  • The conceptnet module ConceptNet 5 comes largely from the hard work of hundreds of thousands of people who gave their time and knowledge for free. So ConceptNet is free as well, released under ...
    Posted Oct 21, 2014, 6:35 PM by Leroy Dyer
  • Scripting for Conceptual Respresentation Knowledge representation Knowledge representation is crucial. One of the clearest results of artificial intelligence research so far is that solving even apparently simple problems requires lots of knowledge. Really understanding ...
    Posted Oct 21, 2014, 6:46 PM by Leroy Dyer
  • Athena Project A preview of the Athena project by Arron Snow <SNOWMAN> http://aaronwsnow.com An example of Custom AI, The Steps, The Mind-Set... Why are people so interested in AI ...
    Posted Oct 18, 2014, 6:13 AM by Leroy Dyer
  • IS A-I POSSIBLE Human intelligence involves both ``mundane'' and ``expert'' reasoning. By mundane reasoning I mean all those things which (nearly) all of us can routinely do (to various abilities) in order to ...
    Posted Oct 18, 2014, 5:08 AM by Leroy Dyer
Showing posts 1 - 5 of 5. View more »

Creating a chatbot - Adding a plugin mechanism

posted Dec 7, 2014, 6:20 AM by Leroy Dyer   [ updated Dec 13, 2014, 9:35 AM ]



In this lesson , you will be shown how to create an interface to allow for external plugins to be added to your AI, Compile on the fly. A DLL file is compiled an made available to the main script without reloading the application.

by creating an interface the AI can execute the Interface and all DLL's implementing the interface.


This feature enables for a release of the AI, Giving the ability to issue updates which can be placed in the designated plugins/updates folder.

Here: An interface Called Iplugin defines the shape of the "Class" or the plugin to be designed. 
The main source code, can create an instance of the class and execute the "unknown class" extracting the "response" from the class to be used in the main script.

The load Plugins function, loads all dlls then only the classes which implement the interface. 


This could provide a mechanism for the AI to Write its own code too. the implications for this can be futuristic, a computer writing its own code and executing the code without the need to recompile the code. 



Creating the chat bot 3 - The speech Addon

posted Oct 26, 2014, 5:18 AM by Leroy Dyer   [ updated Oct 26, 2014, 5:30 AM ]

 Speech is an important part of communication, the microsoft speech API offers all we need to consume. 

Lets Use it!

The speech add on : here we add Microsoft speech to our project.

Imports System.Speech.Recognition
Imports System.Speech.Synthesis

'Speech synthasis methods
    '------------------------------------------------------------------------------------------------------------------------------------------------------

    ''' <summary>
    ''' enables voice recognition engine
    ''' </summary>
    ''' <remarks></remarks>
    Public WithEvents RecoEngine As New SpeechRecognitionEngine()
    ''' <summary>
    ''' Enable TexttoSpeech
    ''' </summary>
    ''' <remarks></remarks>
    Private SpeechSynth As New SpeechSynthesizer



    ''' <summary>
    ''' Sets up Speech Recognition for use
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub SetupRecognition()

        RecoEngine.LoadGrammar(New DictationGrammar())
        RecoEngine.SetInputToDefaultAudioDevice()
        RecoEngine.RecognizeAsync()
    End Sub

    ''' <summary>
    ''' Activated on completion of recognition
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub RecoEngine_RecognizeCompleted(ByVal sender As Object, ByVal e As System.Speech.Recognition.RecognizeCompletedEventArgs) Handles RecoEngine.RecognizeCompleted
        RecoEngine.RecognizeAsync()
    End Sub

    ''' <summary>
    ''' On recogonizing speech the input is sent to the response routine
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub RecoEngine_SpeechRecognized(ByVal sender As Object, ByVal e As System.Speech.Recognition.RecognitionEventArgs) Handles RecoEngine.SpeechRecognized
      
        'a call to act is requird here 
        ProcessInputText(e.Result.Text)
    End Sub

    ''' <summary>
    ''' Speaktext Uses the internal speech system to speak the text, using the SAPI
    ''' </summary>
    ''' <param name="NewText">String: Text to be spoken</param>
    ''' <remarks></remarks>
    Public Sub SpeakText(ByRef NewText As String)

        SpeechSynth.Speak(NewText)
    End Sub


Articles about AI concepts

  • Home Automation HomeSeer includes a built-in web server, giving you access to all your devices from anywhere in the world using any web browser. The program works great if you have ...
    Posted Oct 21, 2014, 6:57 PM by Leroy Dyer
  • The conceptnet module ConceptNet 5 comes largely from the hard work of hundreds of thousands of people who gave their time and knowledge for free. So ConceptNet is free as well, released under ...
    Posted Oct 21, 2014, 6:35 PM by Leroy Dyer
  • Scripting for Conceptual Respresentation Knowledge representation Knowledge representation is crucial. One of the clearest results of artificial intelligence research so far is that solving even apparently simple problems requires lots of knowledge. Really understanding ...
    Posted Oct 21, 2014, 6:46 PM by Leroy Dyer
  • Athena Project A preview of the Athena project by Arron Snow <SNOWMAN> http://aaronwsnow.com An example of Custom AI, The Steps, The Mind-Set... Why are people so interested in AI ...
    Posted Oct 18, 2014, 6:13 AM by Leroy Dyer
  • IS A-I POSSIBLE Human intelligence involves both ``mundane'' and ``expert'' reasoning. By mundane reasoning I mean all those things which (nearly) all of us can routinely do (to various abilities) in order to ...
    Posted Oct 18, 2014, 5:08 AM by Leroy Dyer
Showing posts 1 - 5 of 5. View more »

Creating a chatbot 2

posted Oct 22, 2014, 6:51 AM by Leroy Dyer   [ updated Oct 26, 2014, 5:08 AM ]

Creating a GUI for the artificial intelligence is an important part of the design process. the look and feel of the app can also give you the feeling and look of a professional application.

Apples IOS UI Ideals

  • Deference. The UI helps people understand and interact with the content, but never competes with it.

  • Clarity. Text is legible at every size, icons are precise and lucid, adornments are subtle and appropriate, and a sharpened focus on functionality motivates the design.

  • Depth. Visual layers and realistic motion impart vitality and heighten people’s delight and understanding.



Creating the GUI

When creating the gui i have used a transparent gif file for my skin file.
the transparent for is achieved by new features in the form property s, although this can also leave problems with form movement also.

Additional code has been added to allow for mouse movement of the form.




   'form positioning
    '-----------------------------------------------------------------------------------------
    Private x, y As Integer
    Private newpoint As New Point
    'Form Movement
   

 ''' <summary>
    ''' This samples solves the problem for the form not being moveable.
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub Frm_AI_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
        Try
            ' Form movement set integers
            x = Control.MousePosition.X - Me.Location.X
            y = Control.MousePosition.Y - Me.Location.Y
        Catch ex As Exception

        End Try
    End Sub
    
''' <summary>
    ''' This samples solves the problem for the borderless form not being moveable.
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub Frm_AI_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
        Try
            ' Form movement movement
            If e.Button = Windows.Forms.MouseButtons.Left Then
                newpoint = Control.MousePosition
                newpoint.X -= (x)
                newpoint.Y -= (y)
                Me.Location = newpoint
            End If
        Catch ex As Exception

        End Try
    End Sub
    '-----------------------------------------------------------------------------------------






Articles about AI

  • Home Automation HomeSeer includes a built-in web server, giving you access to all your devices from anywhere in the world using any web browser. The program works great if you have ...
    Posted Oct 21, 2014, 6:57 PM by Leroy Dyer
  • The conceptnet module ConceptNet 5 comes largely from the hard work of hundreds of thousands of people who gave their time and knowledge for free. So ConceptNet is free as well, released under ...
    Posted Oct 21, 2014, 6:35 PM by Leroy Dyer
  • Scripting for Conceptual Respresentation Knowledge representation Knowledge representation is crucial. One of the clearest results of artificial intelligence research so far is that solving even apparently simple problems requires lots of knowledge. Really understanding ...
    Posted Oct 21, 2014, 6:46 PM by Leroy Dyer
  • Athena Project A preview of the Athena project by Arron Snow <SNOWMAN> http://aaronwsnow.com An example of Custom AI, The Steps, The Mind-Set... Why are people so interested in AI ...
    Posted Oct 18, 2014, 6:13 AM by Leroy Dyer
  • IS A-I POSSIBLE Human intelligence involves both ``mundane'' and ``expert'' reasoning. By mundane reasoning I mean all those things which (nearly) all of us can routinely do (to various abilities) in order to ...
    Posted Oct 18, 2014, 5:08 AM by Leroy Dyer
Showing posts 1 - 5 of 5. View more »



Regular Expression Syntax (Scripting)

posted Oct 21, 2014, 6:38 PM by Leroy Dyer   [ updated Oct 21, 2014, 6:38 PM ]

regular expression describes one or more strings to match when you search a body of text. The expression serves as a template for matching a character pattern to the string that is being searched.

A regular expression consists of ordinary characters (for example, letters a through z) and special characters, known asmetacharacters.

  Special Characters

The following table contains a list of single-character metacharacters and their behavior in regular expressions.

NoteNote:

To match one of these special characters, you must first escape the character, that is, precede it with a backslash character (\). For instance, to search for the "+" literal character, you can use the expression "\+".

Metacharacter

Behavior

Example

*

Matches the previous character or subexpression zero or more times.

Equivalent to {0,}.

zo* matches "z" and "zoo".

+

Matches the previous character or subexpression one or more times.

Equivalent to {1,}.

zo+ matches "zo" and "zoo", but not "z".

?

Matches the previous character or subexpression zero or one time.

Equivalent to {0,1}.

When ? immediately follows any other quantifier (*, +, ?, {n}, {n,}, or {n,m}), the matching pattern is non-greedy. A non-greedy pattern matches as little of the searched string as possible. The default greedy pattern matches as much of the searched string as possible.

zo? matches "z" and "zo", but not "zoo".

o+? matches a single "o" in "oooo", and o+ matches all "o"s.

do(es)? matches the "do" in "do" or "does".

^

Matches the position at the start of the searched string. If the Multilineproperty is set, ^ also matches the position following \n or \r.

When used as the first character in a bracket expression, ^ negates the character set.

^\d{3} matches 3 numeric digits at the start of the searched string.

[^abc] matches any character except a, b, and c.

$

Matches the position at the end of the searched string. If the Multilineproperty is set, $ also matches the position before \n or \r.

\d{3}$ matches 3 numeric digits at the end of the searched string.

.

Matches any single character except the newline character \n. To match any character including the \n, use a pattern like [\s\S].

a.c matches "abc", "a1c", and "a-c".

[]

Marks the start and end of a bracket expression.

[1-4] matches "1", "2", "3", or "4". [^aAeEiIoOuU]matches any non-vowel character.

{}

Marks the start and end of a quantifier expression.

a{2,3} matches "aa" and "aaa".

()

Marks the start and end of a subexpression. Subexpressions can be saved for later use.

A(\d) matches "A0" to "A9". The digit is saved for later use.

|

Indicates a choice between two or more items.

z|food matches "z" or "food". (z|f)ood matches "zood" or "food".

/

Denotes the start or end of a literal regular expression pattern in JScript. After the second "/", single-character flags can be added to specify search behavior.

/abc/gi is a JScript literal regular expression that matches "abc". The g (global) flag specifies to find all occurrences of the pattern, and the i (ignore case) flag makes the search case-insensitive.

\

Marks the next character as a special character, a literal, a backreference, or an octal escape.

\n matches a newline character. \( matches "(". \\matches "\".

Most special characters lose their meaning and represent ordinary characters when they occur inside a bracket expression. For more information, see "Characters in Bracket Expressions" in Lists of Matching Characters (Scripting).

  Metacharacters

The following table contains a list of multiple-character metacharacters and their behavior in regular expressions.

Metacharacter

Behavior

Example

\b

Matches a word boundary, that is, the position between a word and a space.

er\b matches the "er" in "never" but not the "er" in "verb".

\B

Matches a word non-boundary.

er\B matches the "er" in "verb" but not the "er" in "never".

\d

Matches a digit character.

Equivalent to [0-9].

In the searched string "12 345", \d{2}matches "12" and "34". \d matches "1", 2", "3", "4", and "5".

\D

Matches a nondigit character.

Equivalent to [^0-9].

\D+ matches "abc" and " def" in "abc123 def".

\w

Matches any of the following characters: A-Z, a-z, 0-9, and underscore.

Equivalent to [A-Za-z0-9_].

In the searched string "The quick brown fox…", \w+ matches "The", "quick", "brown", and "fox".

\W

Matches any character except A-Z, a-z, 0-9, and underscore.

Equivalent to [^A-Za-z0-9_].

In the searched string "The quick brown fox…", \W+ matches "…" and all of the spaces.

[xyz]

A character set. Matches any one of the specified characters.

[abc] matches the "a" in "plain".

[^xyz]

A negative character set. Matches any character that is not specified .

[^abc] matches the "p" in "plain".

[a-z]

A range of characters. Matches any character in the specified range.

[a-z] matches any lowercase alphabetical character in the range "a" through "z".

[^a-z]

A negative range of characters. Matches any character not in the specified range.

[^a-z] matches any character not in the range "a" through "z".

{n}

Matches exactly n times. n is a nonnegative integer.

o{2} does not match the "o" in "Bob", but does match the two "o"s in "food".

{n,}

Matches at least n times. n is a nonnegative integer.

* is equivalent to {0,}.

+ is equivalent to {1,}.

o{2,} does not match the "o" in "Bob" but does match all the "o"s in "foooood".

{n,m}

Matches at least n and at most m times. n and m are nonnegative integers, where n <= m. There cannot be a space between the comma and the numbers.

? is equivalent to {0,1}.

In the searched string"1234567", \d{1,3}matches "123", "456", and "7".

(pattern)

Matches pattern and saves the match. You can retrieve the saved match from theSubMatches collection in Visual Basic Scripting Edition (VBScript) or from array elements returned by the exec Method in JScript. To match parentheses characters ( ), use "\(" or "\)".

(Chapter|Section) [1-9] matches "Chapter 5", and "Chapter" is saved for later use.

(?:pattern)

Matches pattern but does not save the match, that is, the match is not stored for possible later use. This is useful for combining parts of a pattern with the "or" character (|).

industr(?:y|ies) is equivalent toindustry|industries.

(?=pattern)

Positive lookahead. After a match is found, the search for the next match starts before the matched lookahead text. The match is not saved for later use.

(?=.*\d).{4,8} applies a restriction that a password must be 4 to 8 characters long, and must contain at least one digit.

Within the pattern, .*\d finds any number of characters followed by a digit. For the searched string "abc3qr", this matches "abc3".

Starting before, instead of after, that match, .{4,8} matches a 4-8 character string. This matches "abc3qr".

(?!pattern)

Negative lookahead. Matches a search string that does not match pattern. After a match is found, the search for the next match starts before the matched lookahead text. The match is not saved for later use.

\b(?!th)\w+\b matches words that do not start with "th".

Within the pattern, \b matches a word boundary. For the searched string " quick ", this matches the first space. (?!th)matches a string that is not "th". This matches "qu".

Starting before that match, \w+ matches a word. This matches "quick".

\cx

Matches the control character indicated by x. The value of x must be in the range of A-Z or a-z. If it is not, c is assumed to be a literal "c" character.

\cM matches a CTRL+M or carriage return character.

\xn

Matches n, where n is a hexadecimal escape value. Hexadecimal escape values must be exactly two digits long. Allows ASCII codes to be used in regular expressions.

\x41 matches "A". \x041 is equivalent to "\x04" followed by "1", (because n must be exactly 2 digits).

\num

Matches num, where num is a positive integer. This is a reference to saved matches.

(.)\1 matches two consecutive identical characters.

\n

Identifies either an octal escape value or a backreference. If \n is preceded by at least ncaptured subexpressions, n is a backreference. Otherwise, n is an octal escape value if nis an octal digit (0-7).

(\d)\1 matches two consecutive identical digits.

\nm

Identifies either an octal escape value or a backreference. If \nm is preceded by at leastnm captured subexpressions, nm is a backreference. If \nm is preceded by at least ncaptured subexpressions, n is a backreference followed by literal m. If neither of those conditions exist, \nm matches octal escape value nm when n and m are octal digits (0-7).

\11 matches a tab character.

\nml

Matches octal escape value nml when n is an octal digit (0-3) and m and l are octal digits (0-7).

\011 matches a tab character.

\un

Matches n, where n is a Unicode character expressed as four hexadecimal digits.

\u00A9 matches the copyright symbol (©).

  Nonprinting Characters

The following table contains escape sequences that represent non-printing characters.

Character

Matches

Equivalent to

\f

Form-feed character.

\x0c and \cL

\n

Newline character.

\x0a and \cJ

\r

Carriage-return character.

\x0d and \cM

\s

Any white-space character. This includes space, tab, and form feed.

[\f\n\r\t\v]

\S

Any non–white space character.

[^\f\n\r\t\v]

\t

Tab character.

\x09 and \cI

\v

Vertical tab character.

\x0b and \cK

  Order of Precedence

A regular expression is evaluated much like an arithmetic expression; that is, it is evaluated from left to right and follows an order of precedence.

The following table contains the order of precedence of the regular expression operators, from highest to lowest.

Operator or operators

Description

\

Escape

(), (?:), (?=), []

Parentheses and brackets

*, +, ?, {n}, {n,}, {n,m}

Quantifiers

^, $, \anymetacharacter

Anchors and sequences

|

Alternation

Characters have higher precedence than the alternation operator, which, for example, allows "m|food" to match "m" or "food"

Creating the chatbot

posted Oct 18, 2014, 5:12 AM by Leroy Dyer   [ updated Oct 20, 2014, 5:32 AM ]

Chat bots


As you know, the chat-bot is a chatting robot that can understand what you are saying, analyse it and give you a suitable response. It's considered to be a serious branch in AI development, as the purpose of programming a chatbot is to help people obtain information. Examples include:

  • Selling chat bots: These help people to know item prices and offers.

  • Supporting chat bots: You may find this kind of chat bot on websites that offer products and services.

  • Help desk (information desk) 
    chat bots: You may find these in large libraries, websites or programs.
  • Entertaining chat bots: These are made for fun and chatting.

In 1966, Eliza, the first chat bot, was created by Joseph Weizenbaum. 

Artificial Intelligence (AI) technology provides techniques for developing computer programs that carry out a variety of tasks, simulating the intelligent way of problem-solving by humans. The problems that humans solve in their day-to-day lives are of a wide variety and in different domains. Although the domains are different and so are the methods, AI technology provides a set of formalism's to represent the problems as well as techniques for solving them. 

What AI technology provides us is what is described in the above sentences. Based on this, it is very difficult to precisely define the term "artificial intelligence." 

Creating a Chat-bot is a common task which people enjoy, we can all create something the same value as SIRI. the technology for Artificial intelligence has not surpassed this type of brain response although many make the claim to have completed creating an AI.  Here we shall build our own version of the AI's which are available.

  • Home Automation HomeSeer includes a built-in web server, giving you access to all your devices from anywhere in the world using any web browser. The program works great if you have ...
    Posted Oct 21, 2014, 6:57 PM by Leroy Dyer
  • The conceptnet module ConceptNet 5 comes largely from the hard work of hundreds of thousands of people who gave their time and knowledge for free. So ConceptNet is free as well, released under ...
    Posted Oct 21, 2014, 6:35 PM by Leroy Dyer
  • Scripting for Conceptual Respresentation Knowledge representation Knowledge representation is crucial. One of the clearest results of artificial intelligence research so far is that solving even apparently simple problems requires lots of knowledge. Really understanding ...
    Posted Oct 21, 2014, 6:46 PM by Leroy Dyer
Showing posts 1 - 3 of 5. View more »

Creating the interface

Building your chat bot

Before building your chat bot, you have to understand that any chat bot consists of three main parts:

  • Input text: This is where you are going to write what you want to say to your chat bot.
  • Sending button: This allows you to send your input to be analysed before getting the output.
  • Output text: This is where your chat bot is going to give its response

The most important part is the sending button, as it contains all of the processes that analyse your input before copying the result to the output. For this reason, I will call the sending button the Artificial Intelligence Base (AI Base).

The AI Base principles

Any dialogue has a beginning and ending, like saying "Hello"-"Hey"-"Good morning"-"Hi, how are you?" etc. We always hear these sentences when two people start talking. There are also other situations that don't need these sentences to begin, like "Excuse me, what is the time?" etc. On the other hand, we hear other sentences like, "I have to go now" - "bye, see you later" - "I'll call you later" - "looking forward to see you," etc. These sentences are usually used at the end of conversations.


1-5 of 5