From 2e9dadfda40c36641891a098827fa10bddbd52af Mon Sep 17 00:00:00 2001 From: Paul O'Leary McCann Date: Tue, 12 Jul 2022 16:06:15 +0900 Subject: [PATCH] Remove orphaned function This was probably used in the prototyping stage, left as a reference, and then forgotten. Nothing uses it any more. --- spacy/ml/models/span_predictor.py | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/spacy/ml/models/span_predictor.py b/spacy/ml/models/span_predictor.py index 8a93dcf8e..715a89d97 100644 --- a/spacy/ml/models/span_predictor.py +++ b/spacy/ml/models/span_predictor.py @@ -104,37 +104,6 @@ def convert_span_predictor_inputs( return argskwargs, backprop -# TODO This probably belongs in the component, not the model. -def predict_span_clusters( - span_predictor: Model, sent_ids: Ints1d, words: Floats2d, clusters: List[Ints1d] -): - """ - Predicts span clusters based on the word clusters. - - span_predictor: a SpanPredictor instance - sent_ids: For each word indicates, which sentence it appears in. - words: Features for words. - clusters: Clusters inferred by the CorefScorer. - - Returns: - List[List[Tuple[int, int]]: span clusters - """ - if not clusters: - return [] - - xp = span_predictor.ops.xp - heads_ids = xp.asarray(sorted(i for cluster in clusters for i in cluster)) - scores = span_predictor.predict((sent_ids, words, heads_ids)) - starts = scores[:, :, 0].argmax(axis=1).tolist() - ends = (scores[:, :, 1].argmax(axis=1) + 1).tolist() - - head2span = { - head: (start, end) for head, start, end in zip(heads_ids.tolist(), starts, ends) - } - - return [[head2span[head] for head in cluster] for cluster in clusters] - - def build_get_head_metadata(prefix): model = Model( "HeadDataProvider", attrs={"prefix": prefix}, forward=head_data_forward