def create(cls, config): import mitie print('configs:') print('%s' % config.items()) return MitieNLP( config["mitie_file"], mitie.total_word_feature_extractor(config["mitie_file"]))
def pipeline_init(self, mitie_file): # type: (str) -> dict if self.extractor is None: self.extractor = total_word_feature_extractor(mitie_file) MitieNLP.ensure_proper_language_model(self.extractor) return {"mitie_feature_extractor": self.extractor}
def create( cls, config: Dict[Text, Any], model_storage: ModelStorage, resource: Resource, execution_context: ExecutionContext, ) -> MitieNLP: """Creates component (see parent class for full docstring).""" import mitie model_file = config.get("model") if not model_file: raise InvalidConfigException( "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." ) if not Path(model_file).is_file(): raise InvalidConfigException( "The model file configured in the MITIE " "component cannot be found. " "Please ensure the directory path and/or " "filename, '{}', are correct.".format(model_file) ) extractor = mitie.total_word_feature_extractor(str(model_file)) return cls(Path(model_file), extractor)
def load(cls, model_dir=None, model_metadata=None, cached_component=None, **kwargs): # type: (Text, Metadata, Optional[MitieNLP], **Any) -> MitieNLP import mitie if cached_component: return cached_component mitie_file = model_metadata.get("mitie_file") return MitieNLP(mitie_file, mitie.total_word_feature_extractor(mitie_file))
def load(cls, model_dir=None, model_metadata=None, cached_plugin=None, **kwargs): # type: (Text, Metadata, Optional[MitieNLP], **Any) -> MitieNLP import mitie if cached_plugin: return cached_plugin mitie_file = model_metadata.get("mitie_file") return MitieNLP(mitie_file, mitie.total_word_feature_extractor(mitie_file))
def pipeline_init(self, mitie_file): # type: (str) -> dict print mitie_file if self.extractor is None: fileName = mitie_file.split('/')[-1] if "http" in mitie_file and not os.path.isfile("./" + fileName): url = mitie_file print mitie_file urllib.urlretrieve(url + "?dl=1", mitie_file) mitie_file = fileName self.extractor = total_word_feature_extractor(mitie_file) MitieNLP.ensure_proper_language_model(self.extractor) return {"mitie_feature_extractor": self.extractor}
def load(cls, meta: Dict[Text, Any], model_dir: Optional[Text] = None, model_metadata: Optional[Metadata] = None, cached_component: Optional['MitieNLP'] = None, **kwargs: Any) -> 'MitieNLP': import mitie if cached_component: return cached_component mitie_file = meta.get("model") return cls(meta, mitie.total_word_feature_extractor(mitie_file))
def load(cls, meta: Dict[Text, Any], model_dir: Optional[Text] = None, model_metadata: Optional[Metadata] = None, cached_component: Optional['MitieNLP'] = None, **kwargs: Any ) -> 'MitieNLP': import mitie if cached_component: return cached_component mitie_file = meta.get("model") return cls(meta, mitie.total_word_feature_extractor(mitie_file))
def load( cls, meta: Dict[Text, Any], model_dir: Text, model_metadata: Optional[Metadata] = None, cached_component: Optional["MitieNLP"] = None, **kwargs: Any, ) -> "MitieNLP": """Loads trained component (see parent class for full docstring).""" import mitie if cached_component: return cached_component mitie_file = meta.get("model") return cls(meta, mitie.total_word_feature_extractor(mitie_file))
def load(cls, model_dir=None, # type: Optional[Text] model_metadata=None, # type: Optional[Metadata] cached_component=None, # type: Optional[MitieNLP] **kwargs # type: **Any ): # type: (...) -> MitieNLP import mitie if cached_component: return cached_component component_meta = model_metadata.for_component(cls.name) mitie_file = component_meta.get("model") return cls(component_meta, mitie.total_word_feature_extractor(mitie_file))
def create(cls, cfg: RasaNLUModelConfig) -> 'MitieNLP': import mitie component_conf = cfg.for_component(cls.name, cls.defaults) model_file = component_conf.get("model") if not model_file: raise Exception("The MITIE component 'nlp_mitie' 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 MitieNLP(component_conf, extractor)
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) -> '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, mitie_file): import mitie extractor = mitie.total_word_feature_extractor(mitie_file) return MitieNLP(mitie_file, extractor)
def create(cls, config): import mitie return MitieNLP( config["mitie_file"], mitie.total_word_feature_extractor(config["mitie_file"]))
def mitie_feature_extractor(): mitie_file = "data/total_word_feature_extractor.dat" return total_word_feature_extractor(mitie_file)
def create(cls, config): import mitie return MitieNLP(config["mitie_file"], mitie.total_word_feature_extractor(config["mitie_file"]))