def _read_words ( filename ) : with tf . gfile . GFile ( filename , "r" ) as f : if sys . version_info [ 0 ] >= 3 : return f . read ( ) . replace ( "\n" , " %s " % EOS ) . split ( ) else : return f . read ( ) . decode ( "utf-8" ) . replace ( "\n" , " %s " % EOS ) . split ( )
python tensorflow read text file
Reads words from a file .
def _read_words(filename):
  """Reads words from a file."""
  with tf.gfile.GFile(filename, "r") as f:
    if sys.version_info[0] >= 3:
      return f.read().replace("\n", " %s " % EOS).split()
    else:
      return f.read().decode("utf-8").replace("\n", " %s " % EOS).split()