mirror of https://github.com/explosion/spaCy.git
fix docs for Span constructor arguments (#9023)
This commit is contained in:
parent
31e9b126a0
commit
94fb840443
|
@ -89,9 +89,10 @@ cdef class Span:
|
||||||
start (int): The index of the first token of the span.
|
start (int): The index of the first token of the span.
|
||||||
end (int): The index of the first token after the span.
|
end (int): The index of the first token after the span.
|
||||||
label (uint64): A label to attach to the Span, e.g. for named entities.
|
label (uint64): A label to attach to the Span, e.g. for named entities.
|
||||||
kb_id (uint64): An identifier from a Knowledge Base to capture the meaning of a named entity.
|
|
||||||
vector (ndarray[ndim=1, dtype='float32']): A meaning representation
|
vector (ndarray[ndim=1, dtype='float32']): A meaning representation
|
||||||
of the span.
|
of the span.
|
||||||
|
vector_norm (float): The L2 norm of the span's vector representation.
|
||||||
|
kb_id (uint64): An identifier from a Knowledge Base to capture the meaning of a named entity.
|
||||||
|
|
||||||
DOCS: https://spacy.io/api/span#init
|
DOCS: https://spacy.io/api/span#init
|
||||||
"""
|
"""
|
||||||
|
@ -486,10 +487,10 @@ cdef class Span:
|
||||||
"""
|
"""
|
||||||
if "vector_norm" in self.doc.user_span_hooks:
|
if "vector_norm" in self.doc.user_span_hooks:
|
||||||
return self.doc.user_span_hooks["vector"](self)
|
return self.doc.user_span_hooks["vector"](self)
|
||||||
vector = self.vector
|
|
||||||
xp = get_array_module(vector)
|
|
||||||
if self._vector_norm is None:
|
if self._vector_norm is None:
|
||||||
|
vector = self.vector
|
||||||
total = (vector*vector).sum()
|
total = (vector*vector).sum()
|
||||||
|
xp = get_array_module(vector)
|
||||||
self._vector_norm = xp.sqrt(total) if total != 0. else 0.
|
self._vector_norm = xp.sqrt(total) if total != 0. else 0.
|
||||||
return self._vector_norm
|
return self._vector_norm
|
||||||
|
|
||||||
|
|
|
@ -19,13 +19,14 @@ Create a `Span` object from the slice `doc[start : end]`.
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
| Name | Description |
|
| Name | Description |
|
||||||
| -------- | --------------------------------------------------------------------------------------- |
|
| ------------- | --------------------------------------------------------------------------------------- |
|
||||||
| `doc` | The parent document. ~~Doc~~ |
|
| `doc` | The parent document. ~~Doc~~ |
|
||||||
| `start` | The index of the first token of the span. ~~int~~ |
|
| `start` | The index of the first token of the span. ~~int~~ |
|
||||||
| `end` | The index of the first token after the span. ~~int~~ |
|
| `end` | The index of the first token after the span. ~~int~~ |
|
||||||
| `label` | A label to attach to the span, e.g. for named entities. ~~Union[str, int]~~ |
|
| `label` | A label to attach to the span, e.g. for named entities. ~~Union[str, int]~~ |
|
||||||
| `kb_id` | A knowledge base ID to attach to the span, e.g. for named entities. ~~Union[str, int]~~ |
|
|
||||||
| `vector` | A meaning representation of the span. ~~numpy.ndarray[ndim=1, dtype=float32]~~ |
|
| `vector` | A meaning representation of the span. ~~numpy.ndarray[ndim=1, dtype=float32]~~ |
|
||||||
|
| `vector_norm` | The L2 norm of the document's vector representation. ~~float~~ |
|
||||||
|
| `kb_id` | A knowledge base ID to attach to the span, e.g. for named entities. ~~Union[str, int]~~ |
|
||||||
|
|
||||||
## Span.\_\_getitem\_\_ {#getitem tag="method"}
|
## Span.\_\_getitem\_\_ {#getitem tag="method"}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue