mirror of https://github.com/explosion/spaCy.git
Ensure hyphen in config file works as string value (#7642)
* add test for serializing '-' in a config file * bump srsly to 2.4.1
This commit is contained in:
parent
27dbbb9903
commit
8d7af5b2b1
|
@ -7,7 +7,7 @@ blis>=0.4.0,<0.8.0
|
||||||
ml_datasets>=0.2.0,<0.3.0
|
ml_datasets>=0.2.0,<0.3.0
|
||||||
murmurhash>=0.28.0,<1.1.0
|
murmurhash>=0.28.0,<1.1.0
|
||||||
wasabi>=0.8.1,<1.1.0
|
wasabi>=0.8.1,<1.1.0
|
||||||
srsly>=2.4.0,<3.0.0
|
srsly>=2.4.1,<3.0.0
|
||||||
catalogue>=2.0.1,<2.1.0
|
catalogue>=2.0.1,<2.1.0
|
||||||
typer>=0.3.0,<0.4.0
|
typer>=0.3.0,<0.4.0
|
||||||
pathy>=0.3.5
|
pathy>=0.3.5
|
||||||
|
|
|
@ -44,7 +44,7 @@ install_requires =
|
||||||
thinc>=8.0.2,<8.1.0
|
thinc>=8.0.2,<8.1.0
|
||||||
blis>=0.4.0,<0.8.0
|
blis>=0.4.0,<0.8.0
|
||||||
wasabi>=0.8.1,<1.1.0
|
wasabi>=0.8.1,<1.1.0
|
||||||
srsly>=2.4.0,<3.0.0
|
srsly>=2.4.1,<3.0.0
|
||||||
catalogue>=2.0.1,<2.1.0
|
catalogue>=2.0.1,<2.1.0
|
||||||
typer>=0.3.0,<0.4.0
|
typer>=0.3.0,<0.4.0
|
||||||
pathy>=0.3.5
|
pathy>=0.3.5
|
||||||
|
|
|
@ -4,7 +4,7 @@ import spacy
|
||||||
from spacy.lang.en import English
|
from spacy.lang.en import English
|
||||||
from spacy.lang.de import German
|
from spacy.lang.de import German
|
||||||
from spacy.language import Language, DEFAULT_CONFIG, DEFAULT_CONFIG_PRETRAIN_PATH
|
from spacy.language import Language, DEFAULT_CONFIG, DEFAULT_CONFIG_PRETRAIN_PATH
|
||||||
from spacy.util import registry, load_model_from_config, load_config
|
from spacy.util import registry, load_model_from_config, load_config, load_config_from_str
|
||||||
from spacy.ml.models import build_Tok2Vec_model, build_tb_parser_model
|
from spacy.ml.models import build_Tok2Vec_model, build_tb_parser_model
|
||||||
from spacy.ml.models import MultiHashEmbed, MaxoutWindowEncoder
|
from spacy.ml.models import MultiHashEmbed, MaxoutWindowEncoder
|
||||||
from spacy.schemas import ConfigSchema, ConfigSchemaPretrain
|
from spacy.schemas import ConfigSchema, ConfigSchemaPretrain
|
||||||
|
@ -465,3 +465,32 @@ def test_config_only_resolve_relevant_blocks():
|
||||||
nlp.initialize()
|
nlp.initialize()
|
||||||
nlp.config["initialize"]["lookups"] = None
|
nlp.config["initialize"]["lookups"] = None
|
||||||
nlp.initialize()
|
nlp.initialize()
|
||||||
|
|
||||||
|
|
||||||
|
def test_hyphen_in_config():
|
||||||
|
hyphen_config_str = """
|
||||||
|
[nlp]
|
||||||
|
lang = "en"
|
||||||
|
pipeline = ["my_punctual_component"]
|
||||||
|
|
||||||
|
[components]
|
||||||
|
|
||||||
|
[components.my_punctual_component]
|
||||||
|
factory = "my_punctual_component"
|
||||||
|
punctuation = ["?","-"]
|
||||||
|
"""
|
||||||
|
|
||||||
|
@spacy.Language.factory("my_punctual_component")
|
||||||
|
class MyPunctualComponent(object):
|
||||||
|
name = "my_punctual_component"
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
nlp,
|
||||||
|
name,
|
||||||
|
punctuation,
|
||||||
|
):
|
||||||
|
self.punctuation = punctuation
|
||||||
|
|
||||||
|
nlp = English.from_config(load_config_from_str(hyphen_config_str))
|
||||||
|
assert nlp.get_pipe("my_punctual_component").punctuation == ['?', '-']
|
||||||
|
|
Loading…
Reference in New Issue