removing unused imports

This commit is contained in:
svlandeg 2021-05-27 16:31:38 +02:00
parent 910026582d
commit 04b55bf054
3 changed files with 6 additions and 13 deletions

View File

@ -2,19 +2,11 @@ from dataclasses import dataclass
from thinc.api import Model, Linear, Relu, Dropout, chain, noop
from thinc.types import Floats2d, Floats1d, Ints2d, Ragged
from typing import List, Callable, Tuple, Any
from typing import List, Callable, Tuple, Any
from ...tokens import Doc
from ...util import registry
from .coref_util import (
get_predicted_clusters,
get_candidate_mentions,
select_non_crossing_spans,
make_clean_doc,
create_gold_scores,
logsumexp,
topk,
)
from .coref_util import get_candidate_mentions, select_non_crossing_spans, topk
@registry.architectures("spacy.Coref.v1")
@ -172,8 +164,8 @@ def span_embeddings_forward(
# first and last token embeds
# XXX probably would be faster to get these at once
#starts = [tokvecs[ii] for ii in mentions[:, 0]]
#ends = [tokvecs[jj] for jj in mentions[:, 1]]
# starts = [tokvecs[ii] for ii in mentions[:, 0]]
# ends = [tokvecs[jj] for jj in mentions[:, 1]]
starts, ends = zip(*[(tokvecs[ii], tokvecs[jj]) for ii, jj in mentions])
starts = ops.asarray2f(starts)

View File

@ -44,6 +44,7 @@ def topk(xp, arr, k, axis=None):
def logsumexp(xp, arr, axis=None):
"""Emulate torch.logsumexp by returning the log of summed exponentials
along each row in the given dimension.
TODO: currently not used?
Reduces a 2d array to 1d."""
# from slide 5 here:
@ -217,6 +218,7 @@ def get_clusters_from_doc(doc) -> List[List[Tuple[int, int]]]:
def make_clean_doc(nlp, doc):
"""Return a doc with raw data but not span annotations."""
# Surely there is a better way to do this?
# TODO: currently not used?
sents = [tok.is_sent_start for tok in doc]
words = [tok.text for tok in doc]

View File

@ -17,7 +17,6 @@ from ..ml.models.coref_util import (
create_gold_scores,
MentionClusters,
get_clusters_from_doc,
logsumexp,
get_predicted_clusters,
DEFAULT_CLUSTER_PREFIX,
doc2clusters,