Checks if there is no duplicated example in different intents.
(
self, ignore_warnings: bool = True
)
| 96 | return everything_is_alright |
| 97 | |
| 98 | def verify_example_repetition_in_intents( |
| 99 | self, ignore_warnings: bool = True |
| 100 | ) -> bool: |
| 101 | """Checks if there is no duplicated example in different intents.""" |
| 102 | |
| 103 | everything_is_alright = True |
| 104 | |
| 105 | duplication_hash = defaultdict(set) |
| 106 | for example in self.intents.intent_examples: |
| 107 | text = example.get(rasa.shared.nlu.constants.TEXT) |
| 108 | duplication_hash[text].add(example.get("intent")) |
| 109 | |
| 110 | for text, intents in duplication_hash.items(): |
| 111 | |
| 112 | if len(duplication_hash[text]) > 1: |
| 113 | everything_is_alright = ignore_warnings |
| 114 | intents_string = ", ".join(sorted(intents)) |
| 115 | rasa.shared.utils.io.raise_warning( |
| 116 | f"The example '{text}' was found labeled with multiple " |
| 117 | f"different intents in the training data. Each annotated message " |
| 118 | f"should only appear with one intent. You should fix that " |
| 119 | f"conflict The example is labeled with: {intents_string}." |
| 120 | ) |
| 121 | return everything_is_alright |
| 122 | |
| 123 | def verify_intents_in_stories(self, ignore_warnings: bool = True) -> bool: |
| 124 | """Checks intents used in stories. |