**5.3 AIML categories for the evocation of humorous sentences**

The semantic space of the humorous chatbot evocative area has been created by using 3835 funny sentences downloaded from internet one-liners repositories onliners (2011) as well as the standard categories stored in the AIML knowledge base. Their retrieval is obtained through the definition and the use of specifically created AIML tags. As an example, the *relatedSentence* tag in the category template triggers the comparison between the user inputs with the sentences mapped in the semantic space belonging to the evocative area by choosing the sentence semantically closer to the user question. The *randomRelatedSentence* is defined in order to make possible for the chatbot to answer with one of the sentences which is semantically related to the user input.

Below we report the following example of category:

```
<category>
  <pattern>What do you think about *</pattern>
  <template>
   <randomRelatedSentence> <star/></randomRelatedSentence>
```
a Humoristic Chatbot 15

An Emotional Talking Head for a Humoristic Chatbot 333

The *addRiddle* tag has the effect to code a sentence introduced by the user as a vector in the semantic space by means of the folding-in procedure. The entire procedure is hidden to the user by the *think* tag. In this manner, the user will see only the chat-bot reaction to his joke.

In order to validate the humor recognition, two appropriate data set have been created. The former, called *DataSet1*, is composed of 100 humorous phrases extracted by ad-hoc selected web sites, characterized by the presence of a percentual of humoristic features, as shown in

**Features Percentual in DataSet1**

The latter, called *DataSet2*, is composed of 200 phrases, equally distributed between humorous and non-humorous sentences, where the non-humorous examples are always extracted from Internet and chosen among titles of newspapers, proverbs and sets definitions. The

> **DataSet Correct Classification No Recognition** DataSet1 66% 34% DataSet2 73% 27%

The results can be considered satisfactory. Moreover if with the humor recognition area cannot identify the humorous level of sentences written by the user, the dialogue can continue in a funny way. In fact, the chatbot exploits the semantic space, which allows retrieving amusing

The following results show a set of funny answers extracted by the chatbot exploiting the semantic space, and their semantic closeness to the user entry, compared to the answers given

Alice: Cocoa flavoring used in a variety of food products.

implemented algorithms well performed in humor recongition, as shown in table 2.

Alliteration 45% Direct Antinomy 10% Extended Antinomy 6% Indirect Antinomy 5% Adult Slang 6% No Feature 28%

<pattern>Listen this joke \*</pattern>

<addRiddle> <star/> </addRiddle>

Table 1. Humoristic Features Distribution in DataSet1

Table 2. Humor Recognition in the analyzed DataSets

User: What do you think about chocolate?

by standard Alice chatbot: Example 1:

EHeBby:

sentences so that the dialogue can continue in a funny manner.

<template> <humorlevel><star/> </humorlevel>

<category>

**6. Results**

table 1.

<think>

< /think> < /template> < /category>

```
</template>
< /category>
```
If the user question is:

User: What do you think about marriage?

The chat-bot will answer randomically in one of the following ways:

EHeBby: Marriage is an expensive way of getting your laundry done for free. EHeBby: Benjamin Franklin said "'Keep your eyes wide open before marriage, half shut afterwards"'. EHeBby: Love may be blind but marriage is a real eye-opener.

While the standard Alice chat-bot answers:

Alice: The state of being married; relation between husband and wife; married life.

The following dialogue shows a comparison between the answers given with the traditional pattern matching by the chat-bot Alice and the answers given by the evocative chat-bot using the <relatedSentence> tag.

User: You are ignorant. Alice: We can learn new things. EHeBby: Everybody is ignorant, only on different subjects User: what is the difference between woman and men? Alice: I think you already know the answer. I will search for it. EHeBby: Men always want to be a woman's first love. Women have a more subtle instinct; what they like to be is a man's last romance. User: See you tomorrow. Alice: Goodbye. EHeBby: Tomorrow is a mistery... User: Do you enjoy working? Alice: I enjoy working 24 hours every day. EHeBby: I only work to enjoy when I am not working User: My computer has the windows operating system. Alice: Where did he get it? EHeBby: What do Windows and a handgun have in common? Both are harmless while not loaded. User:Are you a pessimist or an optimist? Alice: Am I a pessimist or an optimist? Yes. EHeBby: A pessimist is one who makes difficulties of his opportunities and an optimist is one who makes opportunities of his difficulties. (Harry Truman)

#### **5.4 AIML categories for targeting**

The humorous chatbot is able to update its own sub-symbolic knowledge through a targeting process, which maps new acquired riddles in the semantic space. Targeting is obtained by means of the ad-hoc created AIML tag *addRiddle*, as shown in the following chunk of AIML code:

```
<category>
  <pattern>Listen this joke *</pattern>
  <template> <humorlevel><star/> </humorlevel>
    <think>
    <addRiddle> <star/> </addRiddle>
    < /think>
  < /template>
< /category>
```
The *addRiddle* tag has the effect to code a sentence introduced by the user as a vector in the semantic space by means of the folding-in procedure. The entire procedure is hidden to the user by the *think* tag. In this manner, the user will see only the chat-bot reaction to his joke.
