def load(cls, meta: Dict[Text, Any], model_dir: Optional[Text] = None, model_metadata: Optional[Metadata] = None, cached_component: Optional["SklearnIntentClassifier"] = None, **kwargs: Any) -> "SklearnIntentClassifier": classifier_file = os.path.join(model_dir, meta.get("classifier")) encoder_file = os.path.join(model_dir, meta.get("encoder")) if os.path.exists(classifier_file): classifier = utils.pycloud_unpickle(classifier_file) encoder = utils.pycloud_unpickle(encoder_file) return cls(meta, classifier, encoder) else: return cls(meta)
def load(cls, meta: Dict[Text, Any], model_dir: Optional[Text] = None, model_metadata: Optional[Metadata] = None, cached_component: Optional['rasa_sium'] = None, **kwargs: Any) -> 'rasa_sium': file_name = meta.get("file") classifier_file = os.path.join(model_dir, file_name) if os.path.exists(classifier_file): return utils.pycloud_unpickle(classifier_file) else: return cls(meta)
def load(cls, meta: Dict[Text, Any], model_dir: Optional[Text] = None, model_metadata: Optional["Metadata"] = None, cached_component: Optional["NGramFeaturizer"] = None, **kwargs: Any) -> "NGramFeaturizer": file_name = meta.get("file") featurizer_file = os.path.join(model_dir, file_name) if os.path.exists(featurizer_file): return utils.pycloud_unpickle(featurizer_file) else: return NGramFeaturizer(meta)
def load(cls, meta: Dict[Text, Any], model_dir: Text = None, model_metadata: Metadata = None, cached_component: Optional['CountVectorsFeaturizer'] = None, **kwargs: Any) -> 'CountVectorsFeaturizer': if model_dir and meta.get("file"): file_name = meta.get("file") featurizer_file = os.path.join(model_dir, file_name) return utils.pycloud_unpickle(featurizer_file) else: logger.warning("Failed to load featurizer. Maybe path {} " "doesn't exist".format(os.path.abspath(model_dir))) return CountVectorsFeaturizer(meta)
def load(cls, meta: Dict[Text, Any], model_dir: Text = None, model_metadata: Metadata = None, cached_component: Optional["CountVectorsFeaturizer"] = None, **kwargs: Any) -> "CountVectorsFeaturizer": file_name = meta.get("file") featurizer_file = os.path.join(model_dir, file_name) if os.path.exists(featurizer_file): vectorizer = utils.pycloud_unpickle(featurizer_file) return cls(meta, vectorizer) else: return cls(meta)
def load(cls, meta: Dict[Text, Any], model_dir: Optional[Text] = None, model_metadata: Optional[Metadata] = None, cached_component: Optional['N2GHelper'] = None, **kwargs) -> 'N2GHelper': """Load this component from file.""" file_name = meta.get("file") classifier_file = os.path.join(model_dir, file_name) if os.path.exists(classifier_file): return utils.pycloud_unpickle(classifier_file) else: return cls(meta)