def build_tensorize_text_fn(embeddings):
  """Builds a function to turn text into word/char ids."""
  tbl = contrib_lookup.index_table_from_tensor(
      mapping=embeddings.get_vocab(), num_oov_buckets=1)

  def fn(string_tensor):
    """Builds the output tensor dictionary."""
    out = {}
    if FLAGS.lowercase:
      string_tensor = ops.lowercase_op(string_tensor)
    out["wids"] = tf.to_int32(tbl.lookup(string_tensor))
    out["cids"] = char_utils.batch_word_to_char_ids(string_tensor, 50)
    out["len"] = tf.shape(string_tensor)[-1]
    return out

  return fn
Builds a function to turn text into word/char ids.
language/boolq/run_recurrent_model_boolq.py