alex.ml package

Submodules

alex.ml.exceptions module

exception alex.ml.exceptions.FFNNException[source]

Bases: alex.AlexException

exception alex.ml.exceptions.NBListException[source]

Bases: alex.AlexException

alex.ml.features module

alex.ml.ffnn module

alex.ml.hypothesis module

This module collects classes representing the uncertainty about the actual value of a base type instance.

class alex.ml.hypothesis.ConfusionNetwork[source]

Bases: alex.ml.hypothesis.Hypothesis

Confusion network. In this representation, each fact breaks down into a sequence of elementary acts.

add(probability, fact)[source]

Append a fact to the confusion network.

add_merge(p, fact, combine=u'max')[source]

Add a fact and if it exists merge it according to the given combine strategy.

extend(conf_net)[source]
classmethod from_fact(fact)[source]

Constructs a deterministic confusion network that asserts the given `fact’. Note that `fact’ has to be an iterable of elementary acts.

get_prob(fact)[source]

Get the probability of the fact.

merge(conf_net, combine=u'max')[source]

Merges facts in the current and the given confusion networks.

Arguments:
combine – can be one of {‘new’, ‘max’, ‘add’, ‘arit’, ‘harm’}, and
determines how two probabilities should be merged (default: ‘max’)

XXX As of now, we know that different values for the same slot are contradictory (and in general, the set of contradicting attr-value pairs could be larger). We should therefore consider them alternatives to each other.

normalise()[source]

Makes sure that all probabilities add up to one. They should implicitly sum to one: p + (1-p) == 1.0

prune(prune_prob=0.005)[source]

Prune all low probability dialogue act items.

remove(fact_to_remove)[source]
sort(reverse=True)[source]
update_prob(probability, fact)[source]

Update the probability of a fact.

exception alex.ml.hypothesis.ConfusionNetworkException[source]

Bases: exceptions.Exception

class alex.ml.hypothesis.Hypothesis[source]

Bases: object

This is the base class for all forms of probabilistic hypotheses representations.

classmethod from_fact(fact)[source]

Constructs a deterministic hypothesis that asserts the given `fact’.

class alex.ml.hypothesis.NBList[source]

Bases: alex.ml.hypothesis.Hypothesis

This class represents the uncertainty using an n-best list.

When updating an N-best list, one should do the following.

  1. add utterances or parse a confusion network
  2. merge and normalise, in either order
add(probability, fact)[source]

Finds the last hypothesis with a lower probability and inserts the new item before that one. Optimised for adding objects from the highest probability ones to the lowest probability ones.

add_other(other)[source]

The N-best list is extended to include the other object to represent those object values that are not enumerated in the list.

Returns self.

classmethod from_fact(fact)[source]
get_best()[source]

Returns the most probable value of the object.

merge()[source]

Adds up probabilities for the same hypotheses. Returns self.

normalise()[source]

Scales the list to sum to one.

alex.ml.logarithmetic module

alex.ml.test_hypothesis module

class alex.ml.test_hypothesis.TestConfusionNetwork(methodName='runTest')[source]

Bases: unittest.case.TestCase

test_iter()[source]
test_remove()[source]

alex.ml.tffnn module

Module contents