code: def get_candidates(
      self,
      mention_data,
      verbose=False,
      print_number_of_docs_retrieved=False,
      print_query_flag=False,
  ):
      solr = self.solr
      query_data = self.query_data
  
      # Build query
      keys = query_data["keys"]
      query = query_data["string"]
      query = query.format(
          *[
              mention_data[key]
              if key in mention_data
              else utils.get_sent_context(mention_data, key)
              for key in keys
          ]
      )
  
      if print_query_flag:
          print("Query: {}".format(query))
  
      try:
          results = solr.search(query, **self.query_arguments)
      except Exception as e:
          exc_type, exc_obj, exc_tb = sys.exc_info()
          print("\nException:", exc_type, "- line", exc_tb.tb_lineno)
          print(repr(e))
  
          c = self.c
          c += 1
          if c < 10:
              print(
                  "Exception with: \ncollection_name: {} \nquery: {} \nmention_data: {} \ndataset_name: {}\nquery_args: {}\n".format(
                      self.collection_name,
                      query,
                      mention_data_summary(mention_data),
                      mention_data["dataset_name"],
                      str(self.query_arguments),
                  )
              )
  
          return []
  
      if print_number_of_docs_retrieved:
          print("Retrieved {0} result(s).".format(len(results)))
      # Return the full retrieved objects (debuging purposes)
      if verbose:
          return results
  
      # Filter the data in the retrieved objects, while ignoring the ones without a wikidata_id (only a very small fraction in the dataset; they are noise)
      filtered_results = [
          self._filter_result(cand)
          for cand in results.docs
          if "wikidata_id" in cand
      ]
      return filtered_results
  
file_path: BLINK/blink/candidate_retrieval/candidate_generators.py
imports: import pysolr
  import sys
  import utils
label_desc: Use image node_id 3 for calling the Simple_Candidate_Generator obj's underlying member method code with example usage: obj.get_candidates(mention_data, verbose, print_number_of_docs_retrieved, print_query_flag) and returns: filtered_results, results, list