code: def disambiguate_unit(unit, text):
      
      new_unit = l.UNITS[unit]
      if not new_unit:
          new_unit = l.LOWER_UNITS[unit.lower()]
          if not new_unit:
              raise KeyError('Could not find unit "%s"' % unit)
  
      if len(new_unit) > 1:
          transformed = TFIDF_MODEL.transform([clean_text(text)])
          scores = CLF.predict_proba(transformed).tolist()[0]
          scores = sorted(zip(scores, TARGET_NAMES), key=lambda x: x[0],
                          reverse=True)
          names = [i.name for i in new_unit]
          scores = [i for i in scores if i[1] in names]
          try:
              final = l.UNITS[scores[0][1]][0]
              logging.debug('\tAmbiguity resolved for "%s" (%s)', unit, scores)
          except IndexError:
              logging.debug('\tAmbiguity not resolved for "%s"', unit)
              final = new_unit[0]
      else:
          final = new_unit[0]
  
      return final
docs: Resolve ambiguity.
  
      Distinguish between units that have same names, symbols or abbreviations.