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.
-
class
alex.components.dm.base.
DialoguePolicy
(cfg, ontology)[source]¶ Bases:
object
This is a base class policy.
-
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.
-
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
orDialogueActConfusionNetwork
) – Dialogue act to process. - system_da – Last system dialogue act.
- user_da (
-
-
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.
-
alex.components.dm.common module¶
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.
-
distribute
(value, dist_prob)[source]¶ This function distributes a portion of probability mass assigned to the
value
to other values with a weightprob
.
-
explain
(full=False, linear_prob=True)[source]¶ This function prints the values and their probabilities for this node.
-
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:
- the most probable value is equal to test_value and
- 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:
-
-
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
-
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: - user_da (
DialogueAct
,DialogueActNBList
orDialogueActConfusionNetwork
) – Dialogue act to process. - system_da – Last system dialogue act.
- user_da (
-
alex.components.dm.dstc_tracker module¶
-
class
alex.components.dm.dstc_tracker.
DSTCState
(slots)[source]¶ Bases:
object
Represents state of the tracker.
-
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
-
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.
alex.components.dm.exceptions module¶
-
exception
alex.components.dm.exceptions.
DMException
[source]¶ Bases:
alex.AlexException
-
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:
-
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
-
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>'¶
-
meta_slots
= set([None, '<other>'])¶
-