tools/media_engagement_preload/make_dafsa.py
def encode(dafsa):
  """Encodes a DAFSA to a list of bytes"""
  output = []
  offsets = {}

  for node in reversed(top_sort(dafsa)):
    if (len(node[1]) == 1 and node[1][0] and
        (offsets[id(node[1][0])] == len(output))):
      output.extend(encode_prefix(node[0]))
    else:
      output.extend(encode_links(node[1], offsets, len(output)))
      output.extend(encode_label(node[0]))
    offsets[id(node)] = len(output)

  output.extend(encode_links(dafsa, offsets, len(output)))
  output.reverse()
  return output
Encodes a DAFSA to a list of bytes
Encodes a DAFSA to a list of bytes
Encodes a DAFSA to a list of bytes
def encode(dafsa):
  output = []
  offsets = {}
  for node in reversed(top_sort(dafsa)):
    if (len(node[1]) == 1 and node[1][0] and
        (offsets[id(node[1][0])] == len(output))):
      output.extend(encode_prefix(node[0]))
    else:
      output.extend(encode_links(node[1], offsets, len(output)))
      output.extend(encode_label(node[0]))
    offsets[id(node)] = len(output)
  output.extend(encode_links(dafsa, offsets, len(output)))
  output.reverse()
  return output
def encode ( dafsa ) : output = [ ] offsets = { } for node in reversed ( top_sort ( dafsa ) ) : if ( len ( node [ 1 ] ) == 1 and node [ 1 ] [ 0 ] and ( offsets [ id ( node [ 1 ] [ 0 ] ) ] == len ( output ) ) ) : output . extend ( encode_prefix ( node [ 0 ] ) ) else : output . extend ( encode_links ( node [ 1 ] , offsets , len ( output ) ) ) output . extend ( encode_label ( node [ 0 ] ) ) offsets [ id ( node ) ] = len ( output ) output . extend ( encode_links ( dafsa , offsets , len ( output ) ) ) output . reverse ( ) return output
Encodes a DAFSA to a list of bytes
Encodes a DAFSA to a list of bytes
"""Encodes a DAFSA to a list of bytes"""
dafsa