Woldia University: Department of Computer Science
Woldia University: Department of Computer Science
Read
Content…
Reasoning with large knowledge bases
Integrating special-purpose reasoning engines
Analogical reasoning
Other topics TBD
Conversational Interface
Introduction
Basics of Conversational Assistants
Survey of historical Efforts
Introduction to first set of tools
Image formation
Introduction
Binary image processing
Color and color segmentation
Content…
formation
Region segmentation
Edge, contour, Hough transform and texture
3D Geometry, claiberation, pose and stereo
Lighting and application
Motion and Tracking
Lists
In a list, first element is expected to be a
function which uses remaining elements as
arguments
List is sequence of atoms or other lists
separated by blank.
Example
( i am a list)
(a ( a b c) d e fgh)
(father tom ( susan bill joe))
(sun mon tue wed thur fri sat)
()
Artificial Intelligence Programming
Lists
In a list, first element is expected to be a
function which uses remaining elements as
arguments
List is sequence of atoms or other lists separated by
blank and enclosed in parentheses
Example
( i am a list)
(a ( a b c) d e fgh)
(father tom ( susan bill joe))
(sun mon tue wed thur fri sat)
()
Artificial Intelligence Programming
Lists
The cons Record Structure
A cons is a record structure containing two
components called the car and the cdr
Cons cells or cons are objects are pairs of
values that are created using the function
cons
The cons function takes two arguments and
returns a new cons cell containing the two
values. These values can be references to any
kind of object.
Artificial Intelligence Programming
Lists
The cons Record Structure
The car function is used to access the first value
and the cdr function is used to access the second
value.
Artificial Intelligence Programming
Lists
The cons Record Structure
Although cons cells can be used to create lists, the
list function is rather used for creating lists in LISP
The first and rest functions give the first element
and the rest part of a list.
Artificial Intelligence Programming
Lists
LISP allows to assign properties to symbols
A property list is implemented as a list with
an even number (possibly zero) of
elements
When a symbol is created, its property list
is initially empty. Properties are created by
using get within a setf form
Artificial Intelligence Programming
Lists
Artificial Intelligence Programming
Reading Input from Keyboard
The read function is used for taking input
from the keyboard. It may not take any
argument.
For example, consider the code snippet −
(write ( + 15.0 (read)))
Artificial Intelligence Programming
Macros
A macro is a function that takes an s-expression as arguments
and returns a LISP Form, which is then evaluated.
Used to extend the syntax of standard
LISP
named macro is defined using another macro named defmacro
(defmacro macro-name (parameter-list)
"Optional documentation string."
body-form)
Artificial Intelligence Programming
Global Variables
Global variables are generally declared
using the defvar construct
(defvar x 234)
(write x)
As there is no type declaration for variables
in LISP, you need to specify a value for
a symbol directly with the setq construct
>(setq x 10)
The symbol-value function allows you to
extract the value stored at the symbol
storage place
Artificial Intelligence Programming
Global Variables
(setq x 10)
(setq y 20)
(format t "x = ~2d y = ~2d ~%" x y)
(setq x 100)
(setq y 200)
(format t "x = ~2d y = ~2d" x y)
Artificial Intelligence Programming
Local Variables
Like the global variables, local variables
can also be created using the setq
construct.
There are two other constructs - let and
prog for creating local variables.
Artificial Intelligence Programming
Local Variables
Example:
(prog ((x '(a b c))(y '(1 2 3))(z '(p q 10)))
(format t "x = ~a y = ~a z = ~a" x y z))
Constants are declared using the defconstant
construct.
(defconstant PI 3.141592)
(defun area-circle(rad)
(terpri)
(format t "Radius: ~5f" rad)
(format t "~%Area: ~10f" (* PI rad rad)))
(area-circle 10)
Artificial Intelligence Programming
Operator
An operator is a symbol that tells the
compiler to perform specific mathematical
or logical manipulations
The operations allowed on data could be
categorized as −
Arithmetic Operations
Comparison Operations
Logical Operations
Bitwise Operations
Artificial Intelligence Programming
Program Control
require the programmer specify one or more conditions
to be evaluated or tested by the program
(setq a 10)
(cond ((> a 20)
(format t "~% a is greater than 20"))
(t (format t "~% value of a is ~d " a)))
Artificial Intelligence Programming
Program Control
Artificial Intelligence Programming
Program Control
Artificial Intelligence Programming
Functions in LISP
The macro named defun is used for
defining functions
Syntax:
(defun name (parameter-list) "Optional
documentation string." body)
Artificial Intelligence Programming
Functions in LISP
Artificial Intelligence Programming
Array in LISP
LISP allows you to define single or multiple-
dimension arrays using the make-array
function.
(setf my-array (make-array '(10)))
(aref my-array 9) to access array
Artificial Intelligence Programming
Array in LISP
Artificial Intelligence Programming
Structure
Structures are one of the user-defined data
type, which allows you to combine data items
of different kinds.
The defstruct macro in LISP allows you to
define an abstract record structure
(defstruct book
title
author
subject
book-id
)
Artificial Intelligence Programming
Structure
Artificial Intelligence Programming
Structure
Artificial Intelligence Programming
Common Lisp Object System (CLOS)
Common LISP predated the advance of
object-oriented programming by couple of
decades
The defclass macro allows creating user-
defined classes. It establishes a class as a
data type. It has the following syntax −
Recursion in LISP
Recursion is a programming technique in
which a function calls itself repeatedly until
a certain condition is met
Syntax
(defun function_name(parameters);
body-of-function
if(base-condition)
return;
body-of-function
function_name(parameters)
)
Artificial Intelligence Programming
Recursion in LISP
(defun power (x y)
( if (= y 0)
1
(* x (power x(- y 1)))
)
)
Recursion in LISP
(defun factorial (n)
(if (= n 0)
1
(* n (factorial (- n 1))) ) )
Recursion in LISP
(* 5 (factorial 4))
(* 5 (* 4 (factorial 3)))
(* 5 (* 4 (* 3 (factorial 2))))
(* 5 (* 4 (* 3 (* 2 (factorial 1)))))
(* 5 (* 4 (* 3 (* 2 (* 1 (factorial 0))))))
(* 5 (* 4 (* 3 (* 2 (* 1 1)))))
(* 5 (* 4 (* 3 (* 2 1))))
(* 5 (* 4 (* 3 2)))
(* 5 (* 4 6))
(* 5 24)
---> 120
Artificial Intelligence Programming
(sort '(7883 9099 6729 2828 7754 4179 5340 2644 2958 2239)
(lambda (x y) (< (modulo x 100) (modulo y 100))))
Result: (2828 6729 2239 5340 2644 7754 2958 4179 7883 9099)
Artificial Intelligence Programming
Thank You!
Artificial Intelligence Programming
parse-html
(net.html.parser:parse-html "<html><body>Hello</body></html>")
89
Introduction
90
Example of Dialogue Systems
Saplen system 1997 [R. López-Cózaret et
al. Eurospeech1997]: Food ordering
system
Let’s Go! Bus Information System [Raux
et. al. Eurospeech 2000]
ITSpoke: Intelligent Tutoring SDS [Litman
and Silliman HLT-NAACL 2004]
91
Dialogue System Architecture
92
Parser
The parser parses the word sequence
into a set of semantic frames
Parser
Phoenix - Parser
Dialog Task Specification
Voice-based Chatbot
Input the corpus
Perform data pre-processing on corpus:
Text case [upper or lower] handling
Chatbots…
Voice-based Chatbot
Tokenization
Stemming
Generate BOW [Bag of Words]
Generate one hot encoding for the target column
Design a neural network to classify the words with
TAGS as target outputs
Design a function to speak the output text
Design a function for listening to the user and
convert the spoken words into text
Design a chat utility as a function to interact with
the user till they call a “quit”
Run the chat utility function
Question Answering
What is Question Answering?
3/13/2023
Question and Answering
Question Normalization
Drops punctuation and quotation
marks
Stems verbs and nouns
Knowledge Miners:
Answer
searches from
Candidates unstructured data
Knowledge Annotators:
they provide semi-
structured information,
ex. Gazetteer web service
Answer Extraction
Two ways to extract answers
Answer Type analysis
Pattern Learning approach
Document retrieval
Question analysis
Answer extraction
Issues with Candidates
Answer Relevence
Answer Similarity
Algorithm
Answer :-
P(correct(William J. Clinton)) = 0.758
P(correct(Bill Clinton)) = 0.755l
P(correct(George W. Bush) = 0.617
Example …
P(correct(Bill Clinton)|correct(William
J. Clinton)) = 0.803
P(correct(George W.
Bush)|correct(William J. Clinton)) =
0.617
Artificial Intelligence Programming
Prolog
Prolog as the name itself suggests, is the
short form of LOGical PROgramming. It is a
logical and declarative programming
language
It is one major example of the fourth
generation language that supports the
declarative programming paradigm
involve symbolic or non-numeric
computation
Which is the main reason to use Prolog as the programming
language in Artificial Intelligence, where symbol
Artificial Intelligence Programming
Prolog
Prolog language basically has three
different elements −
Facts − The fact is predicate that is true,
for example, if we say, “Tom is the son of
Jack”, then this is a fact.
Rules − Rules are extinctions of facts that
contain conditional clauses. To satisfy a rule
these conditions should be met
Artificial Intelligence Programming
Prolog
for X to be the grandfather of Y, Z should be a parent of Y and X
should be father of Z fundamental tasks
Applications of Prolog
Intelligent Database Retrieval
Natural Language Understanding
Specification Language
Machine Learning
Robot Planning
Automation System
Problem Solving
Artificial Intelligence Programming
Official Website
http://www.gprolog.org/
Syntax
The syntax for facts is as follows −
relation(object1,object2...).
Artificial Intelligence Programming
Rules
We can define rule as an implicit
relationship between objects.
facts are conditionally true.
when one associated condition is true,
then the predicate is also true
Lili is happy if she dances.
Tom is hungry if he is searching for food.
Jack and Bili are friends if both of them love to
play cricket.
will go to play if school is closed, and he is free.
Artificial Intelligence Programming
Artificial Intelligence Programming
Artificial Intelligence Programming
Knowledge Base
There are three main components in
logic programming − Facts, Rules and
Queries.
These three if we collect the facts and
rules as a whole then that forms a
Knowledge Base.
the knowledge base is a collection of
facts and rules.
Artificial Intelligence Programming
Knowledge Base
Artificial Intelligence Programming
Relations in Prolog
Coming soon