Skip to content

Commit d615407

Browse files
committed
Merge branch 'master' of github.com:RasaHQ/rasa into convert_feat
2 parents 34ae1a2 + 38eb552 commit d615407

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ Fixed
3838
- Fixed server hanging forever on leaving ``rasa shell`` before first message
3939
- Fixed rasa init showing traceback error when user does Keyboard Interrupt before choosing a project path
4040
- ``CountVectorsFeaturizer`` featurizes intents only if its analyzer is set to ``word``
41-
- fixed bug where facebooks generic template was not rendered when buttons were ``None``
41+
- Fixed bug where facebooks generic template was not rendered when buttons were ``None``
42+
- Fixed default intents unnecessarily raising undefined parsing error
4243

4344
[1.4.5] - 2019-11-14
4445
^^^^^^^^^^^^^^^^^^^^

rasa/core/processor.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
ACTION_NAME_SENDER_ID_CONNECTOR_STR,
2121
USER_INTENT_RESTART,
2222
UTTER_PREFIX,
23+
USER_INTENT_BACK,
24+
USER_INTENT_OUT_OF_SCOPE,
2325
)
2426
from rasa.core.domain import Domain
2527
from rasa.core.events import (
@@ -289,17 +291,28 @@ def _log_slots(tracker):
289291
logger.debug(f"Current slot values: \n{slot_values}")
290292

291293
def _log_unseen_features(self, parse_data: Dict[Text, Any]) -> None:
292-
"""Check if the NLU interpreter picks up intents or entities that aren't in the domain."""
294+
"""Check if the NLU interpreter picks up intents or entities that aren't recognized."""
293295

294296
domain_is_not_empty = self.domain and not self.domain.is_empty()
297+
298+
default_intents = [
299+
USER_INTENT_RESTART,
300+
USER_INTENT_BACK,
301+
USER_INTENT_OUT_OF_SCOPE,
302+
]
303+
295304
intent = parse_data["intent"]["name"]
296-
if intent and domain_is_not_empty and intent not in self.domain.intents:
297-
warnings.warn(
298-
f"Interpreter parsed an intent '{intent}' "
299-
"that is not defined in the domain."
300-
)
305+
if intent:
306+
intent_is_recognized = (
307+
domain_is_not_empty and intent in self.domain.intents
308+
) or intent in default_intents
309+
if not intent_is_recognized:
310+
warnings.warn(
311+
f"Interpreter parsed an intent '{intent}' "
312+
"that is not defined in the domain."
313+
)
301314

302-
entities = parse_data["entities"]
315+
entities = parse_data["entities"] or []
303316
for element in entities:
304317
entity = element["entity"]
305318
if entity and domain_is_not_empty and entity not in self.domain.entities:

tests/core/test_processor.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ async def test_log_unseen_feature(default_processor: MessageProcessor):
8383
)
8484

8585

86+
async def test_default_intent_recognized(default_processor: MessageProcessor):
87+
message = UserMessage("/restart")
88+
parsed = await default_processor._parse_message(message)
89+
with pytest.warns(None) as record:
90+
default_processor._log_unseen_features(parsed)
91+
assert len(record) == 0
92+
93+
8694
async def test_http_parsing():
8795
message = UserMessage("lunch?")
8896

0 commit comments

Comments
 (0)