class documentation

Helper data object for training IBM Models 3 and up

Read-only. For a source sentence and its counterpart in the target language, this class holds information about the sentence pair's alignment, cepts, and fertility.

Warning: Alignments are one-indexed here, in contrast to nltk.translate.Alignment and AlignedSent, which are zero-indexed This class is not meant to be used outside of IBM models.

Method __eq__ Undocumented
Method __hash__ Undocumented
Method __init__ Undocumented
Method __ne__ Undocumented
Method center_of_cept No summary
Method fertility_of_i Fertility of word in position i of the source sentence
Method is_head_word No summary
Method previous_cept No summary
Method previous_in_tablet No summary
Method zero_indexed_alignment No summary
Instance Variable alignment tuple(int): Alignment function. alignment[j] is the position in the source sentence that is aligned to the position j in the target sentence.
Instance Variable cepts list(list(int)): The positions of the target words, in ascending order, aligned to a source word position. For example, cepts[4] = (2, 3, 7) means that words in positions 2, 3 and 7 of the target sentence are aligned to the word in position 4 of the source sentence...
Instance Variable score float: Optional. Probability of alignment, as defined by the IBM model that assesses this alignment
Instance Variable src_sentence tuple(str): Source sentence referred to by this object. Should include NULL token (None) in index 0.
Instance Variable trg_sentence tuple(str): Target sentence referred to by this object. Should have a dummy element in index 0 so that the first word starts from index 1.
def __eq__(self, other): (source)

Undocumented

def __hash__(self): (source)

Undocumented

def __init__(self, alignment, src_sentence, trg_sentence, cepts): (source)

Undocumented

def __ne__(self, other): (source)

Undocumented

def center_of_cept(self, i): (source)
Returns
The ceiling of the average positions of the words in the tablet of cept i, or 0 if i is None
def fertility_of_i(self, i): (source)

Fertility of word in position i of the source sentence

def is_head_word(self, j): (source)
Returns
Whether the word in position j of the target sentence is a head word
def previous_cept(self, j): (source)
Returns
The previous cept of j, or None if j belongs to the first cept
def previous_in_tablet(self, j): (source)
Returns
The position of the previous word that is in the same tablet as j, or None if j is the first word of the tablet
def zero_indexed_alignment(self): (source)
Returns
list(tuple)Zero-indexed alignment, suitable for use in external nltk.translate modules like nltk.translate.Alignment
alignment = (source)

tuple(int): Alignment function. alignment[j] is the position in the source sentence that is aligned to the position j in the target sentence.

list(list(int)): The positions of the target words, in ascending order, aligned to a source word position. For example, cepts[4] = (2, 3, 7) means that words in positions 2, 3 and 7 of the target sentence are aligned to the word in position 4 of the source sentence

float: Optional. Probability of alignment, as defined by the IBM model that assesses this alignment

src_sentence = (source)

tuple(str): Source sentence referred to by this object. Should include NULL token (None) in index 0.

trg_sentence = (source)

tuple(str): Target sentence referred to by this object. Should have a dummy element in index 0 so that the first word starts from index 1.