def initialize_vocabulary(vocabulary_path):
 if gfile.Exists(vocabulary_path):
  rev_vocab = []
  with gfile.GFile(vocabulary_path, mode='rb') as f:
   rev_vocab.extend(f.readlines())
  rev_vocab = [tf.compat.as_bytes(line.strip()) for line in rev_vocab]
  vocab = dict([(x, y) for (y, x) in enumerate(rev_vocab)])
  return (vocab, rev_vocab)
 else:
  raise ValueError('Vocabulary file %s not found.', vocabulary_path)

def initialize_vocabulary ( vocabulary_path ) : if gfile . Exists ( vocabulary_path ) : rev_vocab = [ ] with gfile . GFile ( vocabulary_path , mode = 'rb' ) as f : rev_vocab . extend ( f . readlines ( ) ) rev_vocab = [ tf . compat . as_bytes ( line . strip ( ) ) for line in rev_vocab ] vocab = dict ( [ ( x , y ) for ( y , x ) in enumerate ( rev_vocab ) ] ) return ( vocab , rev_vocab ) else : raise ValueError ( 'Vocabulary file %s not found.' , vocabulary_path )
initialize vocabulary from file .