Simulation

SimulatedUsersManager.py - combines simulated components into functional simulator

Copyright CUED Dialogue Systems Group 2015 - 2017

See also

CUED Imports/Dependencies:

import usersimulator.UserModel
import usersimulator.ErrorSimulator
import ontology.Ontology
import ontology.OntologyUtils
import utils.Settings
import utils.DiaAct
import utils.ContextLogger


class usersimulator.SimulatedUsersManager.DomainsSimulatedUser(domainString, error_rate)

User Simulator for a single domain. Comprised of a behaviour component: UserModel to produce a semantic act and an error simulator to produce from the semantic act a list of semantic hypotheses.

Parameters

str – domain string

act_on(sys_act_string)

Thru the UserModel member, receives the system action and then responds.

Parameters

sys_act_string (unicode str) – system action

Returns

(str) user action

restart(otherDomainsConstraints)

Resets all components (User Model) that are statefull.

Parameters

otherDomainsConstraints (list) – of domain goal tuples (slot=val)

Returns

None

class usersimulator.SimulatedUsersManager.SimulatedUsersManager(error_rate)

The multidomain simulated user, which is made up of a dictionary of simulated users indexed by domain. :param (list): of domain strings

act_on(sys_act)

First produce a single semantic act from the simulated user. Then create from it a list of semantic hypotheses which include simulated errors.

restart()
Restarts/boots up the selected domains simulated user components. Shuts down those running and not needed for

the next dialog.

Parameters

None

Returns

None

sample_domains()
Randomly select a set of domains from those available.

The selected domains will be used by the simulated user over a single dialog.

Parameters

None

Returns

None

set_allowed_codomains(ROOTDOMAIN)

Sets member (list) allowed_codomains given a root domain name (ie the domain of the first constraint) Uses the hardcoded rules in Settings.py to do so. Also, based on determined allowed_codomains, sets the probability of each being included, independently.

Parameters

ROOTDOMAIN (str) – domain tag

Returns

None

ConfidenceScorer.py -

Copyright CUED Dialogue Systems Group 2015 - 2017

See also

CUED Imports/Dependencies:

import utils.Settings
import utils.DiaAct


class usersimulator.ConfidenceScorer.AdditiveConfidenceScorer(topProb1=False, rescale=False)

Additive confidence scoring of TODO

assignConfScores(dapl)
Parameters

dapl (list) – N-best list of DiaAct

Returns

scored dialogue act list

class usersimulator.ConfidenceScorer.DSTC2ConfidenceScorer(paramset=None)

Confidence scorer based on the statistics obtained from the DSTC2 corpus

assignConfScores(dapl)
Parameters

dapl (list) – N-best list of DiaAct

Returns

scored dialogue act list

ConfusionModel.py - handcrafted SemI error creator

Copyright CUED Dialogue Systems Group 2015 - 2017

See also

CUED Imports/Dependencies:

import utils.DiaAct
import ontology.Ontology
import utils.Settings
import utils.ContextLogger


class usersimulator.ConfusionModel.EMConfusionModel

Base class for EMRandomConfusionModel.

Note

Used through derived class only.

create_wrong_hyp(a_u)

Create a wrong hypothesis for a_u

Parameters

a_u (instance) – of DiaAct

Returns

(instance) of DiaAct - modified input act

class usersimulator.ConfusionModel.EMLevenshteinConfusionModel(domainString)

Derived class from EMConfusionModel.

Parameters

None

confuse_hyp(a_u)

Randomly confuse the act type, slot or value.

Parameters

a_u (instance) – of DiaAct

Returns

(instance) of DiaAct - modified input act

get_confusion_distributions(word_list, offset=0.15)
Parameters
  • word_list – The list of words to be confused

  • offset – Distribution softening factor, the largest the softer the distribution will be

Returns

dictionary

class usersimulator.ConfusionModel.EMRandomConfusionModel(domainString)

Derived class from EMConfusionModel.

Parameters

None

confuse_hyp(a_u)

Randomly confuse the act type, slot or value.

Parameters

a_u (instance) – of DiaAct

