nodes: 0, module; 1, function_definition; 2, function_name:names_to_abbreviations; 3, parameters; 4, block; 5, identifier:reporters; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, expression_statement; 10, return_statement; 11, comment:"""Build a dict mapping names to their variations
  
      Something like:
  
          {
              "Atlantic Reporter": ['A.', 'A.2d'],
          }
  
      Note that the abbreviations are sorted by start date.
      """; 12, assignment; 13, pattern_list; 14, call; 15, block; 16, assignment; 17, identifier:sorted_names; 18, identifier:names; 19, dictionary; 20, identifier:reporter_key; 21, identifier:data_list; 22, attribute; 23, argument_list; 24, for_statement; 25, identifier:sorted_names; 26, call; 27, identifier:reporters; 28, identifier:items; 29, identifier:data; 30, identifier:data_list; 31, block; 32, identifier:OrderedDict; 33, argument_list; 34, expression_statement; 35, comment:# Sort abbreviations by start date of the edition; 36, expression_statement; 37, expression_statement; 38, expression_statement; 39, call; 40, assignment; 41, assignment; 42, assignment; 43, assignment; 44, identifier:sorted; 45, argument_list; 46, identifier:abbrevs; 47, call; 48, identifier:sort_func; 49, lambda; 50, identifier:abbrevs; 51, call; 52, subscript; 53, identifier:abbrevs; 54, call; 55, keyword_argument; 56, attribute; 57, argument_list; 58, lambda_parameters; 59, binary_operator:str(data['editions'][x]['start']) + x; 60, identifier:sorted; 61, argument_list; 62, identifier:names; 63, subscript; 64, attribute; 65, argument_list; 66, identifier:key; 67, lambda; 68, subscript; 69, identifier:keys; 70, identifier:x; 71, call; 72, identifier:x; 73, identifier:abbrevs; 74, keyword_argument; 75, identifier:data; 76, string; 77, identifier:names; 78, identifier:items; 79, lambda_parameters; 80, subscript; 81, identifier:data; 82, string; 83, identifier:str; 84, argument_list; 85, identifier:key; 86, identifier:sort_func; 87, string_content:name; 88, identifier:t; 89, identifier:t; 90, integer:0; 91, string_content:editions; 92, subscript; 93, subscript; 94, string; 95, subscript; 96, identifier:x; 97, string_content:start; 98, identifier:data; 99, string; 100, string_content:editions
code: def names_to_abbreviations(reporters):
      """Build a dict mapping names to their variations
  
      Something like:
  
          {
              "Atlantic Reporter": ['A.', 'A.2d'],
          }
  
      Note that the abbreviations are sorted by start date.
      """
      names = {}
      for reporter_key, data_list in reporters.items():
          for data in data_list:
              abbrevs = data['editions'].keys()
              # Sort abbreviations by start date of the edition
              sort_func = lambda x: str(data['editions'][x]['start']) + x
              abbrevs = sorted(abbrevs, key=sort_func)
              names[data['name']] = abbrevs
      sorted_names = OrderedDict(sorted(names.items(), key=lambda t: t[0]))
      return sorted_names