def get_actor(tr, chamber):
 actor = tr[0].text_content().strip()
 if (actor.startswith('H') or actor.startswith('S')):
  actor = actor[0]
  return {'H': 'lower', 'S': 'upper'}[actor]
 else:
  h_or_s = tr.xpath(('ancestor::table[1]/preceding-sibling::' + 'table/tr/td/b[contains(text(), "TRANSMIT TO")]'))
  if h_or_s:
   h_or_s = h_or_s[(-1)].text_content().strip()
   actor = ('upper' if h_or_s.endswith('SENATE:') else 'lower')
  else:
   actor = chamber
  return actor

def get_actor ( tr , chamber ) : actor = tr [ 0 ] . text_content ( ) . strip ( ) if ( actor . startswith ( 'H' ) or actor . startswith ( 'S' ) ) : actor = actor [ 0 ] return { 'H' : 'lower' , 'S' : 'upper' } [ actor ] else : h_or_s = tr . xpath ( ( 'ancestor::table[1]/preceding-sibling::' + 'table/tr/td/b[contains(text(), "TRANSMIT TO")]' ) ) if h_or_s : h_or_s = h_or_s [ ( - 1 ) ] . text_content ( ) . strip ( ) actor = ( 'upper' if h_or_s . endswith ( 'SENATE:' ) else 'lower' ) else : actor = chamber return actor
gets the actor of a given action based on presence of a transmit to action .