class_docstr: This class extract relations, objects or triplets from Wikidata HDT file.
class_docstr_tok: ["This","class","extract","relations",",","objects","or","triplets","from","Wikidata","HDT","file","."]
code: def search(
      self,
      query: List[str],
      unknown_elem_positions: List[Tuple[int, str]],
      rel_type,
  ):
      query = list(
          map(lambda elem: "" if elem.startswith("?") else elem, query)
      )
      subj, rel, obj = query
      if self.file_format == "hdt":
          combs = []
          triplets, cnt = self.document.search_triples(subj, rel, obj)
          if cnt < self.max_comb_num:
              triplets = list(triplets)
              if (
                  rel == self.prefixes["description"]
                  or rel == self.prefixes["label"]
              ):
                  triplets = [
                      triplet
                      for triplet in triplets
                      if triplet[2].endswith(self.lang)
                  ]
                  combs = [
                      {
                          elem: triplet[pos]
                          for pos, elem in unknown_elem_positions
                      }
                      for triplet in triplets
                  ]
              else:
                  if isinstance(self.prefixes["rels"][rel_type], str):
                      combs = [
                          {
                              elem: triplet[pos]
                              for pos, elem in unknown_elem_positions
                          }
                          for triplet in triplets
                          if (
                              triplet[1].startswith(
                                  self.prefixes["rels"][rel_type]
                              )
                              or triplet[1].startswith(
                                  self.prefixes["rels"]["type"]
                              )
                          )
                      ]
                  else:
                      combs = [
                          {
                              elem: triplet[pos]
                              for pos, elem in unknown_elem_positions
                          }
                          for triplet in triplets
                          if (
                              any(
                                  triplet[1].startswith(tp)
                                  for tp in self.prefixes["rels"][
                                      rel_type
                                  ]
                              )
                              or triplet[1].startswith(
                                  self.prefixes["rels"]["type"]
                              )
                          )
                      ]
          else:
              log.debug("max comb num exceeds")
      else:
          triplets = []
          if subj:
              subj, triplets = self.find_triplets(subj, "forw")
              triplets = [
                  [subj, triplet[0], obj]
                  for triplet in triplets
                  for obj in triplet[1:]
              ]
          if obj:
              obj, triplets = self.find_triplets(obj, "backw")
              triplets = [
                  [subj, triplet[0], obj]
                  for triplet in triplets
                  for subj in triplet[1:]
              ]
          if rel:
              if rel == self.prefixes["description"]:
                  triplets = [
                      triplet
                      for triplet in triplets
                      if triplet[1] == "descr_en"
                  ]
              else:
                  rel = rel.split("/")[-1]
                  triplets = [
                      triplet
                      for triplet in triplets
                      if triplet[1] == rel
                  ]
          combs = [
              {
                  elem: triplet[pos]
                  for pos, elem in unknown_elem_positions
              }
              for triplet in triplets
          ]
  
      return combs, triplets
  
imports: import datetime
  import re
  from collections import namedtuple
  from logging import getLogger
  from typing import List, Tuple, Dict, Any, Union
  from hdt import HDTDocument
  from deeppavlov.core.commands.utils import expand_path
  from deeppavlov.core.common.file import load_pickle, read_json
  from deeppavlov.core.common.registry import register
label_desc: Use image node_id 7 for calling the WikiParser obj's underlying member method code with example usage: obj.search(query, unknown_elem_positions, rel_type) and returns: combs,  triplets