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 find_rels(
      self, entity: str, direction: str, rel_type: str = "no_type"
  ) -> List[str]:
      rels = []
      if self.file_format == "hdt":
          if not rel_type:
              rel_type = "direct"
          if direction == "forw":
              query = [f"{self.prefixes['entity']}/{entity}", "", ""]
          else:
              query = ["", "", f"{self.prefixes['entity']}/{entity}"]
          triplets, c = self.document.search_triples(*query)
          triplets = list(triplets)
          if isinstance(self.prefixes["rels"][rel_type], str):
              start_str = f"{self.prefixes['rels'][rel_type]}/P"
              rels = {
                  triplet[1]
                  for triplet in triplets
                  if triplet[1].startswith(start_str)
              }
          else:
              rels = {
                  triplet[1]
                  for triplet in triplets
                  if any(
                      [
                          triplet[1].startswith(tp)
                          for tp in self.prefixes["rels"][rel_type]
                      ]
                  )
              }
          rels = list(rels)
          if self.used_rels:
              rels = [
                  rel
                  for rel in rels
                  if rel.split("/")[-1] in self.used_rels
              ]
      return rels
  
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 11 for calling the WikiParser obj's underlying member method code with example usage: obj.find_rels(entity, direction, rel_type) and returns: rels