class_docstr: Detects abbreviations using the algorithm in "A simple algorithm for identifying
  abbreviation definitions in biomedical text.", (Schwartz & Hearst, 2003).
  
  This class sets the `._.abbreviations` attribute on spaCy Doc.
  
  The abbreviations attribute is a `List[Span]` where each Span has the `Span._.long_form`
  attribute set to the long form definition of the abbreviation.
  
  Note that this class does not replace the spans, or merge them.
  
  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
  make_serializable: `bool`, a required argument for whether we want to use the serializable
  or non serializable version.
class_docstr_tok: ["Detects","abbreviations","using","the","algorithm","in","``","A","simple","algorithm","for","identifying","abbreviation","definitions","in","biomedical","text",".","``",",","(","Schwartz","&","Hearst",",","2003",")",".","This","class","sets","the","`","._.abbreviations","`","attribute","on","spaCy","Doc",".","The","abbreviations","attribute","is","a","`","List","[","Span","]","`","where","each","Span","has","the","`","Span._.long_form","`","attribute","set","to","the","long","form","definition","of","the","abbreviation",".","Note","that","this","class","does","not","replace","the","spans",",","or","merge","them",".","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","make_serializable",":","`","bool","`",",","a","required","argument","for","whether","we","want","to","use","the","serializable","or","non","serializable","version","."]
code: def find_matches_for(
      self, filtered: List[Tuple[Span, Span]], doc: Doc
  ) -> List[Tuple[Span, Set[Span]]]:
      rules = {}
      all_occurences: Dict[Span, Set[Span]] = defaultdict(set)
      already_seen_long: Set[str] = set()
      already_seen_short: Set[str] = set()
      for long_candidate, short_candidate in filtered:
          short, long = find_abbreviation(
              long_candidate, short_candidate
          )
          # We need the long and short form definitions to be unique, because we need
          # to store them so we can look them up later. This is a bit of a
          # pathalogical case also, as it would mean an abbreviation had been
          # defined twice in a document. There's not much we can do about this,
          # but at least the case which is discarded will be picked up below by
          # the global matcher. So it's likely that things will work out ok most of the time.
          new_long = (
              long.text not in already_seen_long if long else False
          )
          new_short = short.text not in already_seen_short
          if long is not None and new_long and new_short:
              already_seen_long.add(long.text)
              already_seen_short.add(short.text)
              all_occurences[long].add(short)
              rules[long.text] = long
              # Add a rule to a matcher to find exactly this substring.
              self.global_matcher.add(
                  long.text, [[{"ORTH": x.text} for x in short]]
              )
      to_remove = set()
      global_matches = self.global_matcher(doc)
      for match, start, end in global_matches:
          string_key = self.global_matcher.vocab.strings[match]  # type: ignore
          to_remove.add(string_key)
          all_occurences[rules[string_key]].add(doc[start:end])
      for key in to_remove:
          # Clean up the global matcher.
          self.global_matcher.remove(key)
  
      return list((k, v) for k, v in all_occurences.items())
  
file_path: scispacy/scispacy/abbreviation.py
imports: from typing import Tuple, List, Optional, Set, Dict
  from collections import defaultdict
  from spacy.tokens import Span, Doc
  from spacy.matcher import Matcher
  from spacy.language import Language
label_desc: Use image node_id 4 for calling the AbbreviationDetector obj's underlying member method code with example usage: obj.find_matches_for(filtered, doc) and returns: list