'Calculate the "out-of-place" measure between the
text and language profile for a single trigram'

def calc_dist(self, lang, trigram, text_profile):

    lang_fd = self._corpus.lang_freq(lang)
    dist = 0
    if (trigram in lang_fd):
        idx_lang_profile = list(lang_fd.keys()).index(trigram)
        idx_text = list(text_profile.keys()).index(trigram)
        dist = abs((idx_lang_profile - idx_text))
    elif PY3:
        dist = maxsize
    else:
        dist = maxint
    return dist