Returns

(instance) of DiaAct - modified input act

ErrorModel.py - error simulation

Copyright CUED Dialogue Systems Group 2015 - 2017

See also

CUED Imports/Dependencies:

import usersimulator.ConfidenceScorer
import utils.DiaAct
import utils.ContextLogger


NBestGenerator.py -

Copyright CUED Dialogue Systems Group 2015 - 2017

See also

CUED Imports/Dependencies:

import utils.Settings
import utils.ContextLogger


class usersimulator.NBestGenerator.DSTC2NBestGenerator(confusion_model, error_rate, nbest_size, paramset=None)

Tool for generating random semantic errors based on the statistics learned from the DSTC2 corpus

getNBest(a_u)

Returns an N-best list of dialogue acts of length self.nbest_size

Parameters

a_u (instance) – of DiaActWithProb

class usersimulator.NBestGenerator.EMNBestGenerator(confusion_model, error_rate, nbest_size)

Tool for generating random semantic errors.

getNBest(a_u)

Returns an N-best list of dialogue acts of length nbest_size. Each entry is a random confusion of the given dialogue act a_u with probability e (errorRate).

Parameters

a_u (instance) – of DiaActWithProb

class usersimulator.NBestGenerator.EMSampledNBestGenerator(confusion_model, error_rate, nbest_size)

The Dirichlet collection NBest generator operates by sampling a length for the N-best list and then sampling from a specific Dirichlet for that length.

This is a derived class from base NBestGenerator

Parameters
  • confusion_model (instance) – of ConfusionModel

  • nbest_size (int) – None

Note

The original C++ implementation did not sample N which is the length of the N-best list.

getNBest(a_u)
Parameters

a_u (instance) – of DiaActWithProb

Returns

(list) of such dialogue act types as input

UserModel.py - goal, agenda inventor for sim user

Copyright CUED Dialogue Systems Group 2015 - 2017

See also

CUED Imports/Dependencies:

import utils.DiaAct
import utils.dact
import usersimulator.UMHdcSim
import ontology.Ontology
import utils.Settings
import utils.ContextLogger


class usersimulator.UserModel.GoalGenerator(dstring)

Master class for defining a goal generator to generate domain specific goals for the simulated user.

This class also defines the interface for new goal generators.

To implement domain-specific behaviour, derive from this class and override init_goals.

init_goal(otherDomainsConstraints, um_patience)

Initialises the goal g with random constraints and requests

Parameters
  • otherDomainsConstraints (list) – of constraints from other domains in this dialog which have already had goals generated.

  • um_patience (int) – the patiance value for this goal

Returns

(instance) of UMGoal

class usersimulator.UserModel.UM(domainString)

Simulated user

Parameters

None

init(otherDomainsConstraints)

Initialises the simulated user. 1. Initialises the goal G using the goal generator. 2. Populates the agenda A using the goal G. Resets all UM status to their defaults.

Parameters

otherDomainsConstraints (list) – of domain goals/constraints (slot=val) from other domains in dialog for which goal has already been generated.

Returns None

receive(sys_act)

This method is called to transmit the machine dialogue act to the user. It updates the goal and the agenda. :param sys_act: System action. :return:

respond()

This method is called after receive() to get the user dialogue act response. The method first increments the turn counter, then pops n items off the agenda to form the response dialogue act. The agenda and goal are updated accordingly.

Parameters

None

Returns

(instance) of DiaAct

class usersimulator.UserModel.UMAgenda(dstring)

Agenda of DiaAct acts corresponding to a goal.

Parameters

domain (str) – domain tag (ie CamRestaurants)

append_dact_to_front(dact)

Adds the given dialogue act to the front of the agenda

Parameters

(instance) – dact

Returns

None

clear()

Erases all acts on the agenda (empties list)

Returns

None

contains(slot, value, negate=False)

Check if slot, value pair is in an agenda dialogue act

Parameters
  • slot

  • value

  • negate (bool) – None

Returns

(bool) slot, value is in an agenda dact?

filter_acts_slot(slot)

