Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. user edges: these edges tell the system to wait for a certain event before traversing them. If a state has one outgoing edge that is a user edge, then all outgoing edges of that state will be user edge. this property make a state a user waiting state that blocks the execution of the action until the user says any of the events in the outgoing user edges.
  2. system edges: these edge when traversed make the system say a particular utterance. System edges take time to be traversed: the time taken by the associated system utterances to be played (one can configure to ignore this waiting but the default is to wait for a system edge to finish playing the associated animation).
  3. condition edges: these edges are used to connect state when we don't want to wait for an event and we don't want the virtual human to say anything.
  4. wait edges: an edge that does nothing but wait a specific amount of time.

...

  1. an information state update. That is, changing the value of some variable in the information state when the node containing the effect is entered.
  2. a reward. A reward can be a numeric constant or an expression returning a number. When the state containing a System edges can be of three types:
    1. a normal speech act given as a constant string. The DM will simple send a request to the NLG to create surface text for the given speech act.
    2. an interruptible speech act. This is a system line for which we are ready to receive an interruption. That is, if the user says something we except to prioritize what the user says and interrupt if we have an interruption policy in place that generates an interrupt request.
    3. an evaluation system action: this action has as argument an expression that needs to be evaluated and its result must be a string to be handled like the normal case above.
  3. condition edges: these edges are used to connect state when we don't want to wait for an event and we don't want the virtual human to say anything.
  4. wait edges: an edge that does nothing but wait a specific amount of time.

Anchor
effects
effects
Nodes contain effects. There are three types of effects:

  1. an information state update. That is, changing the value of some variable in the information state when the node containing the effect is entered.
    1. like an assignment or an assertion.
  2. a reward. A reward can be a numeric constant or an expression returning a number. When the state containing a reward is reached, the system achieves the associated reward. A sub-dialogue can have multiple rewards associated to multiple states.
  3. swap out the current sub-dialog (force the sub-dialogue to go from ACTIVE to DORMANT state).).
  4. a request to interrupt the current system action
  5. sending an internal message
  6. sending a VH protocol message

In the example of sub-dialogue given here the red nodes are states with effects. These states can be inspected to display the particular effects associated with them. This graphical representation of a sub-dialogue is generated for debug purposes, it's not used to edit the sub-dialogue, just to check that the intended form is correctly generated from the provided information.

...

Implications are used to define conditional assignments. An implication takes 2 or 3 arguments: a condition and 1 or 2 assignments. For example, imply(==(var1,2),assign(var1,3),assign(var2,4))executes assign(var1,3) if ==(var1,2) is true, otherwise it executes assign(var2,4). the third argument (the else part) is optional and can be omitted.

Special functions (aka Custom functions)

Special functions can be added by implementing the interface edu.usc.ict.nl.kb.cf.CustomFunctionInterface. Special functions are a way to define new functions by associating arbitrary Java code to a certain string. At the moment the following special functions are defined:

  • Hash functions:
    • newMap(): this function creates a new hash table.
    • clear(var): empties the hash table stored in the variable var.
    • get(var1,var2): returns the value associated to the key var2 in the hash table var1.
    • set(var1,var2,var3): sets the value var3 to the key var2 in the hash table var1.
  • List functions:
    • get(var1,var2): returns the value associated to index var2 in list var1 (index can also be the string "random" in that case the function returns a random element of the list).
    • exists(var1,var2,var3): returns true iff there exists an element of var2 for which var3 is true when substituted to the variable named var1.
    • intersect(var1,var2): computes the intersection between the two given collections.
    • len(var1): returns the length of the given list.
    • removeIf(var1,var2,var3),removeIfNot(var1,var2,var3): returns the list formed by the elements of the list var2 for which var3 is true when substituted to the variable named var1.intersectthe boolean expression var3 is false (,true). var1 is the loop variable.
    • set(var1,var2,var3): sets the value var3 at position var2 in list var1.
    • subtract(var1,var2): computes the intersection between the two given collections.
    • len(var1): returns the length of the given list.
    • removeIfremoves all the elements in the list var2 from the list var1.
    • union(var1,var2): computes the union of the two lists.
  • String functions:
    • match(var1,var2,var3),removeIfNot(var1,var2,var3): returns the list formed by the elements of the list var2 for which the boolean expression var3 is false (,true). var1 is the loop variable.
    • set(var1,var2,var3): sets the value var3 at position var2 in list var1.
    • subtract(var1,var2): removes all the elements in the list var2 from the list var1.
    • union): maps to the String.matches(regexp) Java method. var1 must be a string or evaluate to one. var2 must be a string or evaluate to one. The content of var2 must be a valid Java regular expression.
    • concatenate(var1,...,varn): concatenates the provided strings.
  • Time functions:
    • currentTime(): returns the current time in milliseconds since 1/1/1970.
    • getLastTimeMark(var1): returns the last time (in milliseconds since 1/1/1970) the current operator was in state var1, where var1 can be either "DONE" or "ENTER".
    • getLastTimeMark(var1,var2): computes the union of the two lists.
    String functions:
    • matchreturns the last time the current operator said the speech act var2. Var1 must be "SAY".
  • Ordering:
    • follows(var1,var2): maps to the String.matches(regexp) Java method. var1 must be var1 is a string or evaluate to one. var2 must be a string or evaluate to one. The content of var2 must be a valid Java regular expression.
    • concatenate(var1,...,varn): concatenates the provided strings.
  • Time functions:
    • currentTime(): returns the current time in milliseconds since 1/1/1970.
    • getLastTimeMark(var1): returns the last time (in milliseconds since 1/1/1970) the current operator was in state var1, where var1 can be either "DONE" or "ENTER".
    • getLastTimeMark(var1,var2): returns the last time the current operator said the speech act var2. Var1 must be "SAY".
  • Ordering:
    • follows(var1,var2): var1 is a string constant (or a variable with a string constant as value) and var2 is a boolean (or a variable with a boolean value). Var2 is optional, by default it's false. The function returns true if the operator named by var1 has already been executed. If var2 is true, then the function returns true only if the operator named by var1 has already been completed (that is, any final state in the operator has been executed (as opposed to being swapped out before completion)).
  • Topic:
    • isCurrentTopic(var): returns true if the provided string or variable containing a string matches one of the topics of the sub-dialogue currently active.
    • isLastNonNullTopic(var): similar to isCurrentTopic but executes the match on the last non null topic. That is, if currently there are no active networks, this will match the value of var with the topic of the last active network.
  • Numbers:
    • min(var1,...,varn),max(var1,...,varn): returns the min/max of the given list of numbers.
    • random(var): generates a random number from 0 to the value in var-1. var doesn't have to be a variable but can also be a numeric constant.
    • round(var): returns the output of java.lang.Math.round applied to the input argument when converted to a float value.
  • Debug:
    • trace(var): prints a java stack trace when var is evaluated.
    • print(var): prints the value of var when the expression is evaluated by the system.
  • Other:
    • if(var1,var2,var3): return the evaluation of var2 if var1 evaluates to true, if var1 evaluates to false it returns the evaluation of var3. null if var1 returns null.
    • known(expr): this returns true of the provided expression evaluates to anything but the NULL value.
    • numToString(var): returns the string representation of the given number. For example, it returns "twenty three" for 23.
    • hasBeenInterrupted(var): returns true if the current operator has been swapped out by an interruption.
    • isInterruptible(): returns true if the current transition being executed is interruptible (by the user).
    • isQuestion(var): returns true if the provided var evaluates to a string that contains the string "question". This maps to the method edu.usc.ict.nl.io.NLU.isQuestion overwrite with your own specific NLU class if you want to customize or write a new custom function.
