ref: don't pass DataModel  into BlockLearners
It's not needed in there, so should just pass what is needed.
This is prep for further refactoring of removing datamodel more
@@ -216,7 +216,7 @@ def _filter_canopy_predicates(
class DedupeBlockLearner(BlockLearner):
def __init__(
self,
- data_model: DataModel,
+ candidate_predicates: Iterable[Predicate],
data: Data,
index_include: TrainingExamples,
):
@@ -228,7 +228,7 @@ class DedupeBlockLearner(BlockLearner):
index_data = sample_records(data, 50000)
sampled_records = sample_records(index_data, N_SAMPLED_RECORDS)
- preds = _filter_canopy_predicates(data_model.predicates, canopies=True)
+ preds = _filter_canopy_predicates(candidate_predicates, canopies=True)
self.block_learner = training.DedupeBlockLearner(
preds, sampled_records, index_data
)
@@ -268,7 +268,7 @@ class DedupeBlockLearner(BlockLearner):
class RecordLinkBlockLearner(BlockLearner):
def __init__(
self,
- data_model: DataModel,
+ candidate_predicates: Iterable[Predicate],
data_1: Data,
data_2: Data,
index_include: TrainingExamples,
@@ -282,7 +282,7 @@ class RecordLinkBlockLearner(BlockLearner):
index_data = sample_records(data_2, 50000)
sampled_records_2 = sample_records(index_data, N_SAMPLED_RECORDS)
- preds = _filter_canopy_predicates(data_model.predicates, canopies=False)
+ preds = _filter_canopy_predicates(candidate_predicates, canopies=False)
self.block_learner = training.RecordLinkBlockLearner(
preds, sampled_records_1, sampled_records_2, index_data
)
@@ -400,7 +400,7 @@ class DedupeDisagreementLearner(DisagreementLearner):
index_include = index_include.copy()
index_include.append(exact_match)
- self.blocker = DedupeBlockLearner(data_model, data, index_include)
+ self.blocker = DedupeBlockLearner(data_model.predicates, data, index_include)
self._candidates = self.blocker.candidates.copy()
@@ -435,7 +435,9 @@ class RecordLinkDisagreementLearner(DisagreementLearner):
index_include = index_include.copy()
index_include.append(exact_match)
- self.blocker = RecordLinkBlockLearner(data_model, data_1, data_2, index_include)
+ self.blocker = RecordLinkBlockLearner(
+ data_model.predicates, data_1, data_2, index_include
+ )
self._candidates = self.blocker.candidates.copy()
self.matcher = MatchLearner(self.data_model, self.candidates)
