class_docstr: Takes in a record and returns all blocks that record belongs to
class_docstr_tok: ["Takes","in","a","record","and","returns","all","blocks","that","record","belongs","to"]
docstr: Generate the predicates for records. Yields tuples of (predicate,
  record_id).
  
  Args:
      records: A sequence of tuples of (record_id,
            record_dict). Can often be created by
            `data_dict.items()`.
      target: Indicates whether the data should be treated as
              the target data. This effects the behavior of
              search predicates. If `target` is set to
              `True`, an search predicate will return the
              value itself. If `target` is set to `False` the
              search predicate will return all possible
              values within the specified search distance.
  
              Let's say we have a
              `LevenshteinSearchPredicate` with an associated
              distance of `1` on a `"name"` field; and we
              have a record like `{"name": "thomas"}`. If the
              `target` is set to `True` then the predicate
              will return `"thomas"`.  If `target` is set to
              `False`, then the blocker could return
              `"thomas"`, `"tomas"`, and `"thoms"`. By using
              the `target` argument on one of your datasets,
              you will dramatically reduce the total number
              of comparisons without a loss of accuracy.
  
  .. code:: python
  
     > data = [(1, {'name' : 'bob'}), (2, {'name' : 'suzanne'})]
     > blocked_ids = deduper.fingerprinter(data)
     > print list(blocked_ids)
     [('foo:1', 1), ..., ('bar:1', 100)]
docstr_tok: ["Generate","the","predicates","for","records",".","Yields","tuples","of","(","predicate",",","record_id",")",".","Args",":","records",":","A","sequence","of","tuples","of","(","record_id",",","record_dict",")",".","Can","often","be","created","by","`","data_dict.items","(",")","`",".","target",":","Indicates","whether","the","data","should","be","treated","as","the","target","data",".","This","effects","the","behavior","of","search","predicates",".","If","`","target","`","is","set","to","`","True","`",",","an","search","predicate","will","return","the","value","itself",".","If","`","target","`","is","set","to","`","False","`","the","search","predicate","will","return","all","possible","values","within","the","specified","search","distance",".","Let","'s","say","we","have","a","`","LevenshteinSearchPredicate","`","with","an","associated","distance","of","`","1","`","on","a","`","``","name","''","`","field",";","and","we","have","a","record","like","`","{","``","name","''",":","``","thomas","''","}","`",".","If","the","`","target","`","is","set","to","`","True","`","then","the","predicate","will","return","`","``","thomas","''","`",".","If","`","target","`","is","set","to","`","False","`",",","then","the","blocker","could","return","`","``","thomas","''","`",",","`","``","tomas","''","`",",","and","`","``","thoms","''","`",".","By","using","the","`","target","`","argument","on","one","of","your","datasets",",","you","will","dramatically","reduce","the","total","number","of","comparisons","without","a","loss","of","accuracy",".","..","code",":",":","python",">","data","=","[","(","1",",","{","'name","'",":","'bob","'","}",")",",","(","2",",","{","'name","'",":","'suzanne","'","}",")","]",">","blocked_ids","=","deduper.fingerprinter","(","data",")",">","print","list","(","blocked_ids",")","[","(","'foo:1","'",",","1",")",",","...",",","(","'bar:1","'",",","100",")","]"]
code: def __call__(
      self, records: Iterable[Record], target: bool = False
  ) -> Generator[tuple[str, RecordID], None, None]:
      """
      Generate the predicates for records. Yields tuples of (predicate,
      record_id).
  
      Args:
          records: A sequence of tuples of (record_id,
                record_dict). Can often be created by
                `data_dict.items()`.
          target: Indicates whether the data should be treated as
                  the target data. This effects the behavior of
                  search predicates. If `target` is set to
                  `True`, an search predicate will return the
                  value itself. If `target` is set to `False` the
                  search predicate will return all possible
                  values within the specified search distance.
  
                  Let's say we have a
                  `LevenshteinSearchPredicate` with an associated
                  distance of `1` on a `"name"` field; and we
                  have a record like `{"name": "thomas"}`. If the
                  `target` is set to `True` then the predicate
                  will return `"thomas"`.  If `target` is set to
                  `False`, then the blocker could return
                  `"thomas"`, `"tomas"`, and `"thoms"`. By using
                  the `target` argument on one of your datasets,
                  you will dramatically reduce the total number
                  of comparisons without a loss of accuracy.
  
      .. code:: python
  
         > data = [(1, {'name' : 'bob'}), (2, {'name' : 'suzanne'})]
         > blocked_ids = deduper.fingerprinter(data)
         > print list(blocked_ids)
         [('foo:1', 1), ..., ('bar:1', 100)]
  
      """
  
      start_time = time.perf_counter()
      predicates = [
          (":" + str(i), predicate)
          for i, predicate in enumerate(self.predicates)
      ]
  
      for i, record in enumerate(records):
          record_id, instance = record
  
          for pred_id, predicate in predicates:
              block_keys = predicate(instance, target=target)
              for block_key in block_keys:
                  yield block_key + pred_id, record_id
  
          if i and i % 10000 == 0:
              logger.info(
                  "%(iteration)d, %(elapsed)f2 seconds",
                  {
                      "iteration": i,
                      "elapsed": time.perf_counter() - start_time,
                  },
              )
  
file_path: dedupe/dedupe/blocking.py
imports: from __future__ import annotations
  import logging
  import time
  from collections import defaultdict
  from typing import TYPE_CHECKING
label_desc: Use image node_id 2 for calling the Fingerprinter obj's underlying member method code with example usage: obj.__call__(records, target) without return types