Apply suggestions from code review

Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
This commit is contained in:
Lj Miranda 2023-01-17 09:38:47 +08:00 committed by GitHub
parent 75ec9f37f0
commit 65ce4347ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,7 +63,7 @@ def make_spancat(
negative_weight: float = 1.0, negative_weight: float = 1.0,
allow_overlap: bool = True, allow_overlap: bool = True,
) -> "Exclusive_SpanCategorizer": ) -> "Exclusive_SpanCategorizer":
"""Create a SpanCategorizerExclusive component. The span categorizer consists of two """Create an Exclusive_SpanCategorizer component. The span categorizer consists of two
parts: a suggester function that proposes candidate spans, and a labeler parts: a suggester function that proposes candidate spans, and a labeler
model that predicts a maximum of one label for each span. model that predicts a maximum of one label for each span.
@ -136,7 +136,7 @@ class Exclusive_SpanCategorizer(SpanCategorizer):
allow_overlap: bool = True, allow_overlap: bool = True,
scorer: Optional[Callable] = spancat_score, scorer: Optional[Callable] = spancat_score,
) -> None: ) -> None:
"""Initialize the span categorizer. """Initialize the exclusive span categorizer.
vocab (Vocab): The shared vocabulary. vocab (Vocab): The shared vocabulary.
model (thinc.api.Model): The Thinc Model powering the pipeline component. model (thinc.api.Model): The Thinc Model powering the pipeline component.
name (str): The component instance name, used to add entries to the name (str): The component instance name, used to add entries to the
@ -147,8 +147,9 @@ class Exclusive_SpanCategorizer(SpanCategorizer):
`"spans"`. `"spans"`.
negative_weight (float): Multiplier for the loss terms. negative_weight (float): Multiplier for the loss terms.
Can be used to down weigh the negative samples if there are too many. Can be used to down weigh the negative samples if there are too many.
Defaults to 1.0.
allow_overlap (bool): If True the data is assumed to allow_overlap (bool): If True the data is assumed to
contain overlapping spans. contain overlapping spans. Defaults to `True`.
scorer (Optional[Callable]): The scoring method. Defaults to scorer (Optional[Callable]): The scoring method. Defaults to
Scorer.score_spans for the Doc.spans[spans_key] with overlapping Scorer.score_spans for the Doc.spans[spans_key] with overlapping
spans allowed. spans allowed.
@ -186,7 +187,7 @@ class Exclusive_SpanCategorizer(SpanCategorizer):
"""Modify a batch of Doc objects, using pre-computed scores. """Modify a batch of Doc objects, using pre-computed scores.
docs (Iterable[Doc]): The documents to modify. docs (Iterable[Doc]): The documents to modify.
scores: The scores to set, produced by SpanCategorizerExclusive.predict. indices_scores: The scores to set, produced by Exclusive_SpanCategorizer.predict.
DOCS: https://spacy.io/api/spancatcategorizer#set_annotations DOCS: https://spacy.io/api/spancatcategorizer#set_annotations
""" """