code: def test_term_stats():
      schema = fields.Schema(t=fields.TEXT)
      ix = RamStorage().create_index(schema)
      w = ix.writer()
      w.add_document(t=u("alfa bravo charlie delta echo"))
      w.add_document(t=u("bravo charlie delta echo foxtrot"))
      w.add_document(t=u("charlie delta echo foxtrot golf"))
      w.add_document(t=u("delta echo foxtrot"))
      w.add_document(t=u("echo foxtrot golf hotel india juliet"))
      w.add_document(t=u("foxtrot alfa alfa alfa"))
      w.commit()
  
      with ix.reader() as r:
          ti = r.term_info("t", u("alfa"))
          assert ti.weight() == 4.0
          assert ti.doc_frequency() == 2
          assert ti.min_length() == 4
          assert ti.max_length() == 5
          assert ti.max_weight() == 3.0
  
          assert r.term_info("t", u("echo")).min_length() == 3
  
          assert r.doc_field_length(3, "t") == 3
          assert r.min_field_length("t") == 3
          assert r.max_field_length("t") == 6
  
      w = ix.writer()
      w.add_document(t=u("alfa"))
      w.add_document(t=u("bravo charlie"))
      w.add_document(t=u("echo foxtrot tango bravo"))
      w.add_document(t=u("golf hotel"))
      w.add_document(t=u("india"))
      w.add_document(
          t=u("juliet alfa bravo charlie delta echo foxtrot")
      )
      w.commit(merge=False)
  
      with ix.reader() as r:
          ti = r.term_info("t", u("alfa"))
          assert ti.weight() == 6.0
          assert ti.doc_frequency() == 4
          assert ti.min_length() == 1
          assert ti.max_length() == 7
          assert ti.max_weight() == 3.0
  
          assert r.term_info("t", u("echo")).min_length() == 3
  
          assert r.min_field_length("t") == 1
          assert r.max_field_length("t") == 7
  
file_path: whoosh/tests/test_quality.py
imports: from __future__ import with_statement
  import random
  from whoosh import fields, matching, scoring
  from whoosh.compat import u, xrange
  from whoosh.filedb.filestore import RamStorage
  from whoosh.util.numeric import length_to_byte, byte_to_length
label_desc: Use image node_id 4 for calling a global function with example usage: test_term_stats() without return types