'Returns the score for a given trigram using the given scoring
function.'

def score_ngram(self, score_fn, w1, w2, w3):

    n_all = self.N
    n_iii = self.ngram_fd[(w1, w2, w3)]
    if (not n_iii):
        return
    n_iix = self.bigram_fd[(w1, w2)]
    n_ixi = self.wildcard_fd[(w1, w3)]
    n_xii = self.bigram_fd[(w2, w3)]
    n_ixx = self.word_fd[w1]
    n_xix = self.word_fd[w2]
    n_xxi = self.word_fd[w3]
    return score_fn(n_iii, (n_iix, n_ixi, n_xii), (n_ixx, n_xix, n_xxi), n_all)
