class_docstr: Class to compute a variety of basic, readability, morphological, and lexical diversity
  statistics for a given document.
  
  .. code-block:: pycon
  
      >>> text = next(textacy.datasets.CapitolWords().texts(limit=1))
      >>> doc = textacy.make_spacy_doc(text, lang="en_core_web_sm")
      >>> ts = textacy.text_stats.TextStats(doc)
      >>> ts.n_words
      137
      >>> ts.n_unique_words
      81
      >>> ts.entropy
      6.02267943673824
      >>> ts.readability("flesch-kincaid-grade-level")
      11.40259124087591
      >>> ts.diversity("ttr")
      0.5912408759124088
  
  Some readability stats vary by language or are designed for use with
  specific languages:
  
  .. code-block:: pycon
  
      >>> text = (
      ...     "Muchos años después, frente al pelotón de fusilamiento, "
      ...     "el coronel Aureliano Buendía había de recordar aquella tarde remota "
      ...     "en que su padre lo llevó a conocer el hielo."
      ... )
      >>> doc = textacy.make_spacy_doc(text, lang="es_core_news_sm")
      >>> ts = textacy.text_stats.TextStats(doc)
      >>> ts.readability("perspicuity-index")
      56.46000000000002
      >>> ts.readability("mu-legibility-index")
      71.18644067796609
  
  Each of these stats have stand-alone functions in :mod:`textacy.text_stats.basics` ,
  :mod:`textacy.text_stats.readability` , and :mod:`textacy.text_stats.diversity`
  with more detailed info and links in the docstrings -- when in doubt, read the docs!
  
  Args:
      doc: A text document tokenized and (optionally) sentence-segmented by spaCy.
  
  Warning:
      The ``TextStats`` class is deprecated as of v0.12. Instead,
      call the stats functions directly --
      ``text_stats.TextStats(doc).n_sents`` => ``text_stats.n_sents(doc)`` --
      or set them as custom doc extensions and access them from the ``Doc`` --
      ``textacy.set_doc_extensions('text_stats'); doc._.n_sents`` .
docstr: Number of words in document.
  
  See Also:
      :func:`textacy.text_stats.basics.n_words()`
docstr_tok: ["Number","of","words","in","document",".","See","Also",":",":","func",":","`","textacy.text_stats.basics.n_words","(",")","`"]
code: def n_words(self) -> int:
      """
      Number of words in document.
  
      See Also:
          :func:`textacy.text_stats.basics.n_words()`
      """
      if self._n_words is None:
          self._n_words = basics.n_words(self.words)
      return self._n_words
  
imports: from __future__ import annotations
  import logging
  from typing import Literal, Optional
  from spacy.tokens import Doc, Token
  from ..None import errors, extract, utils
  from .None import basics, counts, diversity, readability
label_desc: Use image node_id 3 for calling the TextStats obj's underlying member method code with example usage: obj.n_words() and returns: self