parameters: (self, snode, *contents, **kwargs)
return_statement: return current
docstring: :param snode: SchemaContentNode
          :param contents: Array of one node - the self.counts node
          :param kwargs:
          :return:
docstring_summary: :param snode: SchemaContentNode
          :param contents: Array of one node - the self.counts node
          :param kwargs:
          :return:
docstring_tokens: : param snode : SchemaContentNode : param contents : Array of one node - the self . counts node : param kwargs : : return :
function: def _content_node_visitor(self, snode, *contents, **kwargs):
          """
          :param snode: SchemaContentNode
          :param contents: Array of one node - the self.counts node
          :param kwargs:
          :return:
          """
          assert len(contents) == 1
          current = contents[0]  # some information is manually set - don't wipe and re-create it.   todo: just copy flags?
          depth = snode.depth  # This also acts as an assertion that we have a SchemaContentNode
          ja = {}  # JaggedIntArrays for each language and 'all'
          padded_ja = {}  # Padded JaggedIntArrays for each language
  
          # Get base counts for each language
          for lang, lkey in list(self.lang_map.items()):
              if not current.get(lkey):
                  current[lkey] = {}
  
              ja[lkey] = self._node_count(snode, lang)
  
          # Sum all of the languages
          ja['_all'] = reduce(lambda x, y: x + y, [ja[lkey] for lkey in self.lang_keys])
          zero_mask = ja['_all'].zero_mask()
          current["_all"] = {
              "availableTexts": ja['_all'].array(),
              "shape": ja['_all'].shape()
          }
          # Get derived data for all languages
          for lang, lkey in list(self.lang_map.items()):
              # build zero-padded count ("availableTexts")
              padded_ja[lkey] = ja[lkey] + zero_mask
              current[lkey]["availableTexts"] = padded_ja[lkey].array()
  
              # number of units at each level ("availableCounts") from raw counts
              # depth_sum() reduces anything greater than 1 to 1,
              # so that the count returned is an accurate measure of how much material is there
              current[lkey]["availableCounts"] = [ja[lkey].depth_sum(d) for d in range(depth)]
  
              # Percent of text available, versus its metadata count ("percentAvailable")
              # and if it's a valid measure ('percentAvailableInvalid')
              if getattr(snode, "lengths", None):
                  if len(snode.lengths) == depth:
                      langtotal = reduce(lambda x, y: x + y, current[lkey]["availableCounts"])
                      schematotal = reduce(lambda x, y: x + y, snode.lengths)
                      try:
                          current[lkey]["percentAvailable"] = langtotal / float(schematotal) * 100
                      except ZeroDivisionError:
                          current[lkey]["percentAvailable"] = 0
                  elif len(snode.lengths) < depth:
                      current[lkey]["percentAvailable"] = current[lkey]["availableCounts"][0] / float(snode.lengths[0]) * 100
                  else:
                      raise Exception("Text has less sections than node.lengths for {}".format(snode.full_title()))
                  current[lkey]['percentAvailableInvalid'] = current[lkey]["percentAvailable"] > 100
              else:
                  current[lkey]["percentAvailable"] = 0
                  current[lkey]['percentAvailableInvalid'] = True
  
              # Is this text complete? ("textComplete")
              current[lkey]["textComplete"] = current[lkey]["percentAvailable"] > 99.9
  
              # What percent complete? ('completenessPercent')
              # are we doing this with the zero-padded array on purpose?
              current[lkey]['completenessPercent'] = self._calc_text_structure_completeness(depth, current[lkey]["availableTexts"])
  
          return current
function_tokens: def _content_node_visitor ( self , snode , * contents , * * kwargs ) : assert len ( contents ) == 1 current = contents [ 0 ] # some information is manually set - don't wipe and re-create it.   todo: just copy flags? depth = snode . depth # This also acts as an assertion that we have a SchemaContentNode ja = { } # JaggedIntArrays for each language and 'all' padded_ja = { } # Padded JaggedIntArrays for each language # Get base counts for each language for lang , lkey in list ( self . lang_map . items ( ) ) : if not current . get ( lkey ) : current [ lkey ] = { } ja [ lkey ] = self . _node_count ( snode , lang ) # Sum all of the languages ja [ '_all' ] = reduce ( lambda x , y : x + y , [ ja [ lkey ] for lkey in self . lang_keys ] ) zero_mask = ja [ '_all' ] . zero_mask ( ) current [ "_all" ] = { "availableTexts" : ja [ '_all' ] . array ( ) , "shape" : ja [ '_all' ] . shape ( ) } # Get derived data for all languages for lang , lkey in list ( self . lang_map . items ( ) ) : # build zero-padded count ("availableTexts") padded_ja [ lkey ] = ja [ lkey ] + zero_mask current [ lkey ] [ "availableTexts" ] = padded_ja [ lkey ] . array ( ) # number of units at each level ("availableCounts") from raw counts # depth_sum() reduces anything greater than 1 to 1, # so that the count returned is an accurate measure of how much material is there current [ lkey ] [ "availableCounts" ] = [ ja [ lkey ] . depth_sum ( d ) for d in range ( depth ) ] # Percent of text available, versus its metadata count ("percentAvailable") # and if it's a valid measure ('percentAvailableInvalid') if getattr ( snode , "lengths" , None ) : if len ( snode . lengths ) == depth : langtotal = reduce ( lambda x , y : x + y , current [ lkey ] [ "availableCounts" ] ) schematotal = reduce ( lambda x , y : x + y , snode . lengths ) try : current [ lkey ] [ "percentAvailable" ] = langtotal / float ( schematotal ) * 100 except ZeroDivisionError : current [ lkey ] [ "percentAvailable" ] = 0 elif len ( snode . lengths ) < depth : current [ lkey ] [ "percentAvailable" ] = current [ lkey ] [ "availableCounts" ] [ 0 ] / float ( snode . lengths [ 0 ] ) * 100 else : raise Exception ( "Text has less sections than node.lengths for {}" . format ( snode . full_title ( ) ) ) current [ lkey ] [ 'percentAvailableInvalid' ] = current [ lkey ] [ "percentAvailable" ] > 100 else : current [ lkey ] [ "percentAvailable" ] = 0 current [ lkey ] [ 'percentAvailableInvalid' ] = True # Is this text complete? ("textComplete") current [ lkey ] [ "textComplete" ] = current [ lkey ] [ "percentAvailable" ] > 99.9 # What percent complete? ('completenessPercent') # are we doing this with the zero-padded array on purpose? current [ lkey ] [ 'completenessPercent' ] = self . _calc_text_structure_completeness ( depth , current [ lkey ] [ "availableTexts" ] ) return current