mirror of
https://github.com/explosion/spaCy.git
synced 2025-03-12 15:25:47 +03:00
Update docs for Vocab.get_vector (#10486)
* Update docs for Vocab.get_vector * Clarify description of 0-vector dimensions
This commit is contained in:
parent
489336171a
commit
33e43d5b96
|
@ -354,8 +354,9 @@ cdef class Vocab:
|
||||||
|
|
||||||
def get_vector(self, orth):
|
def get_vector(self, orth):
|
||||||
"""Retrieve a vector for a word in the vocabulary. Words can be looked
|
"""Retrieve a vector for a word in the vocabulary. Words can be looked
|
||||||
up by string or int ID. If no vectors data is loaded, ValueError is
|
up by string or int ID. If the current vectors do not contain an entry
|
||||||
raised.
|
for the word, a 0-vector with the same number of dimensions as the
|
||||||
|
current vectors is returned.
|
||||||
|
|
||||||
orth (int / unicode): The hash value of a word, or its unicode string.
|
orth (int / unicode): The hash value of a word, or its unicode string.
|
||||||
RETURNS (numpy.ndarray or cupy.ndarray): A word vector. Size
|
RETURNS (numpy.ndarray or cupy.ndarray): A word vector. Size
|
||||||
|
|
|
@ -168,22 +168,19 @@ cosines are calculated in minibatches to reduce memory usage.
|
||||||
## Vocab.get_vector {#get_vector tag="method" new="2"}
|
## Vocab.get_vector {#get_vector tag="method" new="2"}
|
||||||
|
|
||||||
Retrieve a vector for a word in the vocabulary. Words can be looked up by string
|
Retrieve a vector for a word in the vocabulary. Words can be looked up by string
|
||||||
or hash value. If no vectors data is loaded, a `ValueError` is raised. If `minn`
|
or hash value. If the current vectors do not contain an entry for the word, a
|
||||||
is defined, then the resulting vector uses [FastText](https://fasttext.cc/)'s
|
0-vector with the same number of dimensions
|
||||||
subword features by average over n-grams of `orth` (introduced in spaCy `v2.1`).
|
([`Vocab.vectors_length`](#attributes)) as the current vectors is returned.
|
||||||
|
|
||||||
> #### Example
|
> #### Example
|
||||||
>
|
>
|
||||||
> ```python
|
> ```python
|
||||||
> nlp.vocab.get_vector("apple")
|
> nlp.vocab.get_vector("apple")
|
||||||
> nlp.vocab.get_vector("apple", minn=1, maxn=5)
|
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
| Name | Description |
|
| Name | Description |
|
||||||
| ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
| ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `orth` | The hash value of a word, or its unicode string. ~~Union[int, str]~~ |
|
| `orth` | The hash value of a word, or its unicode string. ~~Union[int, str]~~ |
|
||||||
| `minn` <Tag variant="new">2.1</Tag> | Minimum n-gram length used for FastText's n-gram computation. Defaults to the length of `orth`. ~~int~~ |
|
|
||||||
| `maxn` <Tag variant="new">2.1</Tag> | Maximum n-gram length used for FastText's n-gram computation. Defaults to the length of `orth`. ~~int~~ |
|
|
||||||
| **RETURNS** | A word vector. Size and shape are determined by the `Vocab.vectors` instance. ~~numpy.ndarray[ndim=1, dtype=float32]~~ |
|
| **RETURNS** | A word vector. Size and shape are determined by the `Vocab.vectors` instance. ~~numpy.ndarray[ndim=1, dtype=float32]~~ |
|
||||||
|
|
||||||
## Vocab.set_vector {#set_vector tag="method" new="2"}
|
## Vocab.set_vector {#set_vector tag="method" new="2"}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user