'Probability of target sentence and an alignment given the
source sentence'

def prob_t_a_given_s(self, alignment_info):

    src_sentence = alignment_info.src_sentence
    trg_sentence = alignment_info.trg_sentence
    l = (len(src_sentence) - 1)
    m = (len(trg_sentence) - 1)
    p1 = self.p1
    p0 = (1 - p1)
    probability = 1.0
    MIN_PROB = IBMModel.MIN_PROB
    null_fertility = alignment_info.fertility_of_i(0)
    probability *= (pow(p1, null_fertility) * pow(p0, (m - (2 * null_fertility))))
    if (probability < MIN_PROB):
        return MIN_PROB
    for i in range(1, (null_fertility + 1)):
        probability *= ((((m - null_fertility) - i) + 1) / i)
        if (probability < MIN_PROB):
            return MIN_PROB
    for i in range(1, (l + 1)):
        fertility = alignment_info.fertility_of_i(i)
        probability *= (factorial(fertility) * self.fertility_table[fertility][src_sentence[i]])
        if (probability < MIN_PROB):
            return MIN_PROB
    for j in range(1, (m + 1)):
        t = trg_sentence[j]
        i = alignment_info.alignment[j]
        s = src_sentence[i]
        probability *= (self.translation_table[t][s] * self.distortion_table[j][i][l][m])
        if (probability < MIN_PROB):
            return MIN_PROB
    return probability
