mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-27 10:26:35 +03:00
Format
This commit is contained in:
parent
8548d4d16e
commit
fd911fe2af
|
@ -168,7 +168,7 @@ class EditTreeLemmatizer(TrainablePipe):
|
||||||
student_scores: Scores representing the student model's predictions.
|
student_scores: Scores representing the student model's predictions.
|
||||||
|
|
||||||
RETURNS (Tuple[float, float]): The loss and the gradient.
|
RETURNS (Tuple[float, float]): The loss and the gradient.
|
||||||
|
|
||||||
DOCS: https://spacy.io/api/edittreelemmatizer#get_teacher_student_loss
|
DOCS: https://spacy.io/api/edittreelemmatizer#get_teacher_student_loss
|
||||||
"""
|
"""
|
||||||
loss_func = LegacySequenceCategoricalCrossentropy(normalize=False)
|
loss_func = LegacySequenceCategoricalCrossentropy(normalize=False)
|
||||||
|
|
|
@ -453,7 +453,11 @@ class EntityLinker(TrainablePipe):
|
||||||
docs_ents: List[Ragged] = []
|
docs_ents: List[Ragged] = []
|
||||||
docs_scores: List[Ragged] = []
|
docs_scores: List[Ragged] = []
|
||||||
if not docs:
|
if not docs:
|
||||||
return {KNOWLEDGE_BASE_IDS: final_kb_ids, "ents": docs_ents, "scores": docs_scores}
|
return {
|
||||||
|
KNOWLEDGE_BASE_IDS: final_kb_ids,
|
||||||
|
"ents": docs_ents,
|
||||||
|
"scores": docs_scores,
|
||||||
|
}
|
||||||
if isinstance(docs, Doc):
|
if isinstance(docs, Doc):
|
||||||
docs = [docs]
|
docs = [docs]
|
||||||
for doc in docs:
|
for doc in docs:
|
||||||
|
@ -585,7 +589,11 @@ class EntityLinker(TrainablePipe):
|
||||||
method="predict", msg="result variables not of equal length"
|
method="predict", msg="result variables not of equal length"
|
||||||
)
|
)
|
||||||
raise RuntimeError(err)
|
raise RuntimeError(err)
|
||||||
return {KNOWLEDGE_BASE_IDS: final_kb_ids, "ents": docs_ents, "scores": docs_scores}
|
return {
|
||||||
|
KNOWLEDGE_BASE_IDS: final_kb_ids,
|
||||||
|
"ents": docs_ents,
|
||||||
|
"scores": docs_scores,
|
||||||
|
}
|
||||||
|
|
||||||
def set_annotations(self, docs: Iterable[Doc], activations: ActivationsT) -> None:
|
def set_annotations(self, docs: Iterable[Doc], activations: ActivationsT) -> None:
|
||||||
"""Modify a batch of documents, using pre-computed scores.
|
"""Modify a batch of documents, using pre-computed scores.
|
||||||
|
|
|
@ -252,8 +252,11 @@ class EntityRecognizer(Parser):
|
||||||
def labels(self):
|
def labels(self):
|
||||||
# Get the labels from the model by looking at the available moves, e.g.
|
# Get the labels from the model by looking at the available moves, e.g.
|
||||||
# B-PERSON, I-PERSON, L-PERSON, U-PERSON
|
# B-PERSON, I-PERSON, L-PERSON, U-PERSON
|
||||||
labels = set(remove_bilu_prefix(move) for move in self.move_names
|
labels = set(
|
||||||
if move[0] in ("B", "I", "L", "U"))
|
remove_bilu_prefix(move)
|
||||||
|
for move in self.move_names
|
||||||
|
if move[0] in ("B", "I", "L", "U")
|
||||||
|
)
|
||||||
return tuple(sorted(labels))
|
return tuple(sorted(labels))
|
||||||
|
|
||||||
def scored_ents(self, beams):
|
def scored_ents(self, beams):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user