class_docstr: Translation model that considers how a word can be aligned to
  multiple words in another language
  
  >>> bitext = []
  >>> bitext.append(AlignedSent(['klein', 'ist', 'das', 'haus'], ['the', 'house', 'is', 'small']))
  >>> bitext.append(AlignedSent(['das', 'haus', 'war', 'ja', 'groß'], ['the', 'house', 'was', 'big']))
  >>> bitext.append(AlignedSent(['das', 'buch', 'ist', 'ja', 'klein'], ['the', 'book', 'is', 'small']))
  >>> bitext.append(AlignedSent(['ein', 'haus', 'ist', 'klein'], ['a', 'house', 'is', 'small']))
  >>> bitext.append(AlignedSent(['das', 'haus'], ['the', 'house']))
  >>> bitext.append(AlignedSent(['das', 'buch'], ['the', 'book']))
  >>> bitext.append(AlignedSent(['ein', 'buch'], ['a', 'book']))
  >>> bitext.append(AlignedSent(['ich', 'fasse', 'das', 'buch', 'zusammen'], ['i', 'summarize', 'the', 'book']))
  >>> bitext.append(AlignedSent(['fasse', 'zusammen'], ['summarize']))
  
  >>> ibm3 = IBMModel3(bitext, 5)
  
  >>> print(round(ibm3.translation_table['buch']['book'], 3))
  1.0
  >>> print(round(ibm3.translation_table['das']['book'], 3))
  0.0
  >>> print(round(ibm3.translation_table['ja'][None], 3))
  1.0
  
  >>> print(round(ibm3.distortion_table[1][1][2][2], 3))
  1.0
  >>> print(round(ibm3.distortion_table[1][2][2][2], 3))
  0.0
  >>> print(round(ibm3.distortion_table[2][2][4][5], 3))
  0.75
  
  >>> print(round(ibm3.fertility_table[2]['summarize'], 3))
  1.0
  >>> print(round(ibm3.fertility_table[1]['book'], 3))
  1.0
  
  >>> print(round(ibm3.p1, 3))
  0.054
  
  >>> test_sentence = bitext[2]
  >>> test_sentence.words
  ['das', 'buch', 'ist', 'ja', 'klein']
  >>> test_sentence.mots
  ['the', 'book', 'is', 'small']
  >>> test_sentence.alignment
  Alignment([(0, 0), (1, 1), (2, 2), (3, None), (4, 3)])
