From a93f6202df63d86510c7086ca1b0db25a41fd35f Mon Sep 17 00:00:00 2001 From: svlandeg Date: Thu, 6 Jul 2023 15:57:42 +0200 Subject: [PATCH] adding further type specifications and removing internal methods --- spacy/training/example.pyi | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/spacy/training/example.pyi b/spacy/training/example.pyi index 1413d857d..9cd563465 100644 --- a/spacy/training/example.pyi +++ b/spacy/training/example.pyi @@ -1,12 +1,13 @@ -from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple +from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple from ..tokens import Doc, Span +from ..vocab import Vocab from .alignment import Alignment def annotations_to_doc( - vocab, - tok_annot, - doc_annot, + vocab: Vocab, + tok_annot: Dict[str, Any], + doc_annot: Dict[str, Any], ) -> Doc: ... def validate_examples( examples: Iterable[Example], @@ -39,35 +40,20 @@ class Example: def reference(self, doc: Doc) -> None: ... def copy(self) -> Example: ... @classmethod - def from_dict(cls, predicted: Doc, example_dict: Dict) -> Example: ... + def from_dict(cls, predicted: Doc, example_dict: Dict[str, Any]) -> Example: ... @property def alignment(self) -> Alignment: ... - def _get_aligned_vectorized(self, align, gold_values): ... - def _get_aligned_non_vectorized(self, align, gold_values): ... - def get_aligned(self, field, as_string=False): ... + def get_aligned(self, field: str, as_string=False): ... def get_aligned_parse(self, projectivize=True): ... def get_aligned_sent_starts(self): ... - def get_aligned_spans_x2y(self, x_spans, allow_overlap=False): ... - def get_aligned_spans_y2x(self, y_spans, allow_overlap=False): ... - def _get_aligned_spans(self, doc, spans, align, allow_overlap): ... - def get_aligned_ents_and_ner(self): ... - def get_aligned_ner(self): ... + def get_aligned_spans_x2y(self, x_spans: Sequence[Span], allow_overlap=False) -> List[Span]: ... + def get_aligned_spans_y2x(self, y_spans: Sequence[Span], allow_overlap=False) -> List[Span]: ... + def get_aligned_ents_and_ner(self) -> Tuple[List[Span], List[str]]: ... + def get_aligned_ner(self) -> List[str]: ... def get_matching_ents(self, check_label: bool = True) -> List[Span]: ... def to_dict(self) -> Dict[str, Any]: ... - def _spans_to_dict(self) -> Dict[str, List[Tuple[int, int, str, str]]]: ... - def _links_to_dict(self) -> Dict[Tuple[int, int], Dict[str, float]]: ... def split_sents(self) -> List[Example]: ... @property def text(self) -> str: ... def __str__(self) -> str: ... def __repr__(self) -> str: ... - -def _annot2array(vocab, tok_annot, doc_annot): ... -def _add_spans_to_doc(doc, spans_data): ... -def _add_entities_to_doc(doc, ner_data): ... -def _parse_example_dict_data(example_dict): ... -def _fix_legacy_dict_data(example_dict): ... -def _has_field(annot, field) -> bool: ... -def _parse_ner_tags(biluo_or_offsets, vocab, words, spaces): ... -def _parse_links(vocab, words, spaces, links): ... -def _guess_spaces(text, words): ...