mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-15 06:09:01 +03:00
30cf9d6a05
* Improve typing hints for Matcher.__call__ * Add typing hints for DependencyMatcher * Add typing hints to underscore extensions * Update Doc.tensor type (requires numpy 1.21) * Fix typing hints for Language.component decorator * Use generic np.ndarray type in Doc to avoid numpy version update * Fix mypy errors * Fix cyclic import caused by Underscore typing hints * Use Literal type from spacy.compat * Update matcher.pyi import format Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com> Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
67 lines
2.1 KiB
Python
67 lines
2.1 KiB
Python
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
|
|
from .matcher import Matcher
|
|
from ..vocab import Vocab
|
|
from ..tokens.doc import Doc
|
|
from ..tokens.span import Span
|
|
|
|
class DependencyMatcher:
|
|
"""Match dependency parse tree based on pattern rules."""
|
|
|
|
_patterns: Dict[str, List[Any]]
|
|
_raw_patterns: Dict[str, List[Any]]
|
|
_tokens_to_key: Dict[str, List[Any]]
|
|
_root: Dict[str, List[Any]]
|
|
_tree: Dict[str, List[Any]]
|
|
_callbacks: Dict[
|
|
Any, Callable[[DependencyMatcher, Doc, int, List[Tuple[int, List[int]]]], Any]
|
|
]
|
|
_ops: Dict[str, Any]
|
|
vocab: Vocab
|
|
_matcher: Matcher
|
|
def __init__(self, vocab: Vocab, *, validate: bool = ...) -> None: ...
|
|
def __reduce__(
|
|
self,
|
|
) -> Tuple[
|
|
Callable[
|
|
[Vocab, Dict[str, Any], Dict[str, Callable[..., Any]]], DependencyMatcher
|
|
],
|
|
Tuple[
|
|
Vocab,
|
|
Dict[str, List[Any]],
|
|
Dict[
|
|
str,
|
|
Callable[
|
|
[DependencyMatcher, Doc, int, List[Tuple[int, List[int]]]], Any
|
|
],
|
|
],
|
|
],
|
|
None,
|
|
None,
|
|
]: ...
|
|
def __len__(self) -> int: ...
|
|
def __contains__(self, key: Union[str, int]) -> bool: ...
|
|
def add(
|
|
self,
|
|
key: Union[str, int],
|
|
patterns: List[List[Dict[str, Any]]],
|
|
*,
|
|
on_match: Optional[
|
|
Callable[[DependencyMatcher, Doc, int, List[Tuple[int, List[int]]]], Any]
|
|
] = ...
|
|
) -> None: ...
|
|
def has_key(self, key: Union[str, int]) -> bool: ...
|
|
def get(
|
|
self, key: Union[str, int], default: Optional[Any] = ...
|
|
) -> Tuple[
|
|
Optional[
|
|
Callable[[DependencyMatcher, Doc, int, List[Tuple[int, List[int]]]], Any]
|
|
],
|
|
List[List[Dict[str, Any]]],
|
|
]: ...
|
|
def remove(self, key: Union[str, int]) -> None: ...
|
|
def __call__(self, doclike: Union[Doc, Span]) -> List[Tuple[int, List[int]]]: ...
|
|
|
|
def unpickle_matcher(
|
|
vocab: Vocab, patterns: Dict[str, Any], callbacks: Dict[str, Callable[..., Any]]
|
|
) -> DependencyMatcher: ...
|