2017-05-29 09:45:45 +00:00
|
|
|
import pytest
|
|
|
|
|
2017-10-26 10:38:23 +00:00
|
|
|
from ...pipeline import DependencyParser
|
2017-05-29 09:45:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
2017-05-29 20:14:31 +00:00
|
|
|
def parser(en_vocab):
|
2017-10-26 10:38:23 +00:00
|
|
|
parser = DependencyParser(en_vocab)
|
2017-05-29 09:45:45 +00:00
|
|
|
parser.add_label('nsubj')
|
|
|
|
parser.model, cfg = parser.Model(parser.moves.n_moves)
|
|
|
|
parser.cfg.update(cfg)
|
|
|
|
return parser
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
2017-05-29 20:14:31 +00:00
|
|
|
def blank_parser(en_vocab):
|
2017-10-26 10:38:23 +00:00
|
|
|
parser = DependencyParser(en_vocab)
|
2017-05-29 09:45:45 +00:00
|
|
|
return parser
|
|
|
|
|
|
|
|
|
|
|
|
def test_to_from_bytes(parser, blank_parser):
|
|
|
|
assert parser.model is not True
|
|
|
|
assert blank_parser.model is True
|
|
|
|
assert blank_parser.moves.n_moves != parser.moves.n_moves
|
|
|
|
bytes_data = parser.to_bytes()
|
|
|
|
blank_parser.from_bytes(bytes_data)
|
|
|
|
assert blank_parser.model is not True
|
|
|
|
assert blank_parser.moves.n_moves == parser.moves.n_moves
|