Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix component lookup #4244

Merged
merged 14 commits into from Aug 15, 2019
Merged
11 changes: 6 additions & 5 deletions CHANGELOG.rst
Expand Up @@ -11,19 +11,20 @@ This project adheres to `Semantic Versioning`_ starting with version 1.0.

Added
-----
- `FallbackPolicy` can now be configured to trigger when the difference between confidences of two predicted intents is too narrow
- `FallbackPolicy` can now be configured to trigger when the difference between
confidences of two predicted intents is too narrow
- throw error during training when triggers are defined in the domain without
``MappingPolicy`` being present in the policy ensemble
- The tracker is now avaialble within the interpreter's ``parse`` method, giving the ability to create interpreter classes that use the tracker state (eg. slot values) during the parsing of the message. More details on motivation of this change see issues/3015
- The tracker is now available within the interpreter's ``parse`` method, giving the
ability to create interpreter classes that use the tracker state (eg. slot values)
during the parsing of the message. More details on motivation of this change see
issues/3015

Changed
-------
- added character-level ``CountVectorsFeaturizer`` with empirically found parameters
into the ``supervised_embeddings`` NLU pipeline template
- bot messages contain the `timestamp` of the `BotUttered` event, which can be used in channels

Changed
-------
- NLU evaluations now also stores its output in the output directory like the core evaluation

Removed
Expand Down
14 changes: 4 additions & 10 deletions rasa/nlu/registry.py
Expand Up @@ -117,23 +117,17 @@
{"name": "CountVectorsFeaturizer"},
{
"name": "CountVectorsFeaturizer",
"config": {"analyzer": "char_wb", "min_ngram": 1, "max_ngram": 4},
"analyzer": "char_wb",
"min_ngram": 1,
"max_ngram": 4,
},
{"name": "EmbeddingIntentClassifier"},
],
}


def pipeline_template(s: Text) -> Optional[List[Dict[Text, Any]]]:
components = registered_pipeline_templates.get(s)

if components:
# converts the list of components in the configuration
# format expected (one json object per component)
return [{"name": c.get("name"), **c.get("config", {})} for c in components]

else:
return None
return registered_pipeline_templates.get(s)


def get_component_class(component_name: Text) -> Type["Component"]:
Expand Down
13 changes: 10 additions & 3 deletions tests/nlu/base/test_config.py
@@ -1,4 +1,6 @@
import json
import tempfile
from typing import Text

import pytest

Expand Down Expand Up @@ -40,13 +42,18 @@ def test_invalid_pipeline_template():
assert "unknown pipeline template" in str(execinfo.value)


def test_pipeline_looksup_registry():
pipeline_template = list(registered_pipeline_templates)[0]
@pytest.mark.parametrize(
"pipeline_template", list(registered_pipeline_templates.keys())
)
def test_pipeline_looksup_registry(pipeline_template: Text):
wochinge marked this conversation as resolved.
Show resolved Hide resolved
args = {"pipeline": pipeline_template}
f = write_file_config(args)
final_config = config.load(f.name)
components = [c for c in final_config.pipeline]
assert components == registered_pipeline_templates[pipeline_template]

assert json.dumps(components, sort_keys=True) == json.dumps(
registered_pipeline_templates[pipeline_template], sort_keys=True
)


def test_default_config_file():
Expand Down