Skip to content

Commit

Permalink
raise exception if intent name contains a slash
Browse files Browse the repository at this point in the history
  • Loading branch information
m-vdb committed Jul 21, 2020
1 parent 2e2f190 commit 9f105d6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions rasa/nlu/training_data/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import scipy.sparse
import typing

from rasa.exceptions import RasaException
from rasa.nlu.constants import (
ENTITIES,
INTENT,
Expand Down Expand Up @@ -126,14 +127,17 @@ def get_combined_intent_response_key(self) -> Text:
@staticmethod
def separate_intent_response_key(
original_intent: Text,
) -> Tuple[Optional[Text], Optional[Text]]:
) -> Tuple[Text, Optional[Text]]:

split_title = original_intent.split(RESPONSE_IDENTIFIER_DELIMITER)
if len(split_title) == 2:
return split_title[0], split_title[1]
elif len(split_title) == 1:
return split_title[0], None
return None, None

raise RasaException(
f"Intent name is invalid, it should not contain '{RESPONSE_IDENTIFIER_DELIMITER}'."
)

def get_sparse_features(
self, attribute: Text, featurizers: Optional[List[Text]] = None
Expand Down

0 comments on commit 9f105d6

Please sign in to comment.