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: Train on ``sentence_aligned_corpus`` and create a lexical
  translation model, a distortion model, a fertility model, and a
  model for generating NULL-aligned words.
  
  Translation direction is from ``AlignedSent.mots`` to
  ``AlignedSent.words``.
  
  :param sentence_aligned_corpus: Sentence-aligned parallel corpus
  :type sentence_aligned_corpus: list(AlignedSent)
  
  :param iterations: Number of iterations to run training algorithm
  :type iterations: int
  
  :param probability_tables: Optional. Use this to pass in custom
      probability values. If not specified, probabilities will be
      set to a uniform distribution, or some other sensible value.
      If specified, all the following entries must be present:
      ``translation_table``, ``alignment_table``,
      ``fertility_table``, ``p1``, ``distortion_table``.
      See ``IBMModel`` for the type and purpose of these tables.
  :type probability_tables: dict[str]: object
docstr_tok: ["Train","on","``","sentence_aligned_corpus","``","and","create","a","lexical","translation","model",",","a","distortion","model",",","a","fertility","model",",","and","a","model","for","generating","NULL-aligned","words",".","Translation","direction","is","from","``","AlignedSent.mots","``","to","``","AlignedSent.words","``",".",":","param","sentence_aligned_corpus",":","Sentence-aligned","parallel","corpus",":","type","sentence_aligned_corpus",":","list","(","AlignedSent",")",":","param","iterations",":","Number","of","iterations","to","run","training","algorithm",":","type","iterations",":","int",":","param","probability_tables",":","Optional",".","Use","this","to","pass","in","custom","probability","values",".","If","not","specified",",","probabilities","will","be","set","to","a","uniform","distribution",",","or","some","other","sensible","value",".","If","specified",",","all","the","following","entries","must","be","present",":","``","translation_table","``",",","``","alignment_table","``",",","``","fertility_table","``",",","``","p1","``",",","``","distortion_table","``",".","See","``","IBMModel","``","for","the","type","and","purpose","of","these","tables",".",":","type","probability_tables",":","dict","[","str","]",":","object"]
code: def __init__(
      self, sentence_aligned_corpus, iterations, probability_tables=None
  ):
      """
      Train on ``sentence_aligned_corpus`` and create a lexical
      translation model, a distortion model, a fertility model, and a
      model for generating NULL-aligned words.
  
      Translation direction is from ``AlignedSent.mots`` to
      ``AlignedSent.words``.
  
      :param sentence_aligned_corpus: Sentence-aligned parallel corpus
      :type sentence_aligned_corpus: list(AlignedSent)
  
      :param iterations: Number of iterations to run training algorithm
      :type iterations: int
  
      :param probability_tables: Optional. Use this to pass in custom
          probability values. If not specified, probabilities will be
          set to a uniform distribution, or some other sensible value.
          If specified, all the following entries must be present:
          ``translation_table``, ``alignment_table``,
          ``fertility_table``, ``p1``, ``distortion_table``.
          See ``IBMModel`` for the type and purpose of these tables.
      :type probability_tables: dict[str]: object
      """
      super().__init__(sentence_aligned_corpus)
      self.reset_probabilities()
  
      if probability_tables is None:
          # Get translation and alignment probabilities from IBM Model 2
          ibm2 = IBMModel2(sentence_aligned_corpus, iterations)
          self.translation_table = ibm2.translation_table
          self.alignment_table = ibm2.alignment_table
          self.set_uniform_probabilities(sentence_aligned_corpus)
      else:
          # Set user-defined probabilities
          self.translation_table = probability_tables[
              "translation_table"
          ]
          self.alignment_table = probability_tables["alignment_table"]
          self.fertility_table = probability_tables["fertility_table"]
          self.p1 = probability_tables["p1"]
          self.distortion_table = probability_tables["distortion_table"]
  
      for n in range(0, iterations):
          self.train(sentence_aligned_corpus)
  
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 1 to create a new IBMModel3 object from inherited base classes: IBMModel with example: obj = IBMModel3(sentence_aligned_corpus, iterations, probability_tables)