# Path: lingtools/prob/probability.py
# class ConditionalFreqDist(defaultdict):
# 
#     """A conditional frequency distribution."""
# 
#     def __init__(self):
#         super(ConditionalFreqDist, self).__init__(FreqDist)


from itertools import product, izip, islice
from operator import itemgetter
from lingtools.prob.probability import ConditionalFreqDist


class Smoothing(object):
    """Define constants for smoothing selection."""
    # The value for none should evaluate to False in boolean context.
    NONE = None
    LAPLACE = "Laplace"
    ELE = "Expected Likelihood Estimate"


class NoSuchContextException(Exception):
    """Raised when information is requested from an unobserved context."""
    pass


class NgramModel(object):
    """A simple N-gram model."""

    def __init__(self, n, training_data=None):
        """Create an n order model using training_data."""
        # Set n and train
        self._order = n
        self._cfd = None
        self.reset()

        if training_data:
            self.update(training_data)

    def reset(self):
        """Clear all trained data structures."""

# Path: lingtools/prob/probability.py
# class ConditionalFreqDist(defaultdict):
# 
#     """A conditional frequency distribution."""
# 
#     def __init__(self):
#         super(ConditionalFreqDist, self).__init__(FreqDist)


# Path: lingtools/prob/ngram.py
from itertools import product, izip, islice
from operator import itemgetter
from lingtools.prob.probability import ConditionalFreqDist



class Smoothing(object):
    """Define constants for smoothing selection."""
    # The value for none should evaluate to False in boolean context.
    NONE = None
    LAPLACE = "Laplace"
    ELE = "Expected Likelihood Estimate"


class NoSuchContextException(Exception):
    """Raised when information is requested from an unobserved context."""
    pass


class NgramModel(object):
    """A simple N-gram model."""

    def __init__(self, n, training_data=None):
        """Create an n order model using training_data."""
        # Set n and train
        self._order = n
        self._cfd = None
        self.reset()

        if training_data:
            self.update(training_data)

    def reset(self):
        """Clear all trained data structures."""

        self._cfd = ConditionalFreqDist()