Table of Contents | ||||
---|---|---|---|---|
|
...
Note |
---|
Although visual support is key because of the reasons listed above, it is also only meant to be just that: support that facilitates conducting a conversation with your conversational agent. Conversational interaction should In this project, you should design conversational interaction to be the primary modality of interaction! Requirement: You should develop a webpage which facilitates conversational interaction; in other words, your webpage design should recognize that speech-based interaction is the primary modality of interaction. As such, you should avoid using input-based interactive webpage elements such as forms, dropdown menus, or other elements focused very much on user input via a webpage. |
...
Using Prolog to build HTML
...
in our
...
agent
It is the visual support. While the way in which visuals are modelled in the agent may look complicated, there is nothing that goes far beyond basic HTML. We utilize a combination of Prolog, HTML and Bootstrap to generate dynamic webpages. Prolog rules are used to add a condition to a webpage (i.e. webpage X is shown when Clause Y is true). By means of these Prolog rules, we generate our HTML code. The HTML code is treated as a Prolog atom, essentially a string, that we manipulate with Prolog important to be able to synchronize the conversational interaction and the visuals displayed on the webpage shown while talking. The MARBEL agent manages the dialog, and for that reason also is the logical place to locate the control over the visual elements. This agent uses a renderPage(Html)
action in the dialog_generation.mod2g
module to render a webpage; when performing this action, the Prolog variable Html
therefore should be instantiated with HTML webpage code. All we need to know before we can use this action, is how to create this HTML page in Prolog.
The basic idea is that we will create essentially a single string that consists of the HTML webpage code. We will utilize a combination of Prolog, HTML and Bootstrap to generate the code for dynamic webpages. Prolog rules are used to generate our HTML code. In other words, the HTML code represented as a Prolog atom, essentially a string, is manipulated with Prolog. So what does that look like? We will first take a look at how to construct some very basic HTML code, then explain how we can add more complicated HTML code that is also using Bootstrap components, and, finally, how we can piece together these components into a complete webpage.
Generating basic HTML elements
An HTML page consists of HTML elements. HTML elements consists of HTML tags that are used to organize content on that page. Tags often come in pairs of a start and end tag. Basic HTML tags, for example, are the tags <p>YOUR PARAGRAPH TEXT HERE</p>
that defines an HTML paragraph, the <h1>...</h1>
defining a large heading, <b>...</b>
defining bold text, etc. The idea to generate basic HTML code is very simple: Simply use single quotes '...'
to generate such an element. The table next lists a few simple examples:
HTML Element | HTML code | Prolog code (single quoted atom) |
---|---|---|
Large heading |
|
|
Paragraph |
|
|
Bold text |
|
|
Note |
---|
It is very important to use the right quote symbols in your code. So, for example, ' is not the same as the |
By means of these and generate with the rule. The HTML code is represented in Bootstrap format, which is also clearly illustrated by examples below or on Bootstrap's documentation website (Bootstrap Documentation).
Note |
---|
Prolog Advice: To manipulate strings and atoms in Prolog it is useful to look at documentation of the following built-in functions: atomic_list_concat, atom_concat, string_concat, append, and maplist here: https://www.swi-prolog.org/. The predicate applyTemplate is a defined predicate that will be explained below. |
Prolog rules are used to add a condition to a webpage (i.e. webpage X is shown when Clause Y is true).
A Quick Prolog Walkthrough
...
Using Prolog rules in the html.pl
file
...