Skip to content

Commit 2a8efda

Browse files
committed
Code review suggestions, cleanup
1 parent e721c7b commit 2a8efda

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

spacy/coref_scorer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ def get_cluster_info(predicted_clusters, gold_clusters):
99
return (gold_clusters, predicted_clusters, g2p, p2g)
1010

1111

12-
def get_markable_assignments(inp_clusters, out_clusters):
12+
def get_markable_assignments(in_clusters, out_clusters):
1313
markable_cluster_ids = {}
1414
out_dic = {}
1515
for cluster_id, cluster in enumerate(out_clusters):
1616
for m in cluster:
1717
out_dic[m] = cluster_id
1818

19-
for cluster in inp_clusters:
19+
for cluster in in_clusters:
2020
for im in cluster:
2121
for om in out_dic:
2222
if im == om:

spacy/ml/models/coref.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def build_wl_coref_model(
2929
dim = 768
3030

3131
with Model.define_operators({">>": chain}):
32-
coref_scorer = PyTorchWrapper(
33-
CorefScorer(
32+
coref_clusterer = PyTorchWrapper(
33+
CorefClusterer(
3434
dim,
3535
distance_embedding_size,
3636
hidden_size,
@@ -39,14 +39,14 @@ def build_wl_coref_model(
3939
antecedent_limit,
4040
antecedent_batch_size,
4141
),
42-
convert_inputs=convert_coref_scorer_inputs,
43-
convert_outputs=convert_coref_scorer_outputs,
42+
convert_inputs=convert_coref_clusterer_inputs,
43+
convert_outputs=convert_coref_clusterer_outputs,
4444
)
45-
coref_model = tok2vec >> coref_scorer
45+
coref_model = tok2vec >> coref_clusterer
4646
return coref_model
4747

4848

49-
def convert_coref_scorer_inputs(
49+
def convert_coref_clusterer_inputs(
5050
model: Model,
5151
X: List[Floats2d],
5252
is_train: bool
@@ -65,7 +65,7 @@ def backprop(args: ArgsKwargs) -> List[Floats2d]:
6565
return ArgsKwargs(args=(word_features, ), kwargs={}), backprop
6666

6767

68-
def convert_coref_scorer_outputs(model: Model, inputs_outputs, is_train: bool):
68+
def convert_coref_clusterer_outputs(model: Model, inputs_outputs, is_train: bool):
6969
_, outputs = inputs_outputs
7070
scores, indices = outputs
7171

@@ -81,7 +81,7 @@ def convert_for_torch_backward(dY: Floats2d) -> ArgsKwargs:
8181
return (scores_xp, indices_xp), convert_for_torch_backward
8282

8383

84-
class CorefScorer(torch.nn.Module):
84+
class CorefClusterer(torch.nn.Module):
8585
"""
8686
Combines all coref modules together to find coreferent token pairs.
8787
Submodules (in the order of their usage in the pipeline):

spacy/ml/models/span_predictor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def build_span_predictor(
4848

4949

5050
def convert_span_predictor_inputs(
51-
model: Model, X: Tuple[Ints1d, Floats2d, Ints1d], is_train: bool
51+
model: Model, X: Tuple[Ints1d, Tuple[Floats2d, Ints1d]], is_train: bool
5252
):
5353
tok2vec, (sent_ids, head_ids) = X
5454
# Normally we should use the input is_train, but for these two it's not relevant

0 commit comments

Comments
 (0)