2019-08-23 18:54:00 +03:00
|
|
|
from spacy.pipeline.pipes import DependencyParser
|
|
|
|
from spacy.vocab import Vocab
|
|
|
|
|
2020-05-19 17:20:03 +03:00
|
|
|
from spacy.pipeline.defaults import default_parser
|
2020-02-27 20:42:27 +03:00
|
|
|
|
2019-08-23 18:54:00 +03:00
|
|
|
|
|
|
|
def test_issue3830_no_subtok():
|
|
|
|
"""Test that the parser doesn't have subtok label if not learn_tokens"""
|
2020-06-20 15:15:04 +03:00
|
|
|
config = {
|
|
|
|
"learn_tokens": False,
|
|
|
|
"min_action_freq": 30,
|
|
|
|
"beam_width": 1,
|
|
|
|
"beam_update_prob": 1.0,
|
|
|
|
}
|
2020-06-12 03:02:07 +03:00
|
|
|
parser = DependencyParser(Vocab(), default_parser(), **config)
|
2019-08-23 18:54:00 +03:00
|
|
|
parser.add_label("nsubj")
|
|
|
|
assert "subtok" not in parser.labels
|
|
|
|
parser.begin_training(lambda: [])
|
|
|
|
assert "subtok" not in parser.labels
|
|
|
|
|
|
|
|
|
|
|
|
def test_issue3830_with_subtok():
|
|
|
|
"""Test that the parser does have subtok label if learn_tokens=True."""
|
2020-06-20 15:15:04 +03:00
|
|
|
config = {
|
|
|
|
"learn_tokens": True,
|
|
|
|
"min_action_freq": 30,
|
|
|
|
"beam_width": 1,
|
|
|
|
"beam_update_prob": 1.0,
|
|
|
|
}
|
2020-06-12 03:02:07 +03:00
|
|
|
parser = DependencyParser(Vocab(), default_parser(), **config)
|
2019-08-23 18:54:00 +03:00
|
|
|
parser.add_label("nsubj")
|
|
|
|
assert "subtok" not in parser.labels
|
|
|
|
parser.begin_training(lambda: [])
|
|
|
|
assert "subtok" in parser.labels
|