alex.components.dm package

Submodules

alex.components.dm.autopath module

self cloning, automatic path configuration

copy this into any subdirectory of pypy from which scripts need to be run, typically all of the test subdirs. The idea is that any such script simply issues

import autopath

and this will make sure that the parent directory containing “pypy” is in sys.path.

If you modify the master “autopath.py” version (in pypy/tool/autopath.py) you can directly run it which will copy itself on all autopath.py files it finds under the pypy root directory.

This module always provides these attributes:

pypydir pypy root directory path this_dir directory where this autopath.py resides

alex.components.dm.base module

class alex.components.dm.base.DialogueManager(cfg)[source]

Bases: object

This is a base class for a dialogue manager. The purpose of a dialogue manager is to accept input in the form dialogue acts and respond again in the form of dialogue acts.

The dialogue manager should be able to accept multiple inputs without producing any output and be able to produce multiple outputs without any input.

da_in(da, utterance=None)[source]

Receives an input dialogue act or dialogue act list with probabilities or dialogue act confusion network.

When the dialogue act is received an update of the state is performed.

da_out()[source]

Produces output dialogue act.

end_dialogue()[source]

Ends the dialogue and post-process the data.

log_state()[source]

Log the state of the dialogue state.

Returns:none
new_dialogue()[source]

Initialises the dialogue manager and makes it ready for a new dialogue conversation.

class alex.components.dm.base.DialoguePolicy(cfg, ontology)[source]

Bases: object

This is a base class policy.

get_da(dialogue_state)[source]
class alex.components.dm.base.DialogueState(cfg, ontology)[source]

Bases: object

This is a trivial implementation of a dialogue state and its update.

It uses only the best dialogue act from the input and based on this it updates its state.

get_slots_being_confirmed()[source]

Returns all slots which are currently being confirmed by the user along with the value being confirmed.

get_slots_being_noninformed()[source]

Returns all slots provided by the user and the system has not informed about them yet along with the value of the slot.

get_slots_being_requested()[source]

Returns all slots which are currently being requested by the user along with the correct value.

log_state()[source]

Log the state using the the session logger.

restart()[source]

Reinitialises the dialogue state so that the dialogue manager can start from scratch.

Nevertheless, remember the turn history.

update(user_da, system_da)[source]

Interface for the dialogue act update.

It can process dialogue act, dialogue act N best lists, or dialogue act confusion networks.

Parameters:
  • user_da (DialogueAct, DialogueActNBList or DialogueActConfusionNetwork) – Dialogue act to process.
  • system_da – Last system dialogue act.
class alex.components.dm.base.DiscreteValue(values, name='', desc='')[source]

Bases: object

explain(full=False, linear_prob=False)[source]

This function prints the values and their probabilities for this node.

mph()[source]

The function returns the most probable value and its probability in a tuple.

mpv()[source]

The function returns the most probable value.

mpvp()[source]

The function returns the probability of the most probable value.

normalise()[source]

This function normalise the sum of all probabilities to 1.0

prune(threshold=0.001)[source]

Prune all values with probability less then a threshold.

tmphs()[source]

This function returns two most probable values and their probabilities.

The function returns a tuple consisting of two tuples (probability, value).

tmpvs()[source]

The function returns two most probable values.

tmpvsp()[source]

The function returns probabilities of two most probable values in the slot.

alex.components.dm.common module

alex.components.dm.common.dm_factory(dm_type, cfg)[source]
alex.components.dm.common.get_dm_type(cfg)[source]

alex.components.dm.dddstate module

alex.components.dm.dstc_tracker module

alex.components.dm.dummypolicy module

alex.components.dm.exceptions module

exception alex.components.dm.exceptions.DMException[source]

Bases: alex.AlexException

exception alex.components.dm.exceptions.DeterministicDiscriminativeDialogueStateException[source]

Bases: alex.components.dm.exceptions.DialogueStateException

exception alex.components.dm.exceptions.DialogueManagerException[source]

Bases: alex.AlexException

exception alex.components.dm.exceptions.DialoguePolicyException[source]

