class_docstr: beam with text, optical and textual score
docstr: extend beam by new character and set optical score
docstr_tok: ["extend","beam","by","new","character","and","set","optical","score"]
code: def createChildBeam(self, newChar, prBlank, prNonBlank):
      "extend beam by new character and set optical score"
      beam = Beam(self.lm, self.useNGrams)
  
      # copy textual information
      beam.textual = copy.deepcopy(self.textual)
      beam.textual.text += newChar
  
      # do textual calculations only if beam gets extended
      if newChar != "":
          if self.useNGrams:  # use unigrams and bigrams
              # if new char occurs inside a word
              if newChar in beam.lm.getWordChars():
                  beam.textual.wordDev += newChar
                  nextWords = beam.lm.getNextWords(beam.textual.wordDev)
  
                  # no complete word in text, then use unigram of all possible next words
                  numWords = len(beam.textual.wordHist)
                  prSum = 0
                  if numWords == 0:
                      for w in nextWords:
                          prSum += beam.lm.getUnigramProb(w)
                  # take last complete word and sum up bigrams of all possible next words
                  else:
                      lastWord = beam.textual.wordHist[-1]
                      for w in nextWords:
                          prSum += beam.lm.getBigramProb(lastWord, w)
                  beam.textual.prTotal = (
                      beam.textual.prUnnormalized * prSum
                  )
                  beam.textual.prTotal = (
                      beam.textual.prTotal ** (1 / (numWords + 1))
                      if numWords >= 1
                      else beam.textual.prTotal
                  )
  
              # if new char does not occur inside a word
              else:
                  # if current word is not empty, add it to history
                  if beam.textual.wordDev != "":
                      beam.textual.wordHist.append(beam.textual.wordDev)
                      beam.textual.wordDev = ""
  
                      # score with unigram (first word) or bigram (all other words) probability
                      numWords = len(beam.textual.wordHist)
                      if numWords == 1:
                          beam.textual.prUnnormalized *= (
                              beam.lm.getUnigramProb(
                                  beam.textual.wordHist[-1]
                              )
                          )
                          beam.textual.prTotal = (
                              beam.textual.prUnnormalized
                          )
                      elif numWords >= 2:
                          beam.textual.prUnnormalized *= (
                              beam.lm.getBigramProb(
                                  beam.textual.wordHist[-2],
                                  beam.textual.wordHist[-1],
                              )
                          )
                          beam.textual.prTotal = (
                              beam.textual.prUnnormalized
                              ** (1 / numWords)
                          )
  
          else:  # don't use unigrams and bigrams, just keep wordDev up to date
              if newChar in beam.lm.getWordChars():
                  beam.textual.wordDev += newChar
              else:
                  beam.textual.wordDev = ""
  
      # set optical information
      beam.optical.prBlank = prBlank
      beam.optical.prNonBlank = prNonBlank
      return beam
  
imports: from __future__ import division
  from __future__ import print_function
  import copy
label_desc: Use image node_id 9 for calling the Beam obj's underlying member method code with example usage: obj.createChildBeam(newChar, prBlank, prNonBlank) and returns: beam