Skip to content

Commit

Permalink
Add full intent name to ranked responses (#5690)
Browse files Browse the repository at this point in the history
Add full retrieval intents to all ranked responses
  • Loading branch information
hotzenklotz authored Apr 23, 2020
1 parent 002b892 commit ac691e3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/5690.improvement.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ``full_retrieval_intent`` property to ``ResponseSelector`` rankings
5 changes: 5 additions & 0 deletions rasa/nlu/selectors/response_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ def process(self, message: Message, **kwargs: Any) -> None:
label, label_ranking = self._predict_label(out)
retrieval_intent_name = self.retrieval_intent_mapping.get(label.get("name"))

for ranking in label_ranking:
ranking["full_retrieval_intent"] = self.retrieval_intent_mapping.get(
ranking.get("name")
)

selector_key = (
self.retrieval_intent
if self.retrieval_intent
Expand Down
8 changes: 8 additions & 0 deletions tests/nlu/selectors/test_selectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,11 @@ def test_train_selector(pipeline, component_builder, tmpdir):
.get("default")
.get("full_retrieval_intent")
) is not None

ranking = parsed.get(RESPONSE_SELECTOR_PROPERTY_NAME).get("default").get("ranking")
assert ranking is not None

for rank in ranking:
assert rank.get("name") is not None
assert rank.get("confidence") is not None
assert rank.get("full_retrieval_intent") is not None

0 comments on commit ac691e3

Please sign in to comment.