code: def _get_grounding(entity):
      
      db_refs = {'TEXT': entity['text']}
      groundings = entity.get('grounding')
      if not groundings:
          return db_refs
  
      def get_ont_concept(concept):
          """Strip slash, replace spaces and remove example leafs."""
          # In the WM context, groundings have no URL prefix and start with /
          # The following block does some special handling of these groundings.
          if concept.startswith('/'):
              concept = concept[1:]
              concept = concept.replace(' ', '_')
              # We eliminate any entries that aren't ontology categories
              # these are typically "examples" corresponding to the category
              while concept not in hume_onto_entries:
                  parts = concept.split('/')
                  if len(parts) == 1:
                      break
                  concept = '/'.join(parts[:-1])
          # Otherwise we just return the concept as is
          return concept
  
      # Basic collection of grounding entries
      raw_grounding_entries = [(get_ont_concept(g['ontologyConcept']),
                                g['value']) for g in groundings]
  
      # Occasionally we get duplicate grounding entries, we want to
      # eliminate those here
      grounding_dict = {}
      for cat, score in raw_grounding_entries:
          if (cat not in grounding_dict) or (score > grounding_dict[cat]):
              grounding_dict[cat] = score
      # Then we sort the list in reverse order according to score
      # Sometimes the exact same score appears multiple times, in this
      # case we prioritize by the "depth" of the grounding which is
      # obtained by looking at the number of /-s in the entry.
      # However, there are still cases where the grounding depth and the score
      # are the same. In these cases we just sort alphabetically.
      grounding_entries = sorted(list(set(grounding_dict.items())),
                                 key=lambda x: (x[1], x[0].count('/'), x[0]),
                                 reverse=True)
      # We could get an empty list here in which case we don't add the
      # grounding
      if grounding_entries:
          db_refs['HUME'] = grounding_entries
      return db_refs
docs: Return Hume grounding.