mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 18:06:29 +03:00
Fix Doc.from_array example to make it work (see #1527)
This commit is contained in:
parent
49635350f0
commit
1fa6ba8130
|
@ -401,11 +401,11 @@ p
|
||||||
+aside-code("Example").
|
+aside-code("Example").
|
||||||
from spacy.attrs import LOWER, POS, ENT_TYPE, IS_ALPHA
|
from spacy.attrs import LOWER, POS, ENT_TYPE, IS_ALPHA
|
||||||
from spacy.tokens import Doc
|
from spacy.tokens import Doc
|
||||||
doc = nlp(text)
|
doc = nlp("Hello world!")
|
||||||
np_array = doc.to_array([LOWER, POS, ENT_TYPE, IS_ALPHA])
|
np_array = doc.to_array([LOWER, POS, ENT_TYPE, IS_ALPHA])
|
||||||
doc2 = Doc(doc.vocab)
|
doc2 = Doc(doc.vocab, words=[t.text for t in doc])
|
||||||
doc2.from_array([LOWER, POS, ENT_TYPE, IS_ALPHA], np_array)
|
doc2.from_array([LOWER, POS, ENT_TYPE, IS_ALPHA], np_array)
|
||||||
assert doc.text == doc2.text
|
assert doc[0].pos_ == doc2[0].pos_
|
||||||
|
|
||||||
+table(["Name", "Type", "Description"])
|
+table(["Name", "Type", "Description"])
|
||||||
+row
|
+row
|
||||||
|
|
Loading…
Reference in New Issue
Block a user