Quotation

...

    • constant (or a variable with a string constant as value) and var2 is a boolean (or a variable with a boolean value). Var2 is optional, by default it's false. The function returns true if the operator named by var1 has already been executed. If var2 is true, then the function returns true only if the operator named by var1 has already been completed (that is, any final state in the operator has been executed (as opposed to being swapped out before completion)).
  • Topic:
    • isCurrentTopic(var): returns true if the provided string or variable containing a string matches one of the topics of the sub-dialogue currently active.
    • isLastNonNullTopic(var): similar to isCurrentTopic but executes the match on the last non null topic. That is, if currently there are no active networks, this will match the value of var with the topic of the last active network.
  • Numbers:
    • min(var1,...,varn),max(var1,...,varn): returns the min/max of the given list of numbers.
    • random(var): generates a random number from 0 to the value in var-1. var doesn't have to be a variable but can also be a numeric constant.
    • round(var): returns the output of java.lang.Math.round applied to the input argument when converted to a float value.
  • Debug:
    • trace(var): prints a java stack trace when var is evaluated.
    • print(var): prints the value of var when the expression is evaluated by the system.
  • Other:
    • if(var1,var2,var3): return the evaluation of var2 if var1 evaluates to true, if var1 evaluates to false it returns the evaluation of var3. null if var1 returns null.
    • known(expr): this returns true of the provided expression evaluates to anything but the NULL value.
    • numToString(var): returns the string representation of the given number. For example, it returns "twenty three" for 23.
    • hasBeenInterrupted(var): returns true if the current operator has been swapped out by an interruption.
    • isInterruptible(): returns true if the current transition being executed is interruptible (by the user).
    • isQuestion(var): returns true if the provided var evaluates to a string that contains the string "question". This maps to the method edu.usc.ict.nl.io.NLU.isQuestion overwrite with your own specific NLU class if you want to customize or write a new custom function.
Quotation

Delayed evaluation is available using the special operator quote. For example, if we execute this assignment assign(expr1,quote(+(var1,var2,3))) we save in the variable expr1 the expression that computes the sum of var1var2 and the constant 3. every time we use the variable expr1 it's like if we use the entire expression it contains. If we later write the condition >=(expr1,34) it's equivalent to the condition >=(+(var1,var2,3),34).

Macros

Macros can be defined to name complex expressions used in conditions and effects. The system also supports templates. For example,

<formulamacro left="isAvailable(topic)" right="exists(m3,question(topic,?),or(!known(answered('other',m3)),!known(answered('self',m3))))"/>

the above defines a template macro isAvailable that accepts one argument, for example, if the argument topic is the variable tt, the template generates the expression: exists(m3,question(t,?),or(!known(answered('other',m3)),!known(answered('self',m3))))

The reward definition file:

...