def create(cls, component_config: Dict[Text, Any], config: RasaNLUModelConfig) -> "SpacyNLP": import spacy component_config = override_defaults(cls.defaults, component_config) spacy_model_name = component_config.get("model") # if no model is specified, we fall back to the language string if not spacy_model_name: spacy_model_name = config.language component_config["model"] = config.language logger.info("Trying to load spacy model with name '{}'".format( spacy_model_name)) try: nlp = spacy.load(spacy_model_name, disable=["parser"]) except OSError: raise InvalidModelError( "Model '{}' is not a linked spaCy model. " "Please download and/or link a spaCy model, " "e.g. by running:\npython -m spacy download " "en_core_web_md\npython -m spacy link " "en_core_web_md en".format(spacy_model_name)) cls.ensure_proper_language_model(nlp) return cls(component_config, nlp)
def create(cls, component_config, config): component_config = override_defaults(cls.defaults, component_config) spacy_model_name = component_config.get("model") # if no model is specified, we fall back to the language string if not spacy_model_name: component_config["model"] = config.language cls.ensure_proper_language_model(nlp_language) return cls(component_config, nlp_language)
def __init__(self, component_config: Optional[Dict[Text, Any]] = None) -> None: if not component_config: component_config = {} # makes sure the name of the configuration is part of the config # this is important for e.g. persistence component_config["name"] = self.name self.component_config = override_defaults(self.defaults, component_config) self.partial_processing_pipeline = None self.partial_processing_context = None
def create(cls, component_config, config): component_config = override_defaults(cls.defaults, component_config) spacy_model_name = component_config.get("model") # if no model is specified, we fall back to the language string if not spacy_model_name: component_config["model"] = config.language print('Starting Language Model - Create {}'.format(config.language)) nlp = spacy_nlp_languages.get(config.language) cls.ensure_proper_language_model(nlp) return cls(component_config, nlp)
def create(cls, component_config: Dict[Text, Any], config: RasaNLUModelConfig) -> "MitieNLP": import mitie component_config = override_defaults(cls.defaults, component_config) model_file = component_config.get("model") if not model_file: raise Exception("The MITIE component 'MitieNLP' needs " "the configuration value for 'model'." "Please take a look at the " "documentation in the pipeline section " "to get more info about this " "parameter.") extractor = mitie.total_word_feature_extractor(model_file) cls.ensure_proper_language_model(extractor) return cls(component_config, extractor)
def create(cls, component_config: Dict[Text, Any], config: RasaNLUModelConfig) -> "SpacyNLP": component_config = override_defaults(cls.defaults, component_config) spacy_model_name = component_config.get("model") # if no model is specified, we fall back to the language string if not spacy_model_name: spacy_model_name = config.language component_config["model"] = config.language logger.info( f"Trying to load spacy model with name '{spacy_model_name}'") nlp = cls.load_model(spacy_model_name) cls.ensure_proper_language_model(nlp) return cls(component_config, nlp)
def create(cls, component_config: Dict[Text, Any], config: RasaNLUModelConfig) -> 'SpacyNLP': import spacy component_config = override_defaults(cls.defaults, component_config) spacy_model_name = component_config.get("model") # if no model is specified, we fall back to the language string if not spacy_model_name: spacy_model_name = config.language component_config["model"] = config.language logger.info("Trying to load spacy model with " "name '{}'".format(spacy_model_name)) nlp = spacy.load(spacy_model_name, disable=['parser']) cls.ensure_proper_language_model(nlp) return cls(component_config, nlp)