code: def test_ngrams():
      s = u("abcdefg h ij klm")
      tk = analysis.RegexTokenizer(r"\S+")
  
      def dotest(f):
          ana = tk | f
          tokens = ana(s, positions=True, chars=True)
          return "/".join(t.text for t in tokens)
  
      f = analysis.NgramFilter(3, 4)
      assert dotest(f) == "abc/abcd/bcd/bcde/cde/cdef/def/defg/efg/klm"
  
      f = analysis.NgramFilter(3, 4, at="start")
      assert dotest(f) == "abc/abcd/klm"
  
      f = analysis.NgramFilter(3, 4, at="end")
      assert dotest(f) == "defg/efg/klm"
  
      ana = tk | analysis.NgramFilter(2, 5, at="end")
      tokens = [
          (t.text, t.startchar, t.endchar) for t in ana(s, chars=True)
      ]
      assert tokens == [
          ("cdefg", 2, 7),
          ("defg", 3, 7),
          ("efg", 4, 7),
          ("fg", 5, 7),
          ("ij", 10, 12),
          ("klm", 13, 16),
          ("lm", 14, 16),
      ]
  
imports: from __future__ import with_statement
  import pytest
  from whoosh import analysis, fields, qparser
  from whoosh.compat import b, u, unichr
  from whoosh.compat import dumps
  from whoosh.filedb.filestore import RamStorage
label_desc: Use image node_id 26 for calling a global function with example usage: test_ngrams() and returns: str