code: def _extract_sentence_tags(tagged_sentence):
      
      untagged_sentence = _untag_sentence(tagged_sentence)
      decluttered_sentence = JUNK_PATT.sub('', tagged_sentence)
      tags = {}
  
      # Iteratively look for all matches of this pattern
      endpos = 0
      while True:
          match = TAG_PATT.search(decluttered_sentence, pos=endpos)
          if not match:
              break
          endpos = match.end()
          text = match.group(2)
          text = text.replace('CONTEXT', '')
          text = text.replace('GLOSSARY', '')
          text = text.strip()
          start = untagged_sentence.index(text)
          stop = start + len(text)
  
          tag_key = match.group(1)
          if ',' in tag_key:
              for sub_key in tag_key.split(','):
                  if sub_key == '0':
                      continue
                  tags[sub_key] = {'text': text, 'bounds': (start, stop)}
          else:
              tags[tag_key] = {'text': text, 'bounds': (start, stop)}
      return tags
docs: Given a tagged sentence, extracts a dictionary mapping tags to the words
      or phrases that they tag.
  
      Parameters
      ----------
      tagged_sentence : str
          The sentence with Medscan annotations and tags
  
      Returns
      -------
      tags : dict
          A dictionary mapping tags to the words or phrases that they tag.