Any acts related to the given slot are removed from the agenda. :param slot: slot name :type slot: str :return: None

filter_constraints(dap)

Filters out acts on the agenda that convey the constraints mentioned in the given dialogue act. Calls filter_acts_slot() to do so.

Parameters

dap

Returns

None

get_agenda_with_act(act)

agenda items with this act :param act: dialogue act :type act: str :return: (list) agenda items

get_agenda_with_act_slot(act, slot)
Parameters
  • act (str) – dialogue act

  • slot (str) – slot name

Returns

(list) of agenda items

init(goal)

Initialises the agenda by creating DiaActs corresponding to the constraints in the goal G. Uses the default order for the dialogue acts on the agenda: an inform act is created for each constraint. Finally a bye act is added at the bottom of the agenda.

Parameters

goal

Note

No requests are added to the agenda.

replace_acts_slot(slot, replaceact='confirm')
size()

Utility func to get size of agenda_items list

Returns

(int) length

class usersimulator.UserModel.UMGoal(patience, domainString)

Defines a goal within a domain

Parameters

patience (int) – user patience

add_const(slot, value, negate=False)
add_prev_used(slot, value)

Adds the given slot-value pair to the record of previously used slot-value pairs.

are_all_requests_filled()
Returns

True if all request slots have a non-empty value.

get_correct_const_value(slot, negate=False)
Returns

(list of) value of the given slot in user goal constraint.

get_correct_const_value_list(slot, negate=False)
Returns

(list of) value of the given slot in user goal constraint.

is_satisfy_all_consts(item)

Check if all the given items set[(slot, op, value),..] satisfies all goal constraints (conjunction of constraints).

Returns True if the request slot ‘name’ is not empty. :return:

set_copied_constraints(all_conditional_constraints)

Creates a list of dacts, where the constraints have come from earlier domains in the dialog.

Parameters

all_conditional_constraints (dict) – of all previous constraints (over all domains in dialog)

Returns

None

UMHdcSim.py - Handcrafted simulated user behaviour

Copyright CUED Dialogue Systems Group 2015 - 2017

See also

CUED Imports/Dependencies:

import usersimulator.UserModel
import utils.DiaAct
import utils.dact
import ontology.Ontology
import utils.Settings
import utils.ContextLogger

Relevant config variables (values are defaults):

[um]
usenewgoalscenarios = True 
answerreqalways = False

[goalgenerator]
patience = 10
class usersimulator.UMHdcSim.UMHdcSim(domainString, max_patience=5)

Handcrafted behaviour of simulated user

init(goal, um_patience)
receive(sys_act, goal)
respond(goal)

This method is called to get the user response.

Parameters

goal (instance) – of UMGoal

Returns

(instance) of DiaActWithProb

usersimulator.UMHdcSim.logger = <utils.ContextLogger.ContextLogger object>

rand_decision_probs = {‘InformCombination’: 0.6, ‘AddSlotToReq’: 0.333, ‘NoAfterReqmore’: 0.7, ‘YesAfterReqmore’: 0.25, ‘Greeting’: 0.5, ‘ConstraintRelax’: 0.667, ‘TellAboutChange’: 0.5, ‘ByeOrStartOver’: 0.333, ‘DealWithPending’: 0.5, ‘AddVenueNameToRequest’: 0.05, ‘NoSlotWithDontcare’: 0.8, ‘Repeat’: 0.0, ‘InformToConfirm’: 0.05, ‘CombAffirmWithAgdItem’: 0.05, ‘NullResp’: 0.0, ‘OverruleCorrection’: 0.1, ‘ConfirmRandomConstr’: 0.1, ‘ReqAltsAfterVenRec1’: 0.143, #0.8 ‘ReqAltsAfterVenRec2’: 0.143, ‘NewRequestResp1’: 0.2, ‘NewRequestResp2’: 0.2, ‘CorrectingAct1’: 0.45, ‘CorrectingAct2’: 0.4, ‘ThankAck1’: 0.1, ‘ThankAck2’: 0.1, ‘AffirmCombination’: 1.0}