docs: def _learn(self, legislator):
          """
          Expects a dictionary with full_name, first_name, last_name and
          middle_name elements as key.
  
          While this can grow quickly, we should never be dealing with
          more than a few hundred legislators at a time so don't worry about
          it.
          """
          name, obj = legislator, legislator['_id']
  
          if (legislator['roles'] and legislator['roles'][0]['term'] ==
                  self._term and legislator['roles'][0]['type'] == 'member'):
              chamber = legislator['roles'][0]['chamber']
          else:
              try:
                  chamber = legislator['old_roles'][self._term][0].get('chamber')
              except KeyError:
                  raise ValueError("no role in legislator %s [%s] for term %s" %
                                   (legislator['full_name'], legislator['_id'],
                                    self._term))
  
          if '_code' in name:
              code = name['_code']
              if code in self._codes[chamber] or code in self._codes[None]:
                  raise ValueError("non-unique legislator code [%s] for %s" %
                                   (code, name['full_name']))
              self._codes[chamber][code] = obj
              self._codes[None][code] = obj
  
          # We throw possible forms of this name into a set because we
          # don't want to try to add the same form twice for the same
          # name
          forms = set()
  
          def add_form(form):
              forms.add(self._normalize(form))
  
          add_form(name['full_name'])
          add_form(name['_scraped_name'])
          add_form(name['last_name'])
  
          if name['first_name']:
              add_form("%s, %s" % (name['last_name'], name['first_name']))
              add_form("%s %s" % (name['first_name'], name['last_name']))
              add_form("%s, %s" % (name['last_name'], name['first_name'][0]))
              add_form("%s (%s)" % (name['last_name'], name['first_name']))
              add_form("%s %s" % (name['first_name'][0], name['last_name']))
              add_form("%s (%s)" % (name['last_name'], name['first_name'][0]))
  
              if name['middle_name']:
                  add_form("%s, %s %s" % (name['last_name'], name['first_name'],
                                          name['middle_name']))
                  add_form("%s, %s %s" % (name['last_name'],
                                          name['first_name'][0],
                                          name['middle_name']))
                  add_form("%s %s %s" % (name['first_name'],
                                         name['middle_name'],
                                         name['last_name']))
                  add_form("%s, %s %s" % (name['last_name'],
                                          name['first_name'][0],
                                          name['middle_name'][0]))
                  add_form("%s %s %s" % (name['first_name'],
                                         name['middle_name'][0],
                                         name['last_name']))
                  add_form("%s, %s %s" % (name['last_name'],
                                          name['first_name'],
                                          name['middle_name'][0]))
                  add_form("%s, %s.%s." % (name['last_name'],
                                           name['first_name'][0],
                                           name['middle_name'][0]))
  
          for form in forms:
              form = self._normalize(form)
              if form in self._names[chamber]:
                  self._names[chamber][form] = None
              else:
                  self._names[chamber][form] = obj
  
              if form in self._names[None]:
                  self._names[None][form] = None
              else:
                  self._names[None][form] = obj