class_docstr: A spaCy pipe for detecting hyponyms using Hearst patterns.
  This class sets the following attributes:
  
  - `Doc._.hearst_patterns`: A List[Tuple[str, Span, Span]] corresonding to
     the matching predicate, extracted general term and specific term
     that matched a Hearst pattern.
  
  Parts of the implementation taken from
  https://github.com/mmichelsonIF/hearst_patterns_python/blob/master/hearstPatterns/hearstPatterns.py
  and
  https://github.com/Fourthought/CNDPipeline/blob/master/cndlib/hpspacy.py
  
  The pipe can be used with an instantiated spacy model like so:
  ```
  # add the hyponym detector
  nlp.add_pipe('hyponym_detector', config={'extended': True}, last=True)
  
  Parameters
  ----------
  
  nlp: `Language`, a required argument for spacy to use this as a factory
  name: `str`, a required argument for spacy to use this as a factory
  extended: `bool`, whether to use the extended Hearts patterns or not
docstr: Expand a token to it's noun phrase based
  on a simple POS tag heuristic.
docstr_tok: ["Expand","a","token","to","it","'s","noun","phrase","based","on","a","simple","POS","tag","heuristic","."]
code: def expand_to_noun_compound(self, token: Token, doc: Doc):
      """
      Expand a token to it's noun phrase based
      on a simple POS tag heuristic.
      """
  
      start = token.i
      while True:
          if start - 1 < 0:
              break
          previous_token = doc[start - 1]
          if previous_token.pos_ in {"PROPN", "NOUN", "PRON"}:
              start -= 1
          else:
              break
  
      end = token.i + 1
      while True:
          if end >= len(doc):
              break
          next_token = doc[end]
          if next_token.pos_ in {"PROPN", "NOUN", "PRON"}:
              end += 1
          else:
              break
  
      return doc[start:end]
  
file_path: scispacy/scispacy/hyponym_detector.py
imports: from spacy.matcher import Matcher
  from spacy.tokens import Token, Doc
  from spacy.language import Language
  from scispacy.hearst_patterns import BASE_PATTERNS, EXTENDED_PATTERNS
label_desc: Use image node_id 2 for calling the HyponymDetector obj's underlying member method code with example usage: obj.expand_to_noun_compound(token, doc) and returns: doc