コード例 #1
0
    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)
コード例 #2
0
    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)
コード例 #3
0
    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)
コード例 #4
0
    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)
コード例 #5
0
    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)
コード例 #6
0
ファイル: torch_n2g.py プロジェクト: lsx0930/rasa_usage
    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)