obtained writing an *ad hoc* AIML category:

```
<category>
  <pattern>WHAT DO YOU THINK ABOUT ROBOTS</pattern>
  <template>Robots will be able to buy happiness,
          but in condensed chip form!!
  </template>
< /category>
```
The *pattern* delimits what the user can say. Every time the *pattern* is matched, the corresponding *template* is activated.

#### **5.2 Example of humor recognition**

The recognition of humorous sentences is obtained using specific tag inserted into the template, as shown in the following categories:

```
<category>
  <pattern>CAN I TELL YOU A JOKE</pattern>
  <template>Yes you can</template>
< /category>
<category>
  <pattern>*</pattern>
    <that>YES YOU CAN</that>
  <template>
    <srai> <humorlevel> <star/> </humorlevel> <srai>
  </template>
< /category>
```
The second category is activated if the previous answer of the chatbot was "Yes you can" (according to the *that* tag behavior), and the *humorlevel* tag evaluates the level of humor of the sentence matched with the \* wildcard (i.e. what the user said). The humor level can assume three different values, *low*, *medium* and *high*. Depending on the humor level value, the category will recursively call, by means of the *srai* tag, another category, which will explicit an emotional tag, including the information needed to the talking head expression, and a *prosody* tag to produce the prosody file. In particular we have extended the AIML language to include three emotional tags *joy*, *anger* and *sadness*. Each of them also includes a mandatory *intensity* attribute. The value assigned to the attribute is a measure of how much that emotion combines to produce the overall emotional state of the chatbot. The called tag link the proper

a Humoristic Chatbot 13

An Emotional Talking Head for a Humoristic Chatbot 331

Fig. 5. TH reaction to a non-humorous sentence

Fig. 6. TH reaction to a rude joke

semantically related to the user input.

<category>

<template>

Below we report the following example of category:

<pattern>What do you think about \*</pattern>

<randomRelatedSentence> <star/></randomRelatedSentence>

**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

.m3g emotional file to the talking head, with the corresponding intensity level. In particular a low humor level will be associated to the *anger* tag, a medium level to a *sadness* tag and finally a high level to a *joy* tag. In a default behavior the emotional intensity for each of these emotions is fixed to a specific value. The following example shows the category related to a high humor level.

```
<category>
  <pattern>HIGH *</pattern>
  <template> <think>
   <prosody>
<star/>
</prosody>
    </think>
<joy intensity="080" />
  </template>
</category>
```
This is a dialogue example that shows the chatbot reaction to a funny joke, while in figure 4 is shown the corresponding TH expression:

User: Doctor gave a man six months to live. The man couldn't pay his bill, so he gave him another six months. EHeBby: Ehehe! You are very funny!! Good.. your joke is fantastic!!

Fig. 4. TH reaction to a funny joke

This other example shows the chatbot reaction to a non-humorous user sentence (see figure 5:

User: The book is on the table. EHeBby: I don't enjoy myself.. !! Your joke is stupid!!

The last example shows the chatbot reaction to a rude joke, while in figure 6 is shown a disgusted talking head expression:

User: 100,000 sperm and you were the fastest? EHeBby: What a disgusting joke!!

12 Will-be-set-by-IN-TECH

.m3g emotional file to the talking head, with the corresponding intensity level. In particular a low humor level will be associated to the *anger* tag, a medium level to a *sadness* tag and finally a high level to a *joy* tag. In a default behavior the emotional intensity for each of these emotions is fixed to a specific value. The following example shows the category related to a

This is a dialogue example that shows the chatbot reaction to a funny joke, while in figure 4 is

User: Doctor gave a man six months to live. The man couldn't pay

EHeBby: Ehehe! You are very funny!! Good.. your joke is fantastic!!

This other example shows the chatbot reaction to a non-humorous user sentence (see figure 5:

The last example shows the chatbot reaction to a rude joke, while in figure 6 is shown a

EHeBby: I don't enjoy myself.. !! Your joke is stupid!!

User: 100,000 sperm and you were the fastest?

his bill, so he gave him another six months.

high humor level.

<prosody>

</think>

</template> </category>

<pattern>HIGH \*</pattern>

shown the corresponding TH expression:

Fig. 4. TH reaction to a funny joke

disgusted talking head expression:

User: The book is on the table.

EHeBby: What a disgusting joke!!

<template> <think>

<joy intensity="080" />

<category>

<star/> </prosody>

Fig. 5. TH reaction to a non-humorous sentence

Fig. 6. TH reaction to a rude joke
