def trie_add(trie, seq_value_2tuples, terminus=0):
 for (seq, value) in seq_value_2tuples:
  this = trie
  w_len = (len(seq) - 1)
  for (i, c) in enumerate(seq):
   if (c in ",. '&[]"):
    continue
   try:
    this = this[c]
   except KeyError:
    this[c] = {}
    this = this[c]
   if (i == w_len):
    this[terminus] = value
 return trie

def trie_add ( trie , seq_value_2tuples , terminus = 0 ) : for ( seq , value ) in seq_value_2tuples : this = trie w_len = ( len ( seq ) - 1 ) for ( i , c ) in enumerate ( seq ) : if ( c in ",. '&[]" ) : continue try : this = this [ c ] except KeyError : this [ c ] = { } this = this [ c ] if ( i == w_len ) : this [ terminus ] = value return trie
given a trie .