class_docstr: An abstract bottom-up parser for ``PCFG`` grammars that uses a ``Chart`` to
  record partial results.  ``BottomUpProbabilisticChartParser`` maintains
  a queue of edges that can be added to the chart.  This queue is
  initialized with edges for each token in the text that is being
  parsed.  ``BottomUpProbabilisticChartParser`` inserts these edges into
  the chart one at a time, starting with the most likely edges, and
  proceeding to less likely edges.  For each edge that is added to
  the chart, it may become possible to insert additional edges into
  the chart; these are added to the queue.  This process continues
  until enough complete parses have been generated, or until the
  queue is empty.
  
  The sorting order for the queue is not specified by
  ``BottomUpProbabilisticChartParser``.  Different sorting orders will
  result in different search strategies.  The sorting order for the
  queue is defined by the method ``sort_queue``; subclasses are required
  to provide a definition for this method.
  
  :type _grammar: PCFG
  :ivar _grammar: The grammar used to parse sentences.
  :type _trace: int
  :ivar _trace: The level of tracing output that should be generated
      when parsing a text.
class_docstr_tok: ["An","abstract","bottom-up","parser","for","``","PCFG","``","grammars","that","uses","a","``","Chart","``","to","record","partial","results",".","``","BottomUpProbabilisticChartParser","``","maintains","a","queue","of","edges","that","can","be","added","to","the","chart",".","This","queue","is","initialized","with","edges","for","each","token","in","the","text","that","is","being","parsed",".","``","BottomUpProbabilisticChartParser","``","inserts","these","edges","into","the","chart","one","at","a","time",",","starting","with","the","most","likely","edges",",","and","proceeding","to","less","likely","edges",".","For","each","edge","that","is","added","to","the","chart",",","it","may","become","possible","to","insert","additional","edges","into","the","chart",";","these","are","added","to","the","queue",".","This","process","continues","until","enough","complete","parses","have","been","generated",",","or","until","the","queue","is","empty",".","The","sorting","order","for","the","queue","is","not","specified","by","``","BottomUpProbabilisticChartParser","``",".","Different","sorting","orders","will","result","in","different","search","strategies",".","The","sorting","order","for","the","queue","is","defined","by","the","method","``","sort_queue","``",";","subclasses","are","required","to","provide","a","definition","for","this","method",".",":","type","_grammar",":","PCFG",":","ivar","_grammar",":","The","grammar","used","to","parse","sentences",".",":","type","_trace",":","int",":","ivar","_trace",":","The","level","of","tracing","output","that","should","be","generated","when","parsing","a","text","."]
code: def _setprob(self, tree, prod_probs):
      if tree.prob() is not None:
          return
  
      # Get the prob of the CFG production.
      lhs = Nonterminal(tree.label())
      rhs = []
      for child in tree:
          if isinstance(child, Tree):
              rhs.append(Nonterminal(child.label()))
          else:
              rhs.append(child)
      prob = prod_probs[lhs, tuple(rhs)]
  
      # Get the probs of children.
      for child in tree:
          if isinstance(child, Tree):
              self._setprob(child, prod_probs)
              prob *= child.prob()
  
      tree.set_prob(prob)
  
imports: import random
  from functools import reduce
  from nltk.grammar import PCFG, Nonterminal
  from nltk.parse.api import ParserI
  from nltk.parse.chart import AbstractChartRule, Chart, LeafEdge, TreeEdge
  from nltk.tree import ProbabilisticTree, Tree
label_desc: Use image node_id 5 for calling the BottomUpProbabilisticChartParser obj's underlying member method code with example usage: obj._setprob(tree, prod_probs) without return types