code: def test_add_pipe(nlp: Language):
      """
      Works as a pipeline component and can be disabled.
      """
      # given
      nlp.add_pipe("topicrank", last=True)
  
      # works as a pipeline component
      # when
      text = "linear constraints over the"
      doc = nlp(text)
      phrases = [p.text for p in doc._.phrases]
  
      # then
      assert len(doc._.phrases) > 0
      assert any(map(lambda x: "constraints" in x, phrases))
  
      # identifies phrases not in noun chunks
      # when
      text = """\
  everything you need to know about student loan interest rates, variable \
  and fixed rates, capitalization, amortization, student loan refinancing \
  and more.\
  """
  
      doc = nlp(text)
      phrases = [p.text for p in doc._.phrases]
  
      # then
      assert len(doc._.phrases) >= 2
  
      # resolves Py 3.5 dict KeyError
      # when
      text = "linear constraints over the set of natural numbers"
      doc = nlp(text)
      phrases = [p.text for p in doc._.phrases]
  
      # then
      assert any(map(lambda x: "constraints" in x, phrases))
  
      # pipeline can be disabled
      # when
      with nlp.select_pipes(disable=["topicrank"]):
          doc = nlp(text)
  
          # then
          assert len(doc._.phrases) == 0
  
file_path: pytextrank/tests/test_topicrank.py
imports: from spacy.language import Language
  from spacy.tokens import Span, Doc
  import spacy
  import sys
  from pytextrank.topicrank import TopicRankFactory
label_desc: Use image node_id 2 for calling a global function with example usage: test_add_pipe(nlp) without return types