'Make a tag dictionary for single-tag words.
:param sentences: A list of list of (word, tag) tuples.'

def _make_tagdict(self, sentences):

    counts = defaultdict((lambda : defaultdict(int)))
    for sentence in sentences:
        self._sentences.append(sentence)
        for (word, tag) in sentence:
            counts[word][tag] += 1
            self.classes.add(tag)
    freq_thresh = 20
    ambiguity_thresh = 0.97
    for (word, tag_freqs) in counts.items():
        (tag, mode) = max(tag_freqs.items(), key=(lambda item: item[1]))
        n = sum(tag_freqs.values())
        if ((n >= freq_thresh) and ((mode / n) >= ambiguity_thresh)):
            self.tagdict[word] = tag
