mirror of
https://github.com/explosion/spaCy.git
synced 2025-09-19 02:22:43 +03:00
removing unused imports
This commit is contained in:
parent
910026582d
commit
04b55bf054
|
@ -2,19 +2,11 @@ from dataclasses import dataclass
|
||||||
|
|
||||||
from thinc.api import Model, Linear, Relu, Dropout, chain, noop
|
from thinc.api import Model, Linear, Relu, Dropout, chain, noop
|
||||||
from thinc.types import Floats2d, Floats1d, Ints2d, Ragged
|
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 ...tokens import Doc
|
||||||
from ...util import registry
|
from ...util import registry
|
||||||
|
|
||||||
from .coref_util import (
|
from .coref_util import get_candidate_mentions, select_non_crossing_spans, topk
|
||||||
get_predicted_clusters,
|
|
||||||
get_candidate_mentions,
|
|
||||||
select_non_crossing_spans,
|
|
||||||
make_clean_doc,
|
|
||||||
create_gold_scores,
|
|
||||||
logsumexp,
|
|
||||||
topk,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@registry.architectures("spacy.Coref.v1")
|
@registry.architectures("spacy.Coref.v1")
|
||||||
|
@ -172,8 +164,8 @@ def span_embeddings_forward(
|
||||||
|
|
||||||
# first and last token embeds
|
# first and last token embeds
|
||||||
# XXX probably would be faster to get these at once
|
# XXX probably would be faster to get these at once
|
||||||
#starts = [tokvecs[ii] for ii in mentions[:, 0]]
|
# starts = [tokvecs[ii] for ii in mentions[:, 0]]
|
||||||
#ends = [tokvecs[jj] for jj in mentions[:, 1]]
|
# ends = [tokvecs[jj] for jj in mentions[:, 1]]
|
||||||
starts, ends = zip(*[(tokvecs[ii], tokvecs[jj]) for ii, jj in mentions])
|
starts, ends = zip(*[(tokvecs[ii], tokvecs[jj]) for ii, jj in mentions])
|
||||||
|
|
||||||
starts = ops.asarray2f(starts)
|
starts = ops.asarray2f(starts)
|
||||||
|
|
|
@ -44,6 +44,7 @@ def topk(xp, arr, k, axis=None):
|
||||||
def logsumexp(xp, arr, axis=None):
|
def logsumexp(xp, arr, axis=None):
|
||||||
"""Emulate torch.logsumexp by returning the log of summed exponentials
|
"""Emulate torch.logsumexp by returning the log of summed exponentials
|
||||||
along each row in the given dimension.
|
along each row in the given dimension.
|
||||||
|
TODO: currently not used?
|
||||||
|
|
||||||
Reduces a 2d array to 1d."""
|
Reduces a 2d array to 1d."""
|
||||||
# from slide 5 here:
|
# 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):
|
def make_clean_doc(nlp, doc):
|
||||||
"""Return a doc with raw data but not span annotations."""
|
"""Return a doc with raw data but not span annotations."""
|
||||||
# Surely there is a better way to do this?
|
# Surely there is a better way to do this?
|
||||||
|
# TODO: currently not used?
|
||||||
|
|
||||||
sents = [tok.is_sent_start for tok in doc]
|
sents = [tok.is_sent_start for tok in doc]
|
||||||
words = [tok.text for tok in doc]
|
words = [tok.text for tok in doc]
|
||||||
|
|
|
@ -17,7 +17,6 @@ from ..ml.models.coref_util import (
|
||||||
create_gold_scores,
|
create_gold_scores,
|
||||||
MentionClusters,
|
MentionClusters,
|
||||||
get_clusters_from_doc,
|
get_clusters_from_doc,
|
||||||
logsumexp,
|
|
||||||
get_predicted_clusters,
|
get_predicted_clusters,
|
||||||
DEFAULT_CLUSTER_PREFIX,
|
DEFAULT_CLUSTER_PREFIX,
|
||||||
doc2clusters,
|
doc2clusters,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user