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

Update validator.py warnings #4795

Merged
merged 14 commits into from
Dec 3, 2019
29 changes: 18 additions & 11 deletions rasa/core/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,18 @@ def verify_intents(self, ignore_warnings: bool = True) -> bool:

for intent in self.domain.intents:
if intent not in nlu_data_intents:
warnings.warn(
logger.debug(
f"The intent '{intent}' is listed in the domain file, but "
"is not found in the NLU training data."
f"is not found in the NLU training data.",
)
everything_is_alright = ignore_warnings and everything_is_alright

for intent in nlu_data_intents:
if intent not in self.domain.intents:
warnings.warn(
f"The intent '{intent}' is in the NLU training data, but "
f"is not listed in the domain."
f"is not listed in the domain.",
stacklevel=2,
)
everything_is_alright = False

Expand All @@ -77,7 +78,9 @@ def verify_example_repetition_in_intents(
everything_is_alright = ignore_warnings and everything_is_alright
intents_string = ", ".join(sorted(intents))
warnings.warn(
f"The example '{text}' was found in these multiples intents: {intents_string }"
f"The example '{text}' was found in these multiples intents: "
imLew marked this conversation as resolved.
Show resolved Hide resolved
f"{intents_string}.",
stacklevel=2,
)
return everything_is_alright

Expand All @@ -100,13 +103,14 @@ def verify_intents_in_stories(self, ignore_warnings: bool = True) -> bool:
if story_intent not in self.domain.intents:
warnings.warn(
f"The intent '{story_intent}' is used in stories, but is not "
f"listed in the domain file."
f"listed in the domain file.",
stacklevel=2,
)
everything_is_alright = False

for intent in self.domain.intents:
if intent not in stories_intents:
warnings.warn(f"The intent '{intent}' is not used in any story.")
logger.debug(f"The intent '{intent}' is not used in any story.")
everything_is_alright = ignore_warnings and everything_is_alright

return everything_is_alright
Expand All @@ -128,16 +132,18 @@ def verify_utterances(self, ignore_warnings: bool = True) -> bool:

for utterance in utterance_templates:
if utterance not in actions:
warnings.warn(
logger.debug(
f"The utterance '{utterance}' is not listed under 'actions' in the "
"domain file. It can only be used as a template."
f"domain file. It can only be used as a template.",
)
everything_is_alright = ignore_warnings and everything_is_alright

for action in actions:
if action.startswith(UTTER_PREFIX):
if action not in utterance_templates:
warnings.warn(f"There is no template for utterance '{action}'.")
warnings.warn(
f"There is no template for utterance '{action}'.", stacklevel=2
)
everything_is_alright = False

return everything_is_alright
Expand Down Expand Up @@ -168,14 +174,15 @@ def verify_utterances_in_stories(self, ignore_warnings: bool = True) -> bool:
if event.action_name not in utterance_actions:
warnings.warn(
f"The utterance '{event.action_name}' is used in stories, but is not a "
f"valid utterance."
f"valid utterance.",
stacklevel=2,
)
everything_is_alright = False
stories_utterances.add(event.action_name)

for utterance in utterance_actions:
if utterance not in stories_utterances:
warnings.warn(f"The utterance '{utterance}' is not used in any story.")
logger.debug(f"The utterance '{utterance}' is not used in any story.")
everything_is_alright = ignore_warnings and everything_is_alright

return everything_is_alright
Expand Down