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
code: def __init__(
      self,
      nlp: Language,
      name: str = "hyponym_detector",
      extended: bool = False,
  ):
      self.nlp = nlp
  
      self.patterns = BASE_PATTERNS
      if extended:
          self.patterns.extend(EXTENDED_PATTERNS)
  
      self.matcher = Matcher(self.nlp.vocab)
  
      Doc.set_extension("hearst_patterns", default=[], force=True)
  
      self.first = set()
      self.last = set()
  
      # add patterns to matcher
      for pattern in self.patterns:
          self.matcher.add(pattern["label"], [pattern["pattern"]])
  
          # gather list of predicates where the hypernym appears first
          if pattern["position"] == "first":
              self.first.add(pattern["label"])
  
          # gather list of predicates where the hypernym appears last
          if pattern["position"] == "last":
              self.last.add(pattern["label"])
  
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 1 to create a new HyponymDetector object  with example: obj = HyponymDetector(nlp, name, extended)