Human-Computer Speech Interaction: Project Report
Human-Computer Speech Interaction: Project Report
ON
Bachelors of Technology
In
INFORMATION TECHNOLOGY
(Batch: 2016-20)
Submitted by:
Name of student:
-SUBHAM DAS (50120707717)
-Sidharth Bisht (04820603116)
------------------------------------------------------------------------------------------------
----
CBPGEC College of Engineering,
Delhi, Jafarpur
1
Acknowledgement
The constant guidance and encouragement received from Dr. Pankaj Lathar
been of great help in carrying out the project work and is acknowledged with
reverential thanks.
Lastly, I would like to thank the almighty and my parents for their moral
support and my friends with whom I shared my day-to-day experience and
received lots of suggestions that improved my quality of work.
SUBHAM DAS
Date: 19/11/2019
2
TABLE OF CONTENTS
1. Title Page i
2. Acknowledgment ii
4. Abstract 4
5. Introduction 6
10. CONCLUSIONS 32
3
ARTIFICIAL INTELLIGENCE MARKUP LANGUAGE
Abstract
4
Introduction
Text communication nowadays takes huge part in peoples’ lives. Almost all age
groups for personal, family and social communication as well as for business
purposes use text messaging. Many companies use text messaging for
communication between employees.
5
humans . In a chatterbot, conversation usually occurs by the exchange of text
messages (as in a chat environment), and the chatterbot is organized to
provide features that allow the usage of natural language, such as dealing of
ambiguous situations and context-based message analysis (based on
Pragmatics).
Currently, the chatterbots has been applied in the most varied purposes. For
example, the entertainment chatterbots that are designed to entertain and to
amuse the user while maintaining a coherent conversation. For instance, the
chatterbot Susan is a virtual human that represents Dr. Susan Calvin from Isaac
Asimov's Robot Serie . There are chatterbots for mobile devices, such as the
ChattyBot for Android platform. Penny is a virtual assistant to solve problems
related to products and/or services offered by the Heat Gas Company Ltd.
Also, educational chatterbots emerge as an alternative to the teaching-learning
process and can be used to supplement the information provided in the
classroom and to clarify any doubts. For instance, the Einstein chatterbot is
responsible for to teach Physics and was developed by Artificial Life3 Company.
Along with the evolution of the chatterbots, researchers noticed that the
structure of chatterbots modeled using the Natural Language Processing (NLP)
would present itself as a complex task. In order to assist in such task, dedicated
technologies for chattebot making has been developed. Among these
technologies, Wallace [6] in collaboration with free software developers’
communities can be noticed. From 1995 to 2000, the Artificial Intelligence
Markup Language (AIML) is created, based on the concepts of Pattern
Recognition, or Matching Pattern technique. It is applied to natural language
modeling for the dialogue between humans and chatterbots that follow the
stimulus-response approach. For this purpose a set of possible user inputs is
modeled and, for each one of these sentences (stimuli), pre-programmed
answers were built to be shown to the user. The ALICE (Artificial Linguistic
Internet Computer Entity) chatterbot was the first to use the AIML language
and interpreter. In ALICE, the AIML technology was responsible for pattern
matching and to relate a user input with a response of the chatterbot’s
Knowledge Base (KB).
6
2. CHATTERBOTS AND PATTERN RECOGNITION
The proposal to make dialogs with computers dates back the 50´s, when the
British mathematician Alan Turing posed the question “Can machines think?”
in the article “Computing Machinery and Intelligence” [9]. Turing proposed a
test called the Imitation Game, now known as the Turing Test. The test is to
make the interlocutor unable to distinguish whether he/she is talking to a
person or a machine. In order to achieve it, the test is performed as follows:
• A digital computer, a human being and a judge (also human) are in
different and isolated rooms;
• The judge establishes a dialogue with the computer and the human being,
through a terminal, using a keyboard and video monitor;
• The computer passes the test if the judge is unable to tell whether the
answers come from the human being or como from the computer.
Thus, the Turing Test can be considered the forerunner of today´s chatterbots.
Laven [1] defines chatterbots as “... a program that attempts to simulate typed
conversation, with the aim of at least temporarily fooling the human into
7
thinking they were talking to another person”. Chatterbots can be classified
according to the techniques used in its development. Following this parameter,
three generations can be identified. The first generation is characterized by the
usage of NLP and Pattern Recognition´s basic techniques. In 1966 the ELIZA
[10] chatterbot was developed by Joseph Weizenbaum and it poses as an early
example of chatterbot design. During the 90's, the second generation
chatterbots were built and the Artificial Intelligence (AI) techniques were
applied, such as Artificial Neural Networks in conjunction with NLP techniques.
JULIA chatterbot is an example of a second generation chatterbot developed
by Michael Mauldin in 1994 [11]. The development of third-generation
chatterbots uses more advanced Pattern Recognition techniques. The
forerunner of this generation was the ALICE [6], developed in 2000 by Richard
Wallace in partnership with the AliceBot community. The ALICE´s KB is
implemented in AIML language. In [12] a current version of ALICE is available
for testing.
This work chooses the chatterbots based on third generation techniques. The
motivation is the fact that the usage of Pattern Recognition, in conjunction
with AIML, presents features such as:
8
sentence (stimuli) and the software makes an output (response) according to
the user input. And in this sequence the dialogue carries on [6]. The language
AIML is used to the development of chatterbots’KB, if the chatterbot adopts
the Pattern Recognition technique.
The ALICE was the first chatterbot with an AIML language implemented KB. Its
operation is divided in three steps. The first step is the question input by the
user. In the second step the system (i) performs word processing actions to fit
the user's input to a pre-established format by the designer and (ii) makes the
pattern matching between user input and the KB. Finally, one answer is
presented to the user in the third step [6].
AIML is based on basic units of dialogue, formed by user input patterns and
chatterbot responses. These basic units are called categories, and the set of all
categories makes the chatterbot KB. Among the AIML objects, the following
tags are worth citing: category, pattern and template. The
category tag defines a unit of knowledge (of dialogue) of the KB. The
pattern tag defines a possible user input, and the template tag sets the
chatterbot response for a certain user input.
9
3.1. Language´s Vocabulary
The AIML vocabulary consists of words, spaces and the special characters “*”
and “_”, known as wildcards. Wildcards are used to replace a string (words or
sentences). The AIML interpreter gives higher priority to categories containing
patterns that use the wildcard “_” than “*”. Then, the categories with the
wildcard “_” are analyzed first. For an AIML object/tag be well defined, it must
follow the XML standards. For example, object names cannot start with
numbers, they are case-sensitive (there is a distinction between uppercase and
lowercase letters) and blanks are not allowed.
In this work, the text into <pattern> tag is written in capital letters in KB.
This standard helps in the stage of standardization and simplification,
responsible for modifying the user's text in order to standardize the sentences.
For example, typing “Please inform how the pattern command works”, the
sentence is replaced by the question “PLEASE INFORM HOW THE PATTERN
COMMAND WORKS”. The transformation for capital letters simplifies the
search task, since all characters are in the same format.
<aiml> Tag
Table 1 shows the AIML code that illustrates a usage of the <aiml> tag. Each
AIML file begins with <aiml> tag and is closed by a </aiml> tag, in Line 1
and Line 8, respectively. This tag contains the version and encoding
attributes, as defined in Line 1. The version attribute identifies the AIML
version used in the KB. This example uses the version 1.0.1. If this attribute is
omitted, it will not result in program errors, but may cause confusion during
maintenance tasks or system upgrade. The encoding attribute identifies the
type of character encoding that will be used in the document. In this example,
UTF-8 is used. Within the scope <aiml> </ aiml> (lines 1-8) at least one
element <category> must exist.
10
Table 1. Example of AIML Code.
<category> Tag
The basic units of an AIML dialog are called categories. Each category is a
fundamental unit of knowledge contained in the chatterbot KB. A category
consists of (i) an user input, in the form of a sentence (assertion, question,
exclamation, etc), (ii) a response to user input, presented by the chatterbot,
and (iii) an optional context.
11
<pattern> Tag
The <pattern> tag contains a possible user input. There is just a single
<pattern> in each <category> tag, and it must be the first element to
be set. Also, the words are separated by single spaces, and wildcards can
replace parts of a sentence. In Table 1 the AIML code
<pattern> HELLO BOT </pattern>, defined in Line 3, indicates that the
chatterbot developer understood that the sentence “HELLO BOT” is a possible
user input.
<template> Tag
12
The AIML code of Table 2, lines from 1 to 6, models the following generic
dialog sequence:
User: I LIKE *
Bot: I like *
too.
From this template it is possible to the chatterbot answer that likes anything
that the user reports that he/she likes. Here is a possible conversation
between user and bot:
1 <category>
2 <pattern> I LIKE * </pattern>
<template>
3
I like <star/> too.
4
</template>
5 </category>
6
7 <category>
8 <pattern> A * IS A * </pattern>
9 <template>
10 When a <star index=”1”/> is not a <star index=”2”/>?
</template>
11
</category>
12
13
Table 2 also exemplifies the usage of <star> tag in the code from line 8 to 13,
corresponding to the following generic dialogue snippet:
User: A * IS A *
Bot: When a * qis not a *?
13
From this generic interaction model, the following dialogue is possible
between user and bot:
<srai> Tag
One of the most useful properties of AIML language is the possibility to target
different <pattern> models (user input) for a single <template> tag
(chatterbot response). Thus, AIML interpreter can efficiently look for an
answer from different types of user input. This possibility is obtained by using
the <srai> tag.
14
Table 3. Symbolic Reduction with <srai> Tag.
1 <category>
2 <pattern> WHO IS ALAN TURING? </pattern>
<template>
3
Alan Turing was a British mathematician, cryptographer,
and computer scientist often credited as the founder of
4 modern Computer Science.
</template>
5 </category>
6
7 <category>
8 <pattern> WHO IS ALBERT SABIN? </pattern>
9 <template>
Albert Sabin was the researcher who developed
10
the vaccine that is the main defense against polio.
11 </template>
</category>
12
13
<category>
14 <pattern> DO YOU KNOW WHO * IS? </pattern>
15 <template>
16 <srai> WHO IS <star/> </srai>
17 </template>
18 </category>
19
20
In the code of Table 3 there is a category prepared to talk about Alan Turing
(lines 1-6), and another category prepared to talk about Albert Sabin (lines 8-
13). The flowchart in Figure 1 illustrates the <pattern> commands of these
categories in A and B, respectively. The first category identifies the user's
question “WHO IS ALAN TURING?”, and the second category identifies the
question “WHO IS ALBERT SABIN?”.
Considering that the user can ask about the same researchers in different
ways, the application of the symbolic reduction technique begins with the
creation of a new category that models a varied way of asking about the
researchers. This category is encoded in lines 15 to 20 and it considers that the
user may ask the question as follows: “DO YOU KNOW WHO * IS?”, where the
wildcard “*” identifies the name of the person that the user wants to search. If
the user enters a text that matches the pattern defined in Line 16
(corresponding to C in Figure 1), the command <srai> WHO IS <star/>
</srai> (Line 18) redirects the chatterbot response for another category.
15
The <star/> command inserts the text captured by the wildcard in Line 16.
In D a test is made in order to check what value is stored in <star/>: ALAN
TURING or ALBERT SABIN. In E and F the category responsible for talking about
these people is called.
1 <category>
2 <pattern> BYE </patter>
<template> Goodbye friend! </template>
3
</category>
4
5
<category>
6 <pattern> BYE * </pattern>
7 <template> <srai> BYE </srai> </template>
8 </category>
9
16
Figure 2 and Table 4 present the AIML code of a conversation that uses this
technique. Line 7 of Table 4 and item A of Figure 2, define a user input pattern
with the following feature: a form of saying goodbye starting with the “Bye”
word, followed by the “*” wildcard representing any sentence. In this case, in
Line 8 of Table 4 (Item B of the flowchart in Figure 2), chatterbot redirects the
execution flow system for Line 2 with the <srai> BYE </ srai>
command.
Line 2 and C define the pattern “BYE”. Thus, the response in Line 3 and D will
be presented to user.
User: Industry
17
Bot: It is a development center.
If the user enters the word “FACTORY”, the chatterbot will redirect the
response by using the srai> INDUSTRY </srai> command in Line 11, to
the pattern defined in Line 2. Consequently, the answer defined in rows 3 to 5
will be presented to the user, resulting in the following iteration:
User: Factory
Bot: It is a development center.
Table 5. Synonyms Resolution with <srai> Tag.
1 category>
2 <pattern> INDUSTRY </pattern>
<template>
3
It is a development center.
4
</template>
5 </category>
6
7 <category>
8 <pattern> FACTORY </pattern>
9 <template>
10 <srai> INDUSTRY </srai>
</template>
11
</category>
12
13
18
_FAMILY (Line 9), FAMILY* (Line 16) and _FAMILY (Line 23). Observe the
combined use of special wildcard characters “*” and “_”.
1
<category>
2
<pattern> FAMILY </pattern>
3
<template>
4 Family is an important institution.
5 </template>
6 </category>
7
8 <category>
9 <pattern> _ FAMILY </pattern>
<template>
10
<srai> FAMILY </srai>
11
</template>
12 </category>
13
14 <category>
15 <pattern> FAMILY * </pattern>
16 <template>
17 <srai> FAMILY </srai>
</template>
18
</category>
19
20
<category>
21
<pattern> _ FAMILY * </pattern>
22 <template>
23 <srai> FAMILY </srai>
24 </template>
25 </category>
26
27
The keyword detection technique defines that, for any input sentence with the
keyword “FAMILY”, the redirection execution flow will occur to the pattern
defined in Line 2. It is performed by <srai> FAMILY </srai> in lines 11,
18 and 25. Thus, the response to be sent to the user will be “Family is an
important institution”, defined in lines 3 to 5.
Considering the code in Table 6, the conversation excerpts between the user
and the chatterbot are presented:
19
Bot: Family is an important institution.
1 <category>
2 <pattern> HI </pattern>
<template>
3
<random>
4
<li> Hi! Nice to meet you </li>
5 <li> Hello, How are you? </li>
6 <li> Hello! </li>
7 </random>
8 </template>
</category>
9
10
The following conversation excerpts may occur, considering the AIML code in
Table 7:
User: Hi
Bot: Hello!
User: Hi
Bot: How are you?
<set> and <get> Tags
The <set> and <get> AIML tags allow the chatterbot to work with variables.
There are predefined variables in the language, to store information such as
data about the chatterbot (e.g., name, gender, location). However the
20
variables can also be created by programmers, by defining a name and
initialization values.
The <set> tag is used to create variables, and must be within the scope of the
<template> tag.
Its syntax is as follows:
Table 8 illustrates an example of using the <set> tag. In this case, the name
informed by user in the sentence “MY NAME IS *”, Line 2, is identified by “*”
wildcard. After this, in Line 4 the
<set name= “nameUser”> <star/> </set> command stores, in the
variable nameUser, the text captured by the <star/> command, which in
this example is the name of the user.
Table 8. <set> Tag Usage Example.
1 <category>
2 <pattern> MY NAME IS * </pattern>
<template>
3
Hello <set name="nameUser"> <star/> </set>
4
</template>
5 </category>
6
The <get> tag returns the value stored by <set> tag, and should also be
within the scope of the <template> tag. Its syntax follows the form:
21
Table 9. <get> Tag Usage Example.
1 <category>
2 <pattern> GOOD NIGHT </pattern>
<template>
3
Good night <get name="nameUser"/>
4
</template>
5 </category>
6
Considering AIML code in tables 8 and 9, the following conversation may occur
between the user and bot:
The <that> tag tells the system to analyze the last sentence presented by the
chatterbot. It is noteworthy that to analyze the latest sequence of chatterbot is
important when the bot has held a question, and the user's response needs to
be contextualized in relation to this question. This tag must be within the
<category> scope.
Table 10 shows an example of AIML code that makes use of <that> tag. In
this example, the possible answers, “YES” or “NO” (defined in the patterns of
lines 9 and 17, respectively), can only be properly understood when compared
with the last question asked by the chatterbot: “Do you like movies?”. It is
asked in lines 3 to 5. The relationship between the chatterbot´s question “Do
you like movies?” and the user responses “YES” or “NO” is done in lines 10 and
18, with the use of <that> tag.
22
It is worth noting that when a category uses <that> tag, the chatterbot’s
answer will be displayed only if the AIML interpreter validate the <that>
content.
Following a possible conversation between the user and the bot is presented,
considering the code in Table 10:
1 <category>
2 <pattern> MAKE SOME QUESTION </pattern>
<template>
3
Do you like movies?
4
</template>
5 </category>
6
7 <category>
8 <pattern> YES </pattern>
9 <that> Do you like movies? </that>
10 <template>
Nice, I like movies too.
11
</template>
12
</category>
13
14
<category>
15 <pattern> NO </pattern>
16 <that> Do you like movies? </that>
17 <template>
18 OK. But I like movies.
</template>
19
</category>
20 s
23
<topic> Tag
The <topic> tag is used to organize subjects/topics that the chatterbot will
be able to talk. To achieve this, the categories that deal with the same subject
are grouped together, to improve the search for reasonable chatterbot’s
responses, to be sent to user. This tag allows the simulation of an important
feature of dialogues between humans, namely: to lead the conversation to a
specific subject, talk about this subject, and then identify when there is a
change of subject during the conversation.
The following excerpt of a possible conversation between the user and the bot
is presented, considering the code in Table 11:
24
User: I like it so
much! Bot: I like
flowers too.
Table 11. <topic> Tag Usage Example.
1 <category>
2 <pattern> LET TALK ABOUT FLOWERS. </pattern>
<template>
3
Yes <set name="topic">flowers</set>
4
</template>
5 </category>
6
7 <topic name="flowers">
8 <category>
9 <pattern> * </pattern>
10 <template>
Flowers have a nice smell.
11
</template>
12
</category>
13
14
<category>
15 <pattern> I LIKE IT SO MUCH! </pattern>
16 <template>
17 I like flowers too.
18 </template>
</category>
19
</topic>
20
<think> Tag
The content of <think> tag is processed by the chatterbot, but not displayed
to user. This tag is used for data processing, conditional statements and tests
that should not be visible to user. In Table 12, an AIML code example of this
tag is displayed. In Line 4 the chatterbot stores the user name in nameUser
variable, without the user having knowledge of this assignment, once the
<set> command is in the <think> tag scope.
Table 12. <think> Tag Usage Example.
1 <category>
2 <pattern> MY NAME IS * </pattern>
<template>
3
<think> <set name=”nameUser”> * </set> </think>
4
</template>
5 </category>
6
25
<condition> Tag
The <condition> tag is used whenever (i) there is a list of possible answers
to be presented to the user, and (ii) the choice of the most appropriate
response relies on the analysis of a particular variable that was updated during
the conversation between the user and the chatterbot. The <condition>
semantics is equivalent to the case command semantics, found in many
programming languages. This tag takes as parameters the variable name and
the value to be compared, as follows:
<condition name=“variableName”
value=“variableValue”/>
Where variableName is the name of the variable to be checked, and
variableValue represents the value that must be compared. If the value
matches, the code block delimited by <condition> tag is executed.
26
<bot> Tag
AIML allows developer to define some chatterbot´s properties with <bot>
tag, and such properties can be seen by the user during the conversation.
Table 14 presents an AIML code using this tag. In this example, when the
chatterbot detects the user input “BOT'S PROPERTIES”, as defined in Line 2, it
shows some of its features (see lines 3-11).
1 <category>
2 <pattern> BOT’S PROPERTIES </pattern>
<template>
3
<bot name="age"/>
4
<bot name="gender"/>
5 <bot name="location"/>
6 <bot name="nationality"/>
7 <bot name="birthday"/>
8 <bot name="sign"/>
<bot name="botmaster"/>
9
10 </template>
</category>
11
12
27
variable is defined for each ambiguous category, and its value identifies the
dialog’s intention. Therefore, in an ambiguous user input, the value of the
control variable is checked and the real user intention with some degree of
truth can be inferred based on such value.
Table 15 shows two categories with the word “LIE” in the sentence of the
<pattern> tag. The category implemented in lines 1 to 7 treats “LIE” as
"mislead”. On the other hand, the category defined in lines 9 to 15 treats “LIE”
as "down". To address this ambiguity issue the control_lie variable is
defined, and may take the values not_true or not_stand, depending on
the conversation contex. These values are assigned during the conversation
with the user. When the chatterbot detects an ambiguous keyword, it uses the
control_lie value to establish the user intention.
Table 15. Example of Ambiguity Treatment.
1 <category>
2 <pattern> I TOLD YOU THE TRUTH </pattern>
<template>
3
Thank you!
4
<think> <set name=”control_lie”> not_true </set> </think>
5 </template>
6 </category>
7
8 <category>
9 <pattern> I WANT TO SLEEP </pattern>
10 <template>
11 Good night!
12 <think> <set name=”control_lie”> not_stand </set> </think>
</template>
13
</category>
14
15
<category>
<pattern> WHAT DO YOU THINK ABOUT LIE? <pattern> 161
17 <template>
18 <condition name=”control_lie” value=”not_true”>
19 Why did you lie to me?
20 </condition>
<condition name=”control_lie” value=”not_stand”>
21
It is better you go to bed.
22 </condition>
23 </template>
24 </category>
25
26
27
28
In Figure 3 the flowchart illustrates this scenario. A, B and C in flowchart (lines
1-7 in Table 15) indicate that, if _lie, and will present the sentence “Thank
you” to the user. On the other hand, D, E and F (lines 9-15) indicate that, if the
user enters the sentence “I WANT TO SLEEP”, the chatterbot will assign the
value not_stand to control_lie, and will submit the sentence “Good
night” to the user.
In Table 15, the ambiguity treatment is implemented in the lines 17 to 27. Also,
it is depicted in
G, H and I in Figure 3. In this example, if the user enters the user enters the
sentence “I TOLD YOU THE TRUTH”, the chatterbot will assign the value
not_true to control the sentence “WHAT DO YOU THINK ABOUT LIE?” (as
defined in Line 18), the answer presented to the user will depend of the
control_lie variable current value. If control_lie is not_true (Line
20 in Table 15, Item H in Figure 3), the bot will show the sentence “Why did
you lie to me?” to the user. If it is not_stand (Line 23 in Table 15, Item H in
Figure 3), the bot will show the phrase “It is better you go to bed.” to the user.
29
5. COMPUTER SYSTEMS FOR CHATTERBOTS
IMPLEMENTATION
The AIML is an interpreted language. Interpretation is one of the processes by
which the source code of a program is translated into the machine code, to be
able to run on a computer. In the interpreting process, the interpreter program
repeatedly performs the following sequence, for each source code line: (1) it
captures the program’s source code line; (2) it checks and analysis the line,
both syntactically and semantically; (3) if there are no errors, it translates to a
binary language for further execution.
The computer systems that assist the chatterbot implementation, based on the
AIML language, have an interpreter in its structure. However, these systems
differ and can be classified according to the following categories: AIML editors
and chatterbots’ development platforms. In the next subsections, some
examples of such software are introduced and described.
30
the botmaster to write comments at the beginning of each AIML file. The
botmaster is the individual who manages the chatterbot to perform
actions such as analysis of the log conversations, the detection of errors
and inconsistencies in the KB, the creation of new rules on questions that
are not answered by bot, among others.
31
Microsoft Windows and Web systems. Since the tool is distributed as a
DLL (Dynamic Link Library) it is possible to attach it in encapsulated form
project.
6. CONCLUSIONS
This work highlighted the importance of the conversational software
development, more specifically the chatterbots as computational agents to
establish natural language dialogs between humans and machines. Among the
chatterbot development theories, the Pattern Recognition was outlined, and it
is based on representative stimulus-response blocks. The AIML language is one
of the most widely used technologies for chatterbots implementation that
combines the technical and theoretical Pattern Recognition‘s infrastructure in
its development.
32