Exemple #1
0
def get_custom_name(component: Dict[Text, Any]) -> Optional[Text]:
    """Checks whether there is a separate "class" attribute or just a name
    and returns the name in either case"""
    if "class" in component:
        return component.get("name")
    else:
        return utils.class_from_module_path(component.get("name")).name
Exemple #2
0
def get_component_class(component_name: Text) -> Type['Component']:
    """Resolve component name to a registered components class."""

    if component_name not in registered_components:
        if component_name not in old_style_names:
            try:
                return utils.class_from_module_path(component_name)
            except Exception:
                raise Exception(
                    "Failed to find component class for '{}'. Unknown "
                    "component name. Check your configured pipeline and make "
                    "sure the mentioned component is not misspelled. If you "
                    "are creating your own component, make sure it is either "
                    "listed as part of the `component_classes` in "
                    "`rasa_nlu.registry.py` or is a proper name of a class "
                    "in a module.".format(component_name))
        else:
            # DEPRECATED ensures compatibility, remove in future versions
            logger.warning("DEPRECATION warning: your nlu config file "
                           "contains old style component name `{}`, "
                           "you should change it to its class name: `{}`."
                           "".format(component_name,
                                     old_style_names[component_name]))
            component_name = old_style_names[component_name]

    return registered_components[component_name]
Exemple #3
0
def get_component_class(component_name: Text) -> Type['Component']:
    """Resolve component name to a registered components class."""

    if component_name not in registered_components:
        if component_name not in old_style_names:
            try:
                return utils.class_from_module_path(component_name)
            except Exception:
                raise Exception(
                    "Failed to find component class for '{}'. Unknown "
                    "component name. Check your configured pipeline and make "
                    "sure the mentioned component is not misspelled. If you "
                    "are creating your own component, make sure it is either "
                    "listed as part of the `component_classes` in "
                    "`rasa_nlu.registry.py` or is a proper name of a class "
                    "in a module.".format(component_name))
        else:
            # DEPRECATED ensures compatibility, remove in future versions
            logger.warning("DEPRECATION warning: your nlu config file "
                           "contains old style component name `{}`, "
                           "you should change it to its class name: `{}`."
                           "".format(component_name,
                                     old_style_names[component_name]))
            component_name = old_style_names[component_name]

    return registered_components[component_name]
Exemple #4
0
def get_component_class(component_name: Text) -> Type['Component']:
    """Resolve component name to a registered components class."""

    if component_name not in registered_components:
        try:
            return utils.class_from_module_path(component_name)
        except Exception:
            raise Exception(
                "Failed to find component class for '{}'. Unknown "
                "component name. Check your configured pipeline and make "
                "sure the mentioned component is not misspelled. If you "
                "are creating your own component, make sure it is either "
                "listed as part of the `component_classes` in "
                "`rasa_nlu.registry.py` or is a proper name of a class "
                "in a module.".format(component_name))
    return registered_components[component_name]
Exemple #5
0
def get_component_class(component_name):
    # type: (Text) -> Optional[Type[Component]]
    """Resolve component name to a registered components class."""

    if component_name not in registered_components:
        try:
            return utils.class_from_module_path(component_name)
        except Exception:
            raise Exception(
                    "Failed to find component class for '{}'. Unknown "
                    "component name. Check your configured pipeline and make "
                    "sure the mentioned component is not misspelled. If you "
                    "are creating your own component, make sure it is either "
                    "listed as part of the `component_classes` in "
                    "`rasa_nlu.registry.py` or is a proper name of a class "
                    "in a module.".format(component_name))
    return registered_components[component_name]