Bases: alex.AlexException

exception alex.components.dm.exceptions.DialogueStateException[source]

Bases: alex.AlexException

exception alex.components.dm.exceptions.DummyDialoguePolicyException[source]

Bases: alex.components.dm.exceptions.DialoguePolicyException

alex.components.dm.ontology module

class alex.components.dm.ontology.Ontology(file_name=None)[source]

Bases: object

Represents an ontology for a dialogue domain.

get_compatible_vals(slot_pair, value)[source]

Given a slot pair (key to ‘compatible_values’ in ontology data), this returns the set of compatible values for the given key. If there is no information about the given pair, None is returned.

Parameters:
  • slot_pair – key to ‘compatible_values’ in ontology data
  • value – the subkey to check compatible values for
Return type:

set

get_default_value(slot)[source]

Given a slot name, get its default value (if set in the ontology). Returns None if the default value is not set for the given slot.

Parameters:slot – the name of the desired slot
Return type:unicode
is_compatible(slot_pair, val1, val2)[source]

Given a slot pair and a pair of values, this tests whether the values are compatible. If there is no information about the slot pair or the first value, returns False. If the second value is None, returns always True (i.e. None is compatible with anything).

Parameters:
  • slot_pair – key to ‘compatible_values’ in ontology data
  • val1 – value of the 1st slot
  • val2 – value of the 2nd slot
Return type:

Boolean

last_talked_about(*args, **kwds)[source]

Returns a list of slots and values that should be used to for tracking about what was talked about recently, given the input dialogue acts.

Parameters:
  • da_type – the source dialogue act type
  • name – the source slot name
  • value – the source slot value
Returns:

returns a list of target slot names and values used for tracking

load(file_name)[source]
reset_on_change(*args, **kwds)[source]
slot_has_value(name, value)[source]

Check whether the slot and the value are compatible.

slot_is_binary(name)[source]

Check whether the given slot has a binary value (using the ‘binary’ key in the ‘slot_attributes’ for the given slot name).

Parameters:name – name of the slot being checked
slots_system_confirms(*args, **kwds)[source]

Return all slots the system can request.

slots_system_requests(*args, **kwds)[source]

Return all slots the system can request.

slots_system_selects(*args, **kwds)[source]

Return all slots the system can request.

exception alex.components.dm.ontology.OntologyException[source]

Bases: exceptions.Exception

alex.components.dm.pstate module

class alex.components.dm.pstate.PDDiscrete(initial=None)[source]

Bases: alex.components.dm.pstate.PDDiscreteBase

Discrete probability distribution.

NULL = None
OTHER = '<other>'
get(item)[source]
get_distrib()[source]
get_entropy()[source]
get_items()[source]
iteritems()[source]
meta_slots = set([None, '<other>'])
normalize()[source]

Normalize the probability distribution.

update(items)[source]
class alex.components.dm.pstate.PDDiscreteBase(*args, **kwargs)[source]

Bases: object

get_best()[source]
get_max(which_one=0)[source]
remove(item)[source]
class alex.components.dm.pstate.PDDiscreteOther(space_size, initial=None)[source]

Bases: alex.components.dm.pstate.PDDiscreteBase

Discrete probability distribution with sink probability slot for OTHER.

NULL = None
OTHER = '<other>'
get(item)[source]
get_distrib()[source]
get_entropy()[source]
get_items()[source]
get_max(which_one=0)[source]
iteritems()[source]
meta_slots = set([None, '<other>'])
normalize(redistrib=0.0)[source]

Normalize the probability distribution.

space_size = None
update(items)[source]
class alex.components.dm.pstate.SimpleUpdater(slots)[source]

Bases: object

update(observ)[source]
update_slot(slot, observ_distrib)[source]

alex.components.dm.state module

class alex.components.dm.state.State(slots)[source]

Bases: object

update(item, value)[source]

alex.components.dm.tracker module

class alex.components.dm.tracker.StateTracker[source]

Bases: object

state_class = None
update_state(state, cn)[source]

Update state according to the confusion network cn.

Module contents