tools/media_engagement_preload/make_dafsa.py
def to_dafsa(words):
  """Generates a DAFSA from a word list and returns the source node.

  Each word is split into characters so that each character is represented by
  a unique node. It is assumed the word list is not empty.
  """
  if not words:
    raise InputError('The origin list must not be empty')
  def ToNodes(word):
    """Split words into characters"""
    if not 0x1F < ord(word[0]) < 0x80:
      raise InputError('Origins must be printable 7-bit ASCII')
    if len(word) == 1:
      return chr(ord(word[0]) & 0x0F), [None]
    return word[0], [ToNodes(word[1:])]
  return [ToNodes(word) for word in words]
Generates a DAFSA from a word list and returns the source node.

  Each word is split into characters so that each character is represented by
  a unique node. It is assumed the word list is not empty.
  
Generates a DAFSA from a word list and returns the source node.
Each word is split into characters so that each character is represented by
a unique node. It is assumed the word list is not empty.
Generates a DAFSA from a word list and returns the source node . Each word is split into characters so that each character is represented by a unique node . It is assumed the word list is not empty .
def to_dafsa(words):
  if not words:
    raise InputError('The origin list must not be empty')
  def ToNodes(word):
    if not 0x1F < ord(word[0]) < 0x80:
      raise InputError('Origins must be printable 7-bit ASCII')
    if len(word) == 1:
      return chr(ord(word[0]) & 0x0F), [None]
    return word[0], [ToNodes(word[1:])]
  return [ToNodes(word) for word in words]
def to_dafsa ( words ) : if not words : raise InputError ( 'The origin list must not be empty' ) def ToNodes ( word ) : """Split words into characters""" if not 0x1F < ord ( word [ 0 ] ) < 0x80 : raise InputError ( 'Origins must be printable 7-bit ASCII' ) if len ( word ) == 1 : return chr ( ord ( word [ 0 ] ) & 0x0F ) , [ None ] return word [ 0 ] , [ ToNodes ( word [ 1 : ] ) ] return [ ToNodes ( word ) for word in words ]
Generates a DAFSA from a word list and returns the source node.
Generates a DAFSA from a word list and returns the source node .
"""Generates a DAFSA from a word list and returns the source node.

  Each word is split into characters so that each character is represented by
  a unique node. It is assumed the word list is not empty.
  """ """Split words into characters"""
words