class_docstr: Implements the *TextRank* algorithm defined by
  [[mihalcea04textrank]](https://derwen.ai/docs/ptr/biblio/#mihalcea04textrank),
  deployed as a `spaCy` pipeline component.
  
  This class does not get called directly; instantiate its factory
  instead.
      
class_docstr_tok: ["Implements","the","*","TextRank","*","algorithm","defined","by","[","[","mihalcea04textrank","]","]","(","https",":","\/\/derwen.ai\/docs\/ptr\/biblio\/","#","mihalcea04textrank",")",",","deployed","as","a","`","spaCy","`","pipeline","component",".","This","class","does","not","get","called","directly",";","instantiate","its","factory","instead","."]
docstr: Run an
  [*extractive summarization*](https://derwen.ai/docs/ptr/glossary/#extractive-summarization),
  based on the vector distance (per sentence) for each of the top-ranked phrases.
  
      limit_phrases:
  maximum number of top-ranked phrases to use in the distance vectors
  
      limit_sentences:
  total number of sentences to yield for the extractive summarization
  
      preserve_order:
  flag to preserve the order of sentences as they originally occurred in the source text; defaults to `False`
  
      level:
  default extractive summarization with `"sentence"` value; when set as `"paragraph`" get the average score per paragraph then sort the paragraphs to produce the summary
  
      yields:
  texts for sentences, in order
          
code: def summary(
      self,
      *,
      limit_phrases: int = 10,
      limit_sentences: int = 4,
      preserve_order: bool = False,
      level: str = "sentence",
  ) -> typing.Iterator[str]:
      """
      Run an
      [*extractive summarization*](https://derwen.ai/docs/ptr/glossary/#extractive-summarization),
      based on the vector distance (per sentence) for each of the top-ranked phrases.
  
          limit_phrases:
      maximum number of top-ranked phrases to use in the distance vectors
  
          limit_sentences:
      total number of sentences to yield for the extractive summarization
  
          preserve_order:
      flag to preserve the order of sentences as they originally occurred in the source text; defaults to `False`
  
          level:
      default extractive summarization with `"sentence"` value; when set as `"paragraph`" get the average score per paragraph then sort the paragraphs to produce the summary
  
          yields:
      texts for sentences, in order
      """
      # build a list of sentence indices sorted by distance
      sent_dist: typing.List[Sentence] = self.calc_sent_dist(
          limit_phrases
      )
  
      if level == "sentence":
          top_sent_ids: typing.List[int] = [
              sent.sent_id
              for sent in sorted(
                  sent_dist, key=lambda sent: sent.distance
              )
          ]
  
          # truncated to the specified limit
          limit = min(limit_sentences, len(top_sent_ids))
          top_sent_ids = top_sent_ids[:limit]
  
          # optional: sort in ascending order of index to preserve
          # the order in which sentences appear in the original text
          if preserve_order:
              top_sent_ids.sort()
  
          # extract sentences with the least distance, up to the limit
          # requested
          for sent_id in top_sent_ids:
              yield sent_dist[sent_id].text(self.doc)
  
      if level == "paragraph":
          top_sent_ids = [
              sent_id
              for p in sorted(
                  self.segment_paragraphs(sent_dist),
                  key=lambda x: x.distance,
              )
              for sent_id in range(p.start, p.end + 1)
          ]
  
          # truncate to the specified limit
          limit_para = min(limit_sentences, len(top_sent_ids))
          top_sent_ids = top_sent_ids[:limit_para]
  
          # optional: sort in ascending order of index to preserve
          # the order in which the sentences appear in the original
          # text
          if preserve_order:
              top_sent_ids.sort()
  
          # extract sentences with the least distance, up to the limit
          # requested
          for sent_id in top_sent_ids:
              yield sent_dist[sent_id].text(self.doc)
  
imports: from collections import Counter, defaultdict, OrderedDict
  from dataclasses import dataclass
  import json
  import math
  import pathlib
  import time
  import typing
  from icecream import ic
  from spacy.tokens import Doc, Span, Token
  import graphviz
  import networkx
  from .util import groupby_apply, default_scrubber
label_desc: Use image node_id 16 for calling the BaseTextRank obj's underlying member method code with example usage: obj.summary() without return types