(input_str)
return string
Clean English string with tensorflow oprations.
Clean English string with tensorflow oprations.
Clean English string with tensorflow oprations .
def clean_english_str_tf(input_str):
  """Clean English string with tensorflow oprations."""
  # pylint: disable=anomalous-backslash-in-string
  string = tf.regex_replace(input_str, r"[^A-Za-z0-9(),!?\'\`<>/]", " ")
  string = tf.regex_replace(string, "\'s", " \'s")
  string = tf.regex_replace(string, "\'ve", " \'ve")
  string = tf.regex_replace(string, "n\'t", " n\'t")
  string = tf.regex_replace(string, "\'re", " \'re")
  string = tf.regex_replace(string, "\'d", " \'d")
  string = tf.regex_replace(string, "\'ll", " \'ll")
  string = tf.regex_replace(string, ",", " , ")
  string = tf.regex_replace(string, "!", " ! ")
  string = tf.regex_replace(string, "\(", " ( ")
  string = tf.regex_replace(string, "\)", " ) ")
  string = tf.regex_replace(string, "\?", " ? ")
  string = tf.regex_replace(string, "\s{2,}", " ")
  string = tf.string_strip(string)
  string = py_x_ops.str_lower(string)
  return string
def clean_english_str_tf ( input_str ) : # pylint: disable=anomalous-backslash-in-string string = tf . regex_replace ( input_str , r"[^A-Za-z0-9(),!?\'\`<>/]" , " " ) string = tf . regex_replace ( string , "\'s" , " \'s" ) string = tf . regex_replace ( string , "\'ve" , " \'ve" ) string = tf . regex_replace ( string , "n\'t" , " n\'t" ) string = tf . regex_replace ( string , "\'re" , " \'re" ) string = tf . regex_replace ( string , "\'d" , " \'d" ) string = tf . regex_replace ( string , "\'ll" , " \'ll" ) string = tf . regex_replace ( string , "," , " , " ) string = tf . regex_replace ( string , "!" , " ! " ) string = tf . regex_replace ( string , "\(" , " ( " ) string = tf . regex_replace ( string , "\)" , " ) " ) string = tf . regex_replace ( string , "\?" , " ? " ) string = tf . regex_replace ( string , "\s{2,}" , " " ) string = tf . string_strip ( string ) string = py_x_ops . str_lower ( string ) return string