class_docstr: Class for linking of entity substrings in the document to entities in Wikidata
class_docstr_tok: ["Class","for","linking","of","entity","substrings","in","the","document","to","entities","in","Wikidata"]
code: def rank_by_connections(self, ids_list):
      objects_sets_dict, scores_dict, conn_dict = {}, {}, {}
      for ids in ids_list:
          for entity_id in ids:
              scores_dict[entity_id] = 0
              conn_dict[entity_id] = set()
      for ids in ids_list:
          for entity_id in ids[: self.num_entities_for_conn_ranking]:
              objects = set()
              for prefix in self.prefixes["entity"]:
                  tr, _ = self.kb.search_triples(
                      f"{prefix}/{entity_id}", "", ""
                  )
                  for subj, rel, obj in tr:
                      if rel.split("/")[-1] not in {"P31", "P279"}:
                          if any(
                              [
                                  obj.startswith(pr)
                                  for pr in self.prefixes["entity"]
                              ]
                          ):
                              objects.add(obj.split("/")[-1])
                          if rel.startswith(
                              self.prefixes["rels"]["no_type"]
                          ):
                              tr2, _ = self.kb.search_triples(
                                  obj, "", ""
                              )
                              for _, rel2, obj2 in tr2:
                                  if rel2.startswith(
                                      self.prefixes["rels"]["statement"]
                                  ) or rel2.startswith(
                                      self.prefixes["rels"]["qualifier"]
                                  ):
                                      if any(
                                          [
                                              obj2.startswith(pr)
                                              for pr in self.prefixes[
                                                  "entity"
                                              ]
                                          ]
                                      ):
                                          objects.add(
                                              obj2.split("/")[-1]
                                          )
              objects_sets_dict[entity_id] = objects
              for obj in objects:
                  if obj not in objects_sets_dict:
                      objects_sets_dict[obj] = set()
                  objects_sets_dict[obj].add(entity_id)
  
      for i in range(len(ids_list)):
          for j in range(len(ids_list)):
              if i != j:
                  for entity_id1 in ids_list[i][
                      : self.num_entities_for_conn_ranking
                  ]:
                      for entity_id2 in ids_list[j][
                          : self.num_entities_for_conn_ranking
                      ]:
                          if (
                              entity_id1
                              in objects_sets_dict[entity_id2]
                          ):
                              conn_dict[entity_id1].add(entity_id2)
                              conn_dict[entity_id2].add(entity_id1)
      for entity_id in conn_dict:
          scores_dict[entity_id] = len(conn_dict[entity_id])
      return scores_dict
  
imports: import re
  import sqlite3
  from logging import getLogger
  from typing import List, Dict, Tuple, Any, Union
  from collections import defaultdict
  import nltk
  import spacy
  from hdt import HDTDocument
  from nltk.corpus import stopwords
  from rapidfuzz import fuzz
  from deeppavlov.core.commands.utils import expand_path
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.models.component import Component
  from deeppavlov.core.models.serializable import Serializable
  from deeppavlov.models.entity_extraction.find_word import WordSearcher
label_desc: Use image node_id 18 for calling the EntityLinker obj's underlying member method code with example usage: obj.rank_by_connections(ids_list) and returns: scores_dict