Skip to content

Parameters

Definition

<query predicate="some_predicate">
Attribute Type Description
predicate string The predicate of the question for which this query is valid

Currently this element supports only wh questions.

Parents

Behaviour

A query can be defined in domain.xml in order to be queried using <invoke_domain_query>.

There are currently four different, mutually exclusive, types of queries: Implications, Random Selection, Enumeration and Random Enumeration. If there are more than one query defined for a predicate or question it is undefined which one will be applied.

See also <iterator>

Implications

This type defines the query in the form of one or more <implication> elements. If the antecedent proposition holds, TDM will assume the consequent proposition. NB! that the implications will need to be exhaustive. If no antecedent matches, there will be an error.

Random Selection

By using a <select_at_random> element, propositions formed using the predicate if the query element and the individuals which are the children of this element, will be assumed at random. This means that two consecutive calls to the query may give the same result.

Enumeration

By using an <enumerate> element, propositions formed using the predicate if the query element and the individuals which are the children of this element, will be assumed in order. When all the elements have been enumerated, enumeration will restart from the beginning. It is possible to check if an enumeration has more items by using the <condition> has_more_items element.

Random Enumeration

By using the randomize="true" attribute of the <enumerate> element, propositions will be enumerated in random order.

Examples

A query that will select a greeting based on time of the day

The example uses implications.

<query predicate="greeting">
    <implication>
        <antecedent predicate="time_of_day" value="am"/>
        <consequent predicate="greeting" value="good morning!"/>
    </implication>
    <implication>
        <antecedent predicate="time_of_day" value="pm"/>
        <consequent predicate="greeting" value="good evening!"/>
    </implication>
</query>>

A query that will select a direction at random.

  <query predicate="way_to_look_random">
    <select_at_random>
      <individual value="left"/>
      <individual value="right"/>
    </select_at_random>
  </query>

A query that will enumerate the four seasons

If called four times, all seasons will be enumerated, in order of definition.

  <query predicate="season_to_consider">
    <enumerate>
        <individual value="spring"/>
        <individual value="summer"/>
        <individual value="autumn"/>
        <individual value="winter"/>
    </enumerate>
  </query>

A query that will enumerate the four seasons randomly

If called four times, all seasons will be enumerated, but in random order.

  <query predicate="season_to_consider">
    <enumerate randomize="true">
        <individual value="spring"/>
        <individual value="summer"/>
        <individual value="autumn"/>
        <individual value="winter"/>
    </enumerate>
  </query>


Last update: October 25, 2023