'Initialize this ContextTagger\'s ``_context_to_tag`` table
based on the given training data.  In particular, for each
context ``c`` in the training data, set
``_context_to_tag[c]`` to the most frequent tag for that
context.  However, exclude any contexts that are already
tagged perfectly by the backoff tagger(s).
The old value of ``self._context_to_tag`` (if any) is discarded.
:param tagged_corpus: A tagged corpus.  Each item should be
a list of (word, tag tuples.
:param cutoff: If the most likely tag for a context occurs
fewer than cutoff times, then exclude it from the
context-to-tag table for the new tagger.'

def _train(self, tagged_corpus, cutoff=0, verbose=False):

    token_count = hit_count = 0
    useful_contexts = set()
    fd = ConditionalFreqDist()
    for sentence in tagged_corpus:
        (tokens, tags) = zip(*sentence)
        for (index, (token, tag)) in enumerate(sentence):
            token_count += 1
            context = self.context(tokens, index, tags[:index])
            if (context is None):
                continue
            fd[context][tag] += 1
            if ((self.backoff is None) or (tag != self.backoff.tag_one(tokens, index, tags[:index]))):
                useful_contexts.add(context)
    for context in useful_contexts:
        best_tag = fd[context].max()
        hits = fd[context][best_tag]
        if (hits > cutoff):
            self._context_to_tag[context] = best_tag
            hit_count += hits
    if verbose:
        size = len(self._context_to_tag)
        backoff = (100 - ((hit_count * 100.0) / token_count))
        pruning = (100 - ((size * 100.0) / len(fd.conditions())))
        print(u'[Trained    Unigram    tagger:', end=u'    ')
        print((u'size=%d,    backoff=%.2f%%,    pruning=%.2f%%]' % (size, backoff, pruning)))
