mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-14 05:37:03 +03:00
446a3ecf34
* `strings`: Remove unused `hash32_utf8` function
* `strings`: Make `hash_utf8` and `decode_Utf8Str` private
* `strings`: Reorganize private functions
* 'strings': Raise error when non-string/-int types are passed to functions that don't accept them
* `strings`: Add `items()` method, add type hints, remove unused methods, restrict inputs to specific types, reorganize methods
* `Morphology`: Use `StringStore.items()` to enumerate features when pickling
* `test_stringstore`: Update pre-Python 3 tests
* Update `StringStore` docs
* Fix `get_string_id` imports
* Replace redundant test with tests for type checking
* Rename `_retrieve_interned_str`, remove `.get` default arg
* Add `get_string_id` to `strings.pyi`
Remove `mypy` ignore directives from imports of the above
* `strings.pyi`: Replace functions that consume `Union`-typed params with overloads
* `strings.pyi`: Revert some function signatures
* Update `SYMBOLS_BY_INT` lookups and error codes post-merge
* Revert clobbered change introduced in a previous merge
* Remove unnecessary type hint
* Invert tuple order in `StringStore.items()`
* Add test for `StringStore.items()`
* Revert "`Morphology`: Use `StringStore.items()` to enumerate features when pickling"
This reverts commit 1af9510ceb
.
* Rename `keys` and `key_map`
* Add `keys()` and `values()`
* Add comment about the inverted key-value semantics in the API
* Fix type hints
* Implement `keys()`, `values()`, `items()` without generators
* Fix type hints, remove unnecessary boxing
* Update docs
* Simplify `keys/values/items()` impl
* `mypy` fix
* Fix error message, doc fixes
27 lines
1.2 KiB
Python
27 lines
1.2 KiB
Python
from typing import List, Optional, Iterable, Iterator, Union, Any, Tuple, overload
|
|
from pathlib import Path
|
|
|
|
class StringStore:
|
|
def __init__(self, strings: Optional[Iterable[str]]) -> None: ...
|
|
@overload
|
|
def __getitem__(self, string_or_hash: str) -> int: ...
|
|
@overload
|
|
def __getitem__(self, string_or_hash: int) -> str: ...
|
|
def as_int(self, string_or_hash: Union[str, int]) -> int: ...
|
|
def as_string(self, string_or_hash: Union[str, int]) -> str: ...
|
|
def add(self, string: str) -> int: ...
|
|
def items(self) -> List[Tuple[str, int]]: ...
|
|
def keys(self) -> List[str]: ...
|
|
def values(self) -> List[int]: ...
|
|
def __len__(self) -> int: ...
|
|
def __contains__(self, string_or_hash: Union[str, int]) -> bool: ...
|
|
def __iter__(self) -> Iterator[str]: ...
|
|
def __reduce__(self) -> Any: ...
|
|
def to_disk(self, path: Union[str, Path]) -> None: ...
|
|
def from_disk(self, path: Union[str, Path]) -> StringStore: ...
|
|
def to_bytes(self, **kwargs: Any) -> bytes: ...
|
|
def from_bytes(self, bytes_data: bytes, **kwargs: Any) -> StringStore: ...
|
|
def _reset_and_load(self, strings: Iterable[str]) -> None: ...
|
|
|
|
def get_string_id(string_or_hash: Union[str, int]) -> int: ...
|