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: Construct a *unit vector* representing the top-ranked phrases in a
  `spaCy` [`Doc`](https://spacy.io/api/doc) document.
  This provides a *characteristic* for comparing each sentence to the
  entire document.
  Taking the ranked phrases in descending order, the unit vector is a
  normalized list of their calculated ranks, up to the specified limit.
  
      limit_phrases:
  maximum number of top-ranked phrases to use in the *unit vector*
  
      returns:
  the unit vector, as a list of `VectorElem` objects
          
code: def get_unit_vector(
      self,
      limit_phrases: int,
  ) -> typing.List[VectorElem]:
      """
      Construct a *unit vector* representing the top-ranked phrases in a
      `spaCy` [`Doc`](https://spacy.io/api/doc) document.
      This provides a *characteristic* for comparing each sentence to the
      entire document.
      Taking the ranked phrases in descending order, the unit vector is a
      normalized list of their calculated ranks, up to the specified limit.
  
          limit_phrases:
      maximum number of top-ranked phrases to use in the *unit vector*
  
          returns:
      the unit vector, as a list of `VectorElem` objects
      """
      unit_vector: typing.List[VectorElem] = [
          VectorElem(
              phrase=p,
              phrase_id=phrase_id,
              coord=p.rank,
          )
          for phrase_id, p in enumerate(self.doc._.phrases)
      ]
  
      # truncate to the specified limit
      limit = min(limit_phrases, len(unit_vector))
      unit_vector = unit_vector[:limit]
  
      # normalize the phrase coordinates, such that the unit vector
      # has length = 1.0
      sum_length = sum([elem.coord for elem in unit_vector])
  
      for elem in unit_vector:
          if sum_length > 0.0:
              elem.coord = elem.coord / sum_length
          else:
              elem.coord = 0.0
  
      return unit_vector
  
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 13 for calling the BaseTextRank obj's underlying member method code with example usage: obj.get_unit_vector(limit_phrases) and returns: unit_vector