code: def get_surface(shifts, orig_text, item, text):
      
      span = item.span()
      logging.debug(u'\tInitial span: %s ("%s")', span, text[span[0]:span[1]])
  
      real_span = (span[0] - shifts[span[0]], span[1] - shifts[span[1] - 1])
      surface = orig_text[real_span[0]:real_span[1]]
      logging.debug(u'\tShifted span: %s ("%s")', real_span, surface)
  
      while any(surface.endswith(i) for i in [' ', '-']):
          surface = surface[:-1]
          real_span = (real_span[0], real_span[1] - 1)
  
      while surface.startswith(' '):
          surface = surface[1:]
          real_span = (real_span[0] + 1, real_span[1])
  
      logging.debug(u'\tFinal span: %s ("%s")', real_span, surface)
      return surface, real_span
docs: Extract surface from regex hit.