mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-12 18:26:30 +03:00
Test pickling hooks
This commit is contained in:
parent
cdb0c426d8
commit
fe844148f6
|
@ -41,3 +41,14 @@ def test_user_data_unpickles():
|
|||
b = pickle.dumps(doc)
|
||||
doc2 = pickle.loads(b)
|
||||
assert doc2.user_data[(0, 1)] == False
|
||||
|
||||
|
||||
def test_hooks_unpickle():
|
||||
def inner_func(d1, d2):
|
||||
return 'hello!'
|
||||
nlp = Language()
|
||||
doc = nlp(u'Hello')
|
||||
doc.user_hooks['similarity'] = inner_func
|
||||
b = pickle.dumps(doc)
|
||||
doc2 = pickle.loads(b)
|
||||
assert doc2.similarity(None) == 'hello!'
|
||||
|
|
Loading…
Reference in New Issue
Block a user