class_docstr: Class for query generation using Wikidata hdt file
class_docstr_tok: ["Class","for","query","generation","using","Wikidata","hdt","file"]
docstr: Args:
      wiki_parser: component deeppavlov.models.kbqa.wiki_parser
      rel_ranker: component deeppavlov.models.kbqa.rel_ranking_infer
      entities_to_leave: how many entities to leave after entity linking
      types_to_leave: how many types to leave after entity linking
      rels_to_leave: how many relations to leave after relation ranking
      max_comb_num: the maximum number of combinations of candidate entities and relations
      gold_query_info: dict of variable names used for formatting output sparql queries
      map_query_str_to_kb: mapping of knowledge base prefixes to full https
      return_answers: whether to return answers or candidate relations and answers for further ranking
      **kwargs:
docstr_tok: ["Args",":","wiki_parser",":","component","deeppavlov.models.kbqa.wiki_parser","rel_ranker",":","component","deeppavlov.models.kbqa.rel_ranking_infer","entities_to_leave",":","how","many","entities","to","leave","after","entity","linking","types_to_leave",":","how","many","types","to","leave","after","entity","linking","rels_to_leave",":","how","many","relations","to","leave","after","relation","ranking","max_comb_num",":","the","maximum","number","of","combinations","of","candidate","entities","and","relations","gold_query_info",":","dict","of","variable","names","used","for","formatting","output","sparql","queries","map_query_str_to_kb",":","mapping","of","knowledge","base","prefixes","to","full","https","return_answers",":","whether","to","return","answers","or","candidate","relations","and","answers","for","further","ranking","*","*","kwargs",":"]
code: def __init__(
      self,
      wiki_parser: WikiParser,
      rel_ranker: RelRankerInfer,
      entities_to_leave: int = 5,
      types_to_leave: int = 2,
      rels_to_leave: int = 7,
      max_comb_num: int = 10000,
      gold_query_info: Dict[str, str] = None,
      map_query_str_to_kb: List[Tuple[str, str]] = None,
      return_answers: bool = True,
      *args,
      **kwargs,
  ) -> None:
      """
  
      Args:
          wiki_parser: component deeppavlov.models.kbqa.wiki_parser
          rel_ranker: component deeppavlov.models.kbqa.rel_ranking_infer
          entities_to_leave: how many entities to leave after entity linking
          types_to_leave: how many types to leave after entity linking
          rels_to_leave: how many relations to leave after relation ranking
          max_comb_num: the maximum number of combinations of candidate entities and relations
          gold_query_info: dict of variable names used for formatting output sparql queries
          map_query_str_to_kb: mapping of knowledge base prefixes to full https
          return_answers: whether to return answers or candidate relations and answers for further ranking
          **kwargs:
      """
      self.wiki_parser = wiki_parser
      self.rel_ranker = rel_ranker
      self.entities_to_leave = entities_to_leave
      self.types_to_leave = types_to_leave
      self.rels_to_leave = rels_to_leave
      self.max_comb_num = max_comb_num
      self.gold_query_info = gold_query_info
      self.map_query_str_to_kb = map_query_str_to_kb
      self.return_answers = return_answers
      self.replace_tokens = [("wdt:p", "wdt:P"), ("pq:p", "pq:P")]
      super().__init__(
          wiki_parser=self.wiki_parser,
          rel_ranker=self.rel_ranker,
          entities_to_leave=self.entities_to_leave,
          rels_to_leave=self.rels_to_leave,
          *args,
          **kwargs,
      )
  
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 1 to create a new QueryGenerator object from inherited base classes: QueryGeneratorBase with example: obj = QueryGenerator(wiki_parser, rel_ranker, entities_to_leave, types_to_leave, rels_to_leave, max_comb_num, gold_query_info, map_query_str_to_kb, return_answers)