Skip to content

Commit 439f30f

Browse files
ezoritaldorigo
andauthored
Add stub files for main cython classes (#8427)
* Add stub files for main API classes * Add contributor agreement for ezorita * Update types for ndarray and hash() * Fix __getitem__ and __iter__ * Add attributes of Doc and Token classes * Overload type hints for Span.__getitem__ * Fix type hint overload for Span.__getitem__ Co-authored-by: Luca Dorigo <dorigoluca@gmail.com>
1 parent 56d4d87 commit 439f30f

11 files changed

Lines changed: 881 additions & 0 deletions

File tree

.github/contributors/ezorita.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# spaCy contributor agreement
2+
3+
This spaCy Contributor Agreement (**"SCA"**) is based on the
4+
[Oracle Contributor Agreement](http://www.oracle.com/technetwork/oca-405177.pdf).
5+
The SCA applies to any contribution that you make to any product or project
6+
managed by us (the **"project"**), and sets out the intellectual property rights
7+
you grant to us in the contributed materials. The term **"us"** shall mean
8+
[ExplosionAI GmbH](https://explosion.ai/legal). The term
9+
**"you"** shall mean the person or entity identified below.
10+
11+
If you agree to be bound by these terms, fill in the information requested
12+
below and include the filled-in version with your first pull request, under the
13+
folder [`.github/contributors/`](/.github/contributors/). The name of the file
14+
should be your GitHub username, with the extension `.md`. For example, the user
15+
example_user would create the file `.github/contributors/example_user.md`.
16+
17+
Read this agreement carefully before signing. These terms and conditions
18+
constitute a binding legal agreement.
19+
20+
## Contributor Agreement
21+
22+
1. The term "contribution" or "contributed materials" means any source code,
23+
object code, patch, tool, sample, graphic, specification, manual,
24+
documentation, or any other material posted or submitted by you to the project.
25+
26+
2. With respect to any worldwide copyrights, or copyright applications and
27+
registrations, in your contribution:
28+
29+
* you hereby assign to us joint ownership, and to the extent that such
30+
assignment is or becomes invalid, ineffective or unenforceable, you hereby
31+
grant to us a perpetual, irrevocable, non-exclusive, worldwide, no-charge,
32+
royalty-free, unrestricted license to exercise all rights under those
33+
copyrights. This includes, at our option, the right to sublicense these same
34+
rights to third parties through multiple levels of sublicensees or other
35+
licensing arrangements;
36+
37+
* you agree that each of us can do all things in relation to your
38+
contribution as if each of us were the sole owners, and if one of us makes
39+
a derivative work of your contribution, the one who makes the derivative
40+
work (or has it made will be the sole owner of that derivative work;
41+
42+
* you agree that you will not assert any moral rights in your contribution
43+
against us, our licensees or transferees;
44+
45+
* you agree that we may register a copyright in your contribution and
46+
exercise all ownership rights associated with it; and
47+
48+
* you agree that neither of us has any duty to consult with, obtain the
49+
consent of, pay or render an accounting to the other for any use or
50+
distribution of your contribution.
51+
52+
3. With respect to any patents you own, or that you can license without payment
53+
to any third party, you hereby grant to us a perpetual, irrevocable,
54+
non-exclusive, worldwide, no-charge, royalty-free license to:
55+
56+
* make, have made, use, sell, offer to sell, import, and otherwise transfer
57+
your contribution in whole or in part, alone or in combination with or
58+
included in any product, work or materials arising out of the project to
59+
which your contribution was submitted, and
60+
61+
* at our option, to sublicense these same rights to third parties through
62+
multiple levels of sublicensees or other licensing arrangements.
63+
64+
4. Except as set out above, you keep all right, title, and interest in your
65+
contribution. The rights that you grant to us under these terms are effective
66+
on the date you first submitted a contribution to us, even if your submission
67+
took place before the date you sign these terms.
68+
69+
5. You covenant, represent, warrant and agree that:
70+
71+
* Each contribution that you submit is and shall be an original work of
72+
authorship and you can legally grant the rights set out in this SCA;
73+
74+
* to the best of your knowledge, each contribution will not violate any
75+
third party's copyrights, trademarks, patents, or other intellectual
76+
property rights; and
77+
78+
* each contribution shall be in compliance with U.S. export control laws and
79+
other applicable export and import laws. You agree to notify us if you
80+
become aware of any circumstance which would make any of the foregoing
81+
representations inaccurate in any respect. We may publicly disclose your
82+
participation in the project, including the fact that you have signed the SCA.
83+
84+
6. This SCA is governed by the laws of the State of California and applicable
85+
U.S. Federal law. Any choice of law rules will not apply.
86+
87+
7. Please place an “x” on one of the applicable statement below. Please do NOT
88+
mark both statements:
89+
90+
* [x] I am signing on behalf of myself as an individual and no other person
91+
or entity, including my employer, has or will have rights with respect to my
92+
contributions.
93+
94+
* [ ] I am signing on behalf of my employer or a legal entity and I have the
95+
actual authority to contractually bind that entity.
96+
97+
## Contributor Details
98+
99+
| Field | Entry |
100+
|------------------------------- | -------------------- |
101+
| Name | Eduard Zorita |
102+
| Company name (if applicable) | |
103+
| Title or role (if applicable) | |
104+
| Date | 06/17/2021 |
105+
| GitHub username | ezorita |
106+
| Website (optional) | |

spacy/lexeme.pyi

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
from typing import (
2+
Union,
3+
Any,
4+
)
5+
from thinc.types import Floats1d
6+
from .tokens import Doc, Span, Token
7+
from .vocab import Vocab
8+
9+
class Lexeme:
10+
def __init__(self, vocab: Vocab, orth: int) -> None: ...
11+
def __richcmp__(self, other: Lexeme, op: int) -> bool: ...
12+
def __hash__(self) -> int: ...
13+
def set_attrs(self, **attrs: Any) -> None: ...
14+
def set_flag(self, flag_id: int, value: bool) -> None: ...
15+
def check_flag(self, flag_id: int) -> bool: ...
16+
def similarity(self, other: Union[Doc, Span, Token, Lexeme]) -> float: ...
17+
@property
18+
def has_vector(self) -> bool: ...
19+
@property
20+
def vector_norm(self) -> float: ...
21+
vector: Floats1d
22+
rank: str
23+
sentiment: float
24+
@property
25+
def orth_(self) -> str: ...
26+
@property
27+
def text(self) -> str: ...
28+
lower: str
29+
norm: int
30+
shape: int
31+
prefix: int
32+
suffix: int
33+
cluster: int
34+
lang: int
35+
prob: float
36+
lower_: str
37+
norm_: str
38+
shape_: str
39+
prefix_: str
40+
suffix_: str
41+
lang_: str
42+
flags: int
43+
@property
44+
def is_oov(self) -> bool: ...
45+
is_stop: bool
46+
is_alpha: bool
47+
is_ascii: bool
48+
is_digit: bool
49+
is_lower: bool
50+
is_upper: bool
51+
is_title: bool
52+
is_punct: bool
53+
is_space: bool
54+
is_bracket: bool
55+
is_quote: bool
56+
is_left_punct: bool
57+
is_right_punct: bool
58+
is_currency: bool
59+
like_url: bool
60+
like_num: bool
61+
like_email: bool

spacy/matcher/matcher.pyi

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from typing import Any, List, Dict, Tuple, Optional, Callable, Union, Iterator, Iterable
2+
from ..vocab import Vocab
3+
from ..tokens import Doc, Span
4+
5+
class Matcher:
6+
def __init__(self, vocab: Vocab, validate: bool = ...) -> None: ...
7+
def __reduce__(self) -> Any: ...
8+
def __len__(self) -> int: ...
9+
def __contains__(self, key: str) -> bool: ...
10+
def add(
11+
self,
12+
key: str,
13+
patterns: List[List[Dict[str, Any]]],
14+
*,
15+
on_match: Optional[
16+
Callable[[Matcher, Doc, int, List[Tuple[Any, ...]]], Any]
17+
] = ...,
18+
greedy: Optional[str] = ...
19+
) -> None: ...
20+
def remove(self, key: str) -> None: ...
21+
def has_key(self, key: Union[str, int]) -> bool: ...
22+
def get(
23+
self, key: Union[str, int], default: Optional[Any] = ...
24+
) -> Tuple[Optional[Callable[[Any], Any]], List[List[Dict[Any, Any]]]]: ...
25+
def pipe(
26+
self,
27+
docs: Iterable[Tuple[Doc, Any]],
28+
batch_size: int = ...,
29+
return_matches: bool = ...,
30+
as_tuples: bool = ...,
31+
) -> Union[
32+
Iterator[Tuple[Tuple[Doc, Any], Any]], Iterator[Tuple[Doc, Any]], Iterator[Doc]
33+
]: ...
34+
def __call__(
35+
self,
36+
doclike: Union[Doc, Span],
37+
*,
38+
as_spans: bool = ...,
39+
allow_missing: bool = ...,
40+
with_alignments: bool = ...
41+
) -> Union[List[Tuple[int, int, int]], List[Span]]: ...

spacy/strings.pyi

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from typing import Optional, Iterable, Iterator, Union, Any
2+
from pathlib import Path
3+
4+
def get_string_id(key: str) -> int: ...
5+
6+
class StringStore:
7+
def __init__(
8+
self, strings: Optional[Iterable[str]] = ..., freeze: bool = ...
9+
) -> None: ...
10+
def __getitem__(self, string_or_id: Union[bytes, str, int]) -> Union[str, int]: ...
11+
def as_int(self, key: Union[bytes, str, int]) -> int: ...
12+
def as_string(self, key: Union[bytes, str, int]) -> str: ...
13+
def add(self, string: str) -> int: ...
14+
def __len__(self) -> int: ...
15+
def __contains__(self, string: str) -> bool: ...
16+
def __iter__(self) -> Iterator[str]: ...
17+
def __reduce__(self) -> Any: ...
18+
def to_disk(self, path: Union[str, Path]) -> None: ...
19+
def from_disk(self, path: Union[str, Path]) -> StringStore: ...
20+
def to_bytes(self, **kwargs: Any) -> bytes: ...
21+
def from_bytes(self, bytes_data: bytes, **kwargs: Any) -> StringStore: ...
22+
def _reset_and_load(self, strings: Iterable[str]) -> None: ...

spacy/tokens/_retokenize.pyi

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from typing import Dict, Any, Union, List, Tuple
2+
from .doc import Doc
3+
from .span import Span
4+
from .token import Token
5+
6+
class Retokenizer:
7+
def __init__(self, doc: Doc) -> None: ...
8+
def merge(self, span: Span, attrs: Dict[Union[str, int], Any] = ...) -> None: ...
9+
def split(
10+
self,
11+
token: Token,
12+
orths: List[str],
13+
heads: List[Union[Token, Tuple[Token, int]]],
14+
attrs: Dict[Union[str, int], List[Any]] = ...,
15+
) -> None: ...
16+
def __enter__(self) -> Retokenizer: ...
17+
def __exit__(self, *args: Any) -> None: ...

0 commit comments

Comments
 (0)