class_docstr: Phrase-based stack decoder for machine translation
  
  >>> from nltk.translate import PhraseTable
  >>> phrase_table = PhraseTable()
  >>> phrase_table.add(('niemand',), ('nobody',), log(0.8))
  >>> phrase_table.add(('niemand',), ('no', 'one'), log(0.2))
  >>> phrase_table.add(('erwartet',), ('expects',), log(0.8))
  >>> phrase_table.add(('erwartet',), ('expecting',), log(0.2))
  >>> phrase_table.add(('niemand', 'erwartet'), ('one', 'does', 'not', 'expect'), log(0.1))
  >>> phrase_table.add(('die', 'spanische', 'inquisition'), ('the', 'spanish', 'inquisition'), log(0.8))
  >>> phrase_table.add(('!',), ('!',), log(0.8))
  
  >>> #  nltk.model should be used here once it is implemented
  >>> from collections import defaultdict
  >>> language_prob = defaultdict(lambda: -999.0)
  >>> language_prob[('nobody',)] = log(0.5)
  >>> language_prob[('expects',)] = log(0.4)
  >>> language_prob[('the', 'spanish', 'inquisition')] = log(0.2)
  >>> language_prob[('!',)] = log(0.1)
  >>> language_model = type('',(object,),{'probability_change': lambda self, context, phrase: language_prob[phrase], 'probability': lambda self, phrase: language_prob[phrase]})()
  
  >>> stack_decoder = StackDecoder(phrase_table, language_model)
  
  >>> stack_decoder.translate(['niemand', 'erwartet', 'die', 'spanische', 'inquisition', '!'])
  ['nobody', 'expects', 'the', 'spanish', 'inquisition', '!']
class_docstr_tok: ["Phrase-based","stack","decoder","for","machine","translation",">",">",">","from","nltk.translate","import","PhraseTable",">",">",">","phrase_table","=","PhraseTable","(",")",">",">",">","phrase_table.add","(","(","'niemand","'",",",")",",","(","'nobody","'",",",")",",","log","(","0.8",")",")",">",">",">","phrase_table.add","(","(","'niemand","'",",",")",",","(","'no","'",",","'one","'",")",",","log","(","0.2",")",")",">",">",">","phrase_table.add","(","(","'erwartet","'",",",")",",","(","'expects","'",",",")",",","log","(","0.8",")",")",">",">",">","phrase_table.add","(","(","'erwartet","'",",",")",",","(","'expecting","'",",",")",",","log","(","0.2",")",")",">",">",">","phrase_table.add","(","(","'niemand","'",",","'erwartet","'",")",",","(","'one","'",",","'does","'",",","'not","'",",","'expect","'",")",",","log","(","0.1",")",")",">",">",">","phrase_table.add","(","(","'die","'",",","'spanische","'",",","'inquisition","'",")",",","(","'the","'",",","'spanish","'",",","'inquisition","'",")",",","log","(","0.8",")",")",">",">",">","phrase_table.add","(","(","'","!","'",",",")",",","(","'","!","'",",",")",",","log","(","0.8",")",")",">",">",">","#","nltk.model","should","be","used","here","once","it","is","implemented",">",">",">","from","collections","import","defaultdict",">",">",">","language_prob","=","defaultdict","(","lambda",":","-999.0",")",">",">",">","language_prob","[","(","'nobody","'",",",")","]","=","log","(","0.5",")",">",">",">","language_prob","[","(","'expects","'",",",")","]","=","log","(","0.4",")",">",">",">","language_prob","[","(","'the","'",",","'spanish","'",",","'inquisition","'",")","]","=","log","(","0.2",")",">",">",">","language_prob","[","(","'","!","'",",",")","]","=","log","(","0.1",")",">",">",">","language_model","=","type","(","``",",","(","object",",",")",",","{","'probability_change","'",":","lambda","self",",","context",",","phrase",":","language_prob","[","phrase","]",",","'probability","'",":","lambda","self",",","phrase",":","language_prob","[","phrase","]","}",")","(",")",">",">",">","stack_decoder","=","StackDecoder","(","phrase_table",",","language_model",")",">",">",">","stack_decoder.translate","(","[","'niemand","'",",","'erwartet","'",",","'die","'",",","'spanische","'",",","'inquisition","'",",","'","!","'","]",")","[","'nobody","'",",","'expects","'",",","'the","'",",","'spanish","'",",","'inquisition","'",",","'","!","'","]"]
docstr: Determines the approximate scores for translating every
  subsequence in ``src_sentence``
  
  Future scores can be used a look-ahead to determine the
  difficulty of translating the remaining parts of a src_sentence.
  
  :type src_sentence: tuple(str)
  
  :return: Scores of subsequences referenced by their start and
      end positions. For example, result[2][5] is the score of the
      subsequence covering positions 2, 3, and 4.
  :rtype: dict(int: (dict(int): float))
docstr_tok: ["Determines","the","approximate","scores","for","translating","every","subsequence","in","``","src_sentence","``","Future","scores","can","be","used","a","look-ahead","to","determine","the","difficulty","of","translating","the","remaining","parts","of","a","src_sentence",".",":","type","src_sentence",":","tuple","(","str",")",":","return",":","Scores","of","subsequences","referenced","by","their","start","and","end","positions",".","For","example",",","result","[","2","]","[","5","]","is","the","score","of","the","subsequence","covering","positions","2",",","3",",","and","4.",":","rtype",":","dict","(","int",":","(","dict","(","int",")",":","float",")",")"]
code: def compute_future_scores(self, src_sentence):
      """
      Determines the approximate scores for translating every
      subsequence in ``src_sentence``
  
      Future scores can be used a look-ahead to determine the
      difficulty of translating the remaining parts of a src_sentence.
  
      :type src_sentence: tuple(str)
  
      :return: Scores of subsequences referenced by their start and
          end positions. For example, result[2][5] is the score of the
          subsequence covering positions 2, 3, and 4.
      :rtype: dict(int: (dict(int): float))
      """
      scores = defaultdict(lambda: defaultdict(lambda: float("-inf")))
      for seq_length in range(1, len(src_sentence) + 1):
          for start in range(0, len(src_sentence) - seq_length + 1):
              end = start + seq_length
              phrase = src_sentence[start:end]
              if phrase in self.phrase_table:
                  score = self.phrase_table.translations_for(phrase)[
                      0
                  ].log_prob  # pick best (first) translation
                  # Warning: API of language_model is subject to change
                  score += self.language_model.probability(phrase)
                  scores[start][end] = score
  
              # check if a better score can be obtained by combining
              # two child subsequences
              for mid in range(start + 1, end):
                  combined_score = scores[start][mid] + scores[mid][end]
                  if combined_score > scores[start][end]:
                      scores[start][end] = combined_score
      return scores
  
imports: import warnings
  from collections import defaultdict
  from math import log
label_desc: Use image node_id 7 for calling the StackDecoder obj's underlying member method code with example usage: obj.compute_future_scores(src_sentence) and returns: scores