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:
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

class alex.components.dm.dddstate.D3DiscreteValue(values={}, name=u'', desc=u'')[source]

Bases: alex.components.dm.base.DiscreteValue

This is a simple implementation of a probabilistic slot. It serves for the case of simple MDP approach or UFAL DSTC 1.0-like dialogue state deterministic update.

add(value, prob)[source]

This function adds probability to the given value.

distribute(value, dist_prob)[source]

This function distributes a portion of probability mass assigned to the value to other values with a weight prob.

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

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

get(value, default_prob)[source]
items()[source]
mph()[source]

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

normalise()[source]

This function normalises the sum of all probabilities to 1.0

reset()[source]
scale(weight)[source]

This function scales each probability by the weigh.t

set(value, prob=None)[source]

This function sets a probability of a specific value.

WARNING This can lead to un-normalised probabilities.

test(test_value=None, test_prob=None, neg_val=False, neg_prob=False)[source]

Test the most probable value of the slot whether:

  1. the most probable value is equal to test_value and
  2. its probability is larger the test_prob

Each of the above tests can be negated when neg_* is set True.

Parameters:
  • test_value
  • test_prob
  • neg_val
  • neg_prob
Returns:

tmphs()[source]

This function returns two most probable values and their probabilities. If there are multiple values with the same probability, it prefers non-‘none’ values.

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

Return type:tuple
class alex.components.dm.dddstate.DeterministicDiscriminativeDialogueState(cfg, ontology)[source]

Bases: alex.components.dm.base.DialogueState

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

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

get_accepted_slots(acc_prob)[source]

Returns all slots which have a probability of a non “none” value larger then some threshold.

get_changed_slots(cha_prob)[source]

Returns all slots that has changed from the previous turn. Because the change is determined by change in probability for a particular value, there may be very small changes. Therefore, this will only report changes for values with a probability larger than the given threshold.

Parameters:cha_prob – minimum current probability of the most probable hypothesis to be reported
Return type:dict
get_slots_being_confirmed(conf_prob=0.8)[source]

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

get_slots_being_noninformed(noninf_prob=0.8)[source]

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

This will not detect a change in a goal. For example:

U: I want a Chinese restaurant.
S: Ok, you want a Chinese restaurant. What price range you have in mind?
U: Well, I would rather want an Italian Restaurant.
S: Ok, no problem. You want an Italian restaurant. What price range you have in mind?

Because the system informed about the food type and stored “system-informed”, then we will not notice that we confirmed a different food type.

get_slots_being_requested(req_prob=0.8)[source]

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

get_slots_tobe_confirmed(min_prob, max_prob)[source]

Returns all slots which have a probability of a non “none” value larger then some threshold and still not so large to be considered as accepted.

get_slots_tobe_selected(sel_prob)[source]

Returns all slots which have a probability of the two most probable non “none” value larger then some threshold.

has_state_changed(cha_prob)[source]

Returns a boolean indicating whether the dialogue state changed significantly since the last turn. True is returned if at least one slot has at least one value whose probability has changed at least by the given threshold since last time.

Parameters:cha_prob – minimum probability change to be reported
Return type:Boolean
log_state()[source]

Log the state using the the session logger.

restart()[source]

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

Nevertheless, remember the turn history.

slots = None
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:

alex.components.dm.dstc_tracker module

class alex.components.dm.dstc_tracker.DSTCState(slots)[source]

Bases: object

Represents state of the tracker.

pprint()[source]

Pretty-print self.

class alex.components.dm.dstc_tracker.DSTCTracker(slots, default_space_size=defaultdict(<function <lambda> at 0x7fbf78f57668>, {}))[source]

Bases: alex.components.dm.tracker.StateTracker

Represents simple deterministic DSTC state tracker.

state_class

alias of DSTCState

update_state(state, cn)[source]
class alex.components.dm.dstc_tracker.ExtendedSlotUpdater[source]

Bases: object

Updater of state given observation and deny distributions.

classmethod update_slot(curr_pd, observ_pd, deny_pd)[source]
alex.components.dm.dstc_tracker.main()[source]

alex.components.dm.dummypolicy module

This is an example implementation of a dummy yet funny dialogue policy.

class alex.components.dm.dummypolicy.DummyDialoguePolicy(cfg, ontology)[source]

Bases: alex.components.dm.base.DialoguePolicy

This is a trivial policy just to demonstrate basic functionality of a proper DM.

get_da(dialogue_state)[source]

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