class_docstr: Class for query generation using Wikidata hdt file
class_docstr_tok: ["Class","for","query","generation","using","Wikidata","hdt","file"]
code: def parse_outputs(
      self,
      outputs_list,
      combs_list,
      query_info_list,
      entity_conf_list,
      rels_scores_dict,
  ):
      outputs = []
      if isinstance(outputs_list, list) and outputs_list:
          outputs_len = len(outputs_list)
          combs_list = combs_list[:outputs_len]
          entity_conf_list = entity_conf_list[:outputs_len]
          for (
              combs,
              query_info,
              entity_conf,
              (answers_list, found_rels_list, found_combs_list),
          ) in zip(
              combs_list,
              query_info_list,
              entity_conf_list,
              outputs_list,
          ):
              for answers, found_rels, found_comb in zip(
                  answers_list, found_rels_list, found_combs_list
              ):
                  found_rels = [
                      found_rel.split("/")[-1]
                      for found_rel in found_rels
                  ]
                  new_combs = list(copy.deepcopy(combs))
                  found_unk_rel = False
                  for j, rel_var in enumerate(["?p", "?p2"]):
                      if (
                          isinstance(new_combs[2][j], tuple)
                          and new_combs[2][j][0] == rel_var
                      ):
                          if found_rels:
                              new_combs[2][j] = (
                                  found_rels[j],
                                  rels_scores_dict.get(
                                      found_rels[j], 1.0
                                  ),
                              )
                          else:
                              new_combs[2][j] = (
                                  new_combs[2][j][0],
                                  0.0,
                              )
                          found_unk_rel = True
                  if found_rels and not found_unk_rel:
                      new_combs[2] = new_combs[2][:-1] + [
                          (found_rels[0], 1.0),
                          new_combs[2][-1],
                      ]
                  confidence = np.prod(
                      [score for rel, score in new_combs[2][:-1]]
                  )
                  if answers:
                      outputs.append(
                          [new_combs[0], new_combs[1]]
                          + [rel for rel, score in new_combs[2][:-1]]
                          + answers
                          + [
                              (confidence, entity_conf),
                              found_comb,
                              query_info,
                              new_combs[2],
                          ]
                      )
          outputs_dict = defaultdict(list)
          types_dict = defaultdict(list)
          for output in outputs:
              key = (
                  tuple(output[0]),
                  tuple([rel.split("/")[-1] for rel in output[2:-5]]),
              )
              if (
                  key not in outputs_dict
                  or output[-5:] not in outputs_dict[key]
              ):
                  outputs_dict[key].append(output[-5:])
                  types_dict[key].append(tuple(output[1]))
          outputs = []
          for (entity_comb, rel_comb), output in outputs_dict.items():
              type_comb = types_dict[(entity_comb, rel_comb)]
              output_conf = [elem[1] for elem in output]
              output_conf = sorted(
                  output_conf, key=lambda x: x[0] * x[1], reverse=True
              )
              found_combs = [elem[2] for elem in output]
              queries = [elem[3] for elem in output]
              rel_combs = [elem[4] for elem in output]
              cur_rel_comb = rel_combs[0]
              cur_rel_comb = [rel for rel, score in cur_rel_comb[:-1]]
              sparql_query = make_sparql_query(
                  queries[0],
                  entity_comb,
                  rel_combs[0],
                  type_comb[0],
                  self.gold_query_info,
              )
              parser_info_list = ["fill_triplets"]
              parser_query_list = [
                  (queries[0][1], queries[0][2], found_combs[0])
              ]
              filled_triplets = self.wiki_parser(
                  parser_info_list, parser_query_list
              )
              outputs.append(
                  {
                      "entities": entity_comb,
                      "types": type_comb,
                      "relations": list(cur_rel_comb),
                      "answers": tuple([ans for ans, *_ in output]),
                      "output_conf": output_conf[0],
                      "sparql_query": sparql_query,
                      "triplets": filled_triplets[0],
                  }
              )
      return outputs
  
imports: import copy
  import itertools
  import re
  from collections import defaultdict
  from logging import getLogger
  from typing import Tuple, List, Optional, Union, Dict, Any, Set
  import nltk
  import numpy
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.models.component import Component
  from deeppavlov.models.kbqa.query_generator_base import QueryGeneratorBase
  from deeppavlov.models.kbqa.rel_ranking_infer import RelRankerInfer
  from deeppavlov.models.kbqa.utils import extract_year, extract_number, make_combs, fill_query, find_query_features, make_sparql_query, merge_sparql_query
  from deeppavlov.models.kbqa.wiki_parser import WikiParser
label_desc: Use image node_id 6 for calling the QueryGenerator obj's underlying member method code with example usage: obj.parse_outputs(outputs_list, combs_list, query_info_list, entity_conf_list, rels_scores_dict) and returns: outputs