code: def build_span_analyzer(document, vec):
      """Return an analyzer and the preprocessed doc.
      Analyzer will yield pairs of spans and feature, where spans are pairs
      of indices into the preprocessed doc. The idea here is to do minimal
      preprocessing so that we can still recover the same features as sklearn
      vectorizers, but with spans, that will allow us to highlight
      features in preprocessed documents.
      Analyzers are adapted from VectorizerMixin from sklearn.
      """
      preprocessed_doc = vec.build_preprocessor()(vec.decode(document))
      analyzer = None
      if vec.analyzer == "word" and vec.tokenizer is None:
          stop_words = vec.get_stop_words()
          tokenize = _build_tokenizer(vec)
          analyzer = lambda doc: _word_ngrams(
              vec, tokenize(doc), stop_words
          )
      elif vec.analyzer == "char":
          preprocessed_doc = vec._white_spaces.sub(
              " ", preprocessed_doc
          )
          analyzer = lambda doc: _char_ngrams(vec, doc)
      elif vec.analyzer == "char_wb":
          preprocessed_doc = vec._white_spaces.sub(
              " ", preprocessed_doc
          )
          analyzer = lambda doc: _char_wb_ngrams(vec, doc)
      return analyzer, preprocessed_doc
  
file_path: eli5/eli5/sklearn/_span_analyzers.py
imports: from __future__ import absolute_import
  import re
  from six.moves import xrange
label_desc: Use image node_id 1 for calling a global function with example usage: build_span_analyzer(document, vec) and returns: analyzer,  preprocessed_doc