mirror of https://github.com/explosion/spaCy.git
spacy-101 vocab doc giving valid variable names (#2236)
This commit is contained in:
parent
b4d35c7dfb
commit
df389e5b74
|
@ -96,13 +96,13 @@ p
|
||||||
assert doc.vocab.strings[3197928453018144401] == u'coffee' # 👍
|
assert doc.vocab.strings[3197928453018144401] == u'coffee' # 👍
|
||||||
|
|
||||||
empty_doc = Doc(Vocab()) # new Doc with empty Vocab
|
empty_doc = Doc(Vocab()) # new Doc with empty Vocab
|
||||||
# doc.vocab.strings[3197928453018144401] will raise an error :(
|
# empty_doc.vocab.strings[3197928453018144401] will raise an error :(
|
||||||
|
|
||||||
empty_doc.vocab.strings.add(u'coffee') # add "coffee" and generate hash
|
empty_doc.vocab.strings.add(u'coffee') # add "coffee" and generate hash
|
||||||
assert doc.vocab.strings[3197928453018144401] == u'coffee' # 👍
|
assert empty_doc.vocab.strings[3197928453018144401] == u'coffee' # 👍
|
||||||
|
|
||||||
new_doc = Doc(doc.vocab) # create new doc with first doc's vocab
|
new_doc = Doc(doc.vocab) # create new doc with first doc's vocab
|
||||||
assert doc.vocab.strings[3197928453018144401] == u'coffee' # 👍
|
assert new_doc.vocab.strings[3197928453018144401] == u'coffee' # 👍
|
||||||
|
|
||||||
p
|
p
|
||||||
| If the vocabulary doesn't contain a string for #[code 3197928453018144401],
|
| If the vocabulary doesn't contain a string for #[code 3197928453018144401],
|
||||||
|
|
Loading…
Reference in New Issue