# Path: corpkit/constants.py
# PYTHON_VERSION = sys.version_info.major
# 
# STRINGTYPE = str if PYTHON_VERSION == 3 else basestring


import math
import os
        import os
        import pandas as pd
        import pandas as pd
    import os
from nltk import ngrams, sent_tokenize, word_tokenize
from corpkit.constants import PYTHON_VERSION, STRINGTYPE
        from collections import Counter
        from corpkit.other import load
        from collections import Counter, OrderedDict
        from corpkit.corpus import Subcorpus, File
    from pandas import DataFrame, Series
    from corpkit.other import load
        from corpkit.other import save
        # mixed type, such as L, GL, GF, because the backoff
        # involves getting just the first ORDER words ...
        for index, count in data.iteritems():
            #gramm = index.split('/')
            # order == 1 still gives us a tuple for now!
            cut_index = index[:order]
            self.counts[cut_index] += count
            if order == 1:
                lexicon.add(cut_index)
                self.n += 1
        self.v = len(lexicon)

    def _logprob(self, ngram):
        return math.log(self._prob(ngram))
    
    def _prob(self, ngram):
        if self.backoff is not None:
            freq = self.counts[ngram]
            backoff_freq = self.backoff.counts[ngram[1:]]
            if freq == 0:
                return self.alpha * self.backoff._prob(ngram[1:])
            else:
                return freq / backoff_freq
        else:
            # laplace smoothing to handle unknown unigrams
            return (self.counts[ngram] + 1) / (self.n + self.v)

class MultiModel(dict):
    
    def __init__(self, data, order, name='', **kwargs):

# Path: corpkit/constants.py
# PYTHON_VERSION = sys.version_info.major
# 
# STRINGTYPE = str if PYTHON_VERSION == 3 else basestring


# Path: corpkit/model.py
import math
import os
        import os
        import pandas as pd
        import pandas as pd
    import os
from nltk import ngrams, sent_tokenize, word_tokenize
from corpkit.constants import PYTHON_VERSION, STRINGTYPE
        from collections import Counter
        from corpkit.other import load
        from collections import Counter, OrderedDict
        from corpkit.corpus import Subcorpus, File
    from pandas import DataFrame, Series
    from corpkit.other import load
        from corpkit.other import save

        # mixed type, such as L, GL, GF, because the backoff
        # involves getting just the first ORDER words ...
        for index, count in data.iteritems():
            #gramm = index.split('/')
            # order == 1 still gives us a tuple for now!
            cut_index = index[:order]
            self.counts[cut_index] += count
            if order == 1:
                lexicon.add(cut_index)
                self.n += 1
        self.v = len(lexicon)

    def _logprob(self, ngram):
        return math.log(self._prob(ngram))
    
    def _prob(self, ngram):
        if self.backoff is not None:
            freq = self.counts[ngram]
            backoff_freq = self.backoff.counts[ngram[1:]]
            if freq == 0:
                return self.alpha * self.backoff._prob(ngram[1:])
            else:
                return freq / backoff_freq
        else:
            # laplace smoothing to handle unknown unigrams
            return (self.counts[ngram] + 1) / (self.n + self.v)

class MultiModel(dict):
    
    def __init__(self, data, order, name='', **kwargs):

        if isinstance(data, STRINGTYPE):