class documentation

Partial solution to a translation.

Records the word positions of the phrase being translated, its translation, raw score, and the cost of the untranslated parts of the sentence. When the next phrase is selected to build upon the partial solution, a new _Hypothesis object is created, with a back pointer to the previous hypothesis.

To find out which words have been translated so far, look at the src_phrase_span in the hypothesis chain. Similarly, the translation output can be found by traversing up the chain.

Method __init__ No summary
Method score Overall score of hypothesis after accounting for local and global features
Method total_translated_words Undocumented
Method translated_positions List of positions in the source sentence of words already translated. The list is not sorted.
Method translation_so_far Undocumented
Method untranslated_spans Starting from each untranslated word, find the longest continuous span of untranslated positions
Instance Variable future_score Undocumented
Instance Variable previous Undocumented
Instance Variable raw_score Undocumented
Instance Variable src_phrase_span Undocumented
Instance Variable trg_phrase Undocumented
Method __build_translation Undocumented
def __init__(self, raw_score=0.0, src_phrase_span=(), trg_phrase=(), previous=None, future_score=0.0): (source)
Parameters
raw_score:floatLikelihood of hypothesis so far. Higher is better. Does not account for untranslated words.
src_phrase_span:tuple(int)Span of word positions covered by the source phrase in this hypothesis expansion. For example, (2, 5) means that the phrase is from the second word up to, but not including the fifth word in the source sentence.
trg_phrase:tuple(str)Translation of the source phrase in this hypothesis expansion
previous:_HypothesisPrevious hypothesis before expansion to this one
future_score:floatApproximate score for translating the remaining words not covered by this hypothesis. Higher means that the remaining words are easier to translate.
def score(self): (source)

Overall score of hypothesis after accounting for local and global features

def total_translated_words(self): (source)

Undocumented

def translated_positions(self): (source)

List of positions in the source sentence of words already translated. The list is not sorted.

Returns
list(int)Undocumented
def translation_so_far(self): (source)

Undocumented

def untranslated_spans(self, sentence_length): (source)

Starting from each untranslated word, find the longest continuous span of untranslated positions

Parameters
sentence_length:intLength of source sentence being translated by the hypothesis
Returns
list(tuple(int, int))Undocumented
future_score = (source)

Undocumented

previous = (source)

Undocumented

raw_score = (source)

Undocumented

src_phrase_span = (source)

Undocumented

trg_phrase = (source)

Undocumented

def __build_translation(self, hypothesis, output): (source)

Undocumented