nodes: 0, module; 1, function_definition; 2, function_name:_sub_expand; 3, parameters; 4, block; 5, identifier:self; 6, identifier:tags; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, comment:# name entities; 11, for_statement; 12, for_statement; 13, comment:"""This called by expand to find cliques
  
          Args:
              tags (list): a list of the tags used to get cliques
  
          Yields:
              list : list of sorted tags by start_token this is a clique
          """; 14, assignment; 15, assignment; 16, identifier:tag; 17, identifier:tags; 18, block; 19, identifier:clique; 20, call; 21, block; 22, identifier:entities; 23, dictionary; 24, identifier:graph; 25, call; 26, for_statement; 27, identifier:get_cliques; 28, argument_list; 29, expression_statement; 30, for_statement; 31, expression_statement; 32, expression_statement; 33, attribute; 34, argument_list; 35, identifier:entity_index; 36, call; 37, block; 38, call; 39, identifier:graph; 40, assignment; 41, identifier:entity_name; 42, identifier:clique; 43, block; 44, assignment; 45, yield; 46, identifier:self; 47, identifier:_build_graph; 48, identifier:tags; 49, identifier:xrange; 50, argument_list; 51, expression_statement; 52, if_statement; 53, expression_statement; 54, identifier:list; 55, argument_list; 56, identifier:result; 57, list; 58, expression_statement; 59, expression_statement; 60, expression_statement; 61, expression_statement; 62, identifier:result; 63, call; 64, identifier:result; 65, call; 66, assignment; 67, not_operator; 68, block; 69, augmented_assignment; 70, identifier:entities; 71, assignment; 72, assignment; 73, assignment; 74, call; 75, identifier:sorted; 76, argument_list; 77, identifier:len; 78, argument_list; 79, identifier:node_name; 80, call; 81, comparison_operator:node_name in entities; 82, expression_statement; 83, subscript; 84, list; 85, identifier:start_token; 86, call; 87, identifier:old_tag; 88, subscript; 89, identifier:tag; 90, dictionary; 91, attribute; 92, argument_list; 93, identifier:result; 94, keyword_argument; 95, call; 96, identifier:graph_key_from_tag; 97, argument_list; 98, identifier:node_name; 99, identifier:entities; 100, assignment; 101, identifier:entities; 102, identifier:node_name; 103, subscript; 104, call; 105, identifier:tag; 106, identifier:int; 107, argument_list; 108, subscript; 109, integer:2; 110, pair; 111, pair; 112, pair; 113, pair; 114, pair; 115, pair; 116, pair; 117, identifier:result; 118, identifier:append; 119, identifier:tag; 120, identifier:key; 121, lambda; 122, attribute; 123, argument_list; 124, identifier:tag; 125, identifier:entity_index; 126, subscript; 127, list; 128, call; 129, identifier:entity_index; 130, attribute; 131, argument_list; 132, subscript; 133, identifier:entities; 134, identifier:entity_name; 135, string; 136, identifier:start_token; 137, string; 138, list; 139, string; 140, binary_operator:entities.get(entity_name)[1] * old_tag.get('confidence', 1.0); 141, string; 142, call; 143, string; 144, call; 145, string; 146, call; 147, string; 148, call; 149, lambda_parameters; 150, call; 151, identifier:tag; 152, identifier:get; 153, string; 154, identifier:entities; 155, identifier:node_name; 156, attribute; 157, argument_list; 158, subscript; 159, identifier:get; 160, string; 161, call; 162, integer:0; 163, string_content:start_token; 164, string_content:entities; 165, subscript; 166, string_content:confidence; 167, subscript; 168, call; 169, string_content:end_token; 170, attribute; 171, argument_list; 172, string_content:match; 173, attribute; 174, argument_list; 175, string_content:key; 176, attribute; 177, argument_list; 178, string_content:from_context; 179, attribute; 180, argument_list; 181, identifier:e; 182, attribute; 183, argument_list; 184, string_content:entities; 185, identifier:tag; 186, identifier:get; 187, string; 188, list; 189, call; 190, identifier:entity_index; 191, string_content:confidence; 192, attribute; 193, argument_list; 194, call; 195, integer:0; 196, call; 197, integer:1; 198, attribute; 199, argument_list; 200, identifier:old_tag; 201, identifier:get; 202, string; 203, subscript; 204, identifier:get; 205, string; 206, subscript; 207, identifier:get; 208, string; 209, identifier:old_tag; 210, identifier:get; 211, string; 212, False; 213, identifier:e; 214, identifier:get; 215, string; 216, string_content:entities; 217, attribute; 218, argument_list; 219, identifier:entity_name; 220, identifier:split; 221, string:"-"; 222, attribute; 223, argument_list; 224, attribute; 225, argument_list; 226, identifier:old_tag; 227, identifier:get; 228, string; 229, float:1.0; 230, string_content:end_token; 231, call; 232, integer:0; 233, string_content:match; 234, call; 235, integer:0; 236, string_content:key; 237, string_content:from_context; 238, string_content:start_token; 239, identifier:tag; 240, identifier:get; 241, string; 242, list; 243, identifier:entities; 244, identifier:get; 245, identifier:entity_name; 246, identifier:entities; 247, identifier:get; 248, identifier:entity_name; 249, string_content:confidence; 250, attribute; 251, argument_list; 252, attribute; 253, argument_list; 254, string_content:entities; 255, identifier:old_tag; 256, identifier:get; 257, string; 258, identifier:old_tag; 259, identifier:get; 260, string; 261, string_content:entities; 262, string_content:entities
code: def _sub_expand(self, tags):
          """This called by expand to find cliques
  
          Args:
              tags (list): a list of the tags used to get cliques
  
          Yields:
              list : list of sorted tags by start_token this is a clique
          """
          entities = {}
          graph = self._build_graph(tags)
  
          # name entities
          for tag in tags:
              for entity_index in xrange(len(tag.get('entities'))):
                  node_name = graph_key_from_tag(tag, entity_index)
                  if not node_name in entities:
                      entities[node_name] = []
                  entities[node_name] += [
                      tag.get('entities', [])[entity_index],
                      tag.get('entities', [])[entity_index].get('confidence'),
                      tag
                  ]
  
          for clique in get_cliques(list(entities), graph):
              result = []
              for entity_name in clique:
                  start_token = int(entity_name.split("-")[0])
                  old_tag = entities[entity_name][2]
                  tag = {
                      'start_token': start_token,
                      'entities': [entities.get(entity_name)[0]],
                      'confidence': entities.get(entity_name)[1] * old_tag.get('confidence', 1.0),
                      'end_token': old_tag.get('end_token'),
                      'match': old_tag.get('entities')[0].get('match'),
                      'key': old_tag.get('entities')[0].get('key'),
                      'from_context': old_tag.get('from_context', False)
                  }
                  result.append(tag)
              result = sorted(result, key=lambda e: e.get('start_token'))
              yield result