class_docstr_tok: ["Translation","model","that","considers","how","a","word","can","be","aligned","to","multiple","words","in","another","language",">",">",">","bitext","=","[","]",">",">",">","bitext.append","(","AlignedSent","(","[","'klein","'",",","'ist","'",",","'das","'",",","'haus","'","]",",","[","'the","'",",","'house","'",",","'is","'",",","'small","'","]",")",")",">",">",">","bitext.append","(","AlignedSent","(","[","'das","'",",","'haus","'",",","'war","'",",","'ja","'",",","'gro\u00df","'","]",",","[","'the","'",",","'house","'",",","'was","'",",","'big","'","]",")",")",">",">",">","bitext.append","(","AlignedSent","(","[","'das","'",",","'buch","'",",","'ist","'",",","'ja","'",",","'klein","'","]",",","[","'the","'",",","'book","'",",","'is","'",",","'small","'","]",")",")",">",">",">","bitext.append","(","AlignedSent","(","[","'ein","'",",","'haus","'",",","'ist","'",",","'klein","'","]",",","[","'","a","'",",","'house","'",",","'is","'",",","'small","'","]",")",")",">",">",">","bitext.append","(","AlignedSent","(","[","'das","'",",","'haus","'","]",",","[","'the","'",",","'house","'","]",")",")",">",">",">","bitext.append","(","AlignedSent","(","[","'das","'",",","'buch","'","]",",","[","'the","'",",","'book","'","]",")",")",">",">",">","bitext.append","(","AlignedSent","(","[","'ein","'",",","'buch","'","]",",","[","'","a","'",",","'book","'","]",")",")",">",">",">","bitext.append","(","AlignedSent","(","[","'ich","'",",","'fasse","'",",","'das","'",",","'buch","'",",","'zusammen","'","]",",","[","'","i","'",",","'summarize","'",",","'the","'",",","'book","'","]",")",")",">",">",">","bitext.append","(","AlignedSent","(","[","'fasse","'",",","'zusammen","'","]",",","[","'summarize","'","]",")",")",">",">",">","ibm3","=","IBMModel3","(","bitext",",","5",")",">",">",">","print","(","round","(","ibm3.translation_table","[","'buch","'","]","[","'book","'","]",",","3",")",")","1.0",">",">",">","print","(","round","(","ibm3.translation_table","[","'das","'","]","[","'book","'","]",",","3",")",")","0.0",">",">",">","print","(","round","(","ibm3.translation_table","[","'ja","'","]","[","None","]",",","3",")",")","1.0",">",">",">","print","(","round","(","ibm3.distortion_table","[","1","]","[","1","]","[","2","]","[","2","]",",","3",")",")","1.0",">",">",">","print","(","round","(","ibm3.distortion_table","[","1","]","[","2","]","[","2","]","[","2","]",",","3",")",")","0.0",">",">",">","print","(","round","(","ibm3.distortion_table","[","2","]","[","2","]","[","4","]","[","5","]",",","3",")",")","0.75",">",">",">","print","(","round","(","ibm3.fertility_table","[","2","]","[","'summarize","'","]",",","3",")",")","1.0",">",">",">","print","(","round","(","ibm3.fertility_table","[","1","]","[","'book","'","]",",","3",")",")","1.0",">",">",">","print","(","round","(","ibm3.p1",",","3",")",")","0.054",">",">",">","test_sentence","=","bitext","[","2","]",">",">",">","test_sentence.words","[","'das","'",",","'buch","'",",","'ist","'",",","'ja","'",",","'klein","'","]",">",">",">","test_sentence.mots","[","'the","'",",","'book","'",",","'is","'",",","'small","'","]",">",">",">","test_sentence.alignment","Alignment","(","[","(","0",",","0",")",",","(","1",",","1",")",",","(","2",",","2",")",",","(","3",",","None",")",",","(","4",",","3",")","]",")"]
docstr: Probability of target sentence and an alignment given the
  source sentence
docstr_tok: ["Probability","of","target","sentence","and","an","alignment","given","the","source","sentence"]
code: def prob_t_a_given_s(self, alignment_info):
      """
      Probability of target sentence and an alignment given the
      source sentence
      """
      src_sentence = alignment_info.src_sentence
      trg_sentence = alignment_info.trg_sentence
      l = len(src_sentence) - 1  # exclude NULL
      m = len(trg_sentence) - 1
      p1 = self.p1
      p0 = 1 - p1
  
      probability = 1.0
      MIN_PROB = IBMModel.MIN_PROB
  
      # Combine NULL insertion probability
      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
  
      # Compute combination (m - null_fertility) choose null_fertility
      for i in range(1, null_fertility + 1):
          probability *= (m - null_fertility - i + 1) / i
          if probability < MIN_PROB:
              return MIN_PROB
  
      # Combine fertility probabilities
      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
  
      # Combine lexical and distortion probabilities
      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
  
file_path: nltk/nltk/translate/ibm3.py
imports: import warnings
  from collections import defaultdict
  from math import factorial
  from nltk.translate import AlignedSent, Alignment, IBMModel, IBMModel2
  from nltk.translate.ibm_model import Counts
label_desc: Use image node_id 6 for calling the IBMModel3 obj's underlying member method code with example usage: obj.prob_t_a_given_s(alignment_info) and returns: probability, MIN_PROB, MIN_PROB, MIN_PROB, MIN_PROB