class_docstr: Intent classifier using simple keyword matching.
  
  The classifier takes a list of keywords and associated intents as an input.
  An input sentence is checked for the keywords and the intent is returned.
class_docstr_tok: ["Intent","classifier","using","simple","keyword","matching",".","The","classifier","takes","a","list","of","keywords","and","associated","intents","as","an","input",".","An","input","sentence","is","checked","for","the","keywords","and","the","intent","is","returned","."]
docstr: Trains the intent classifier on a data set.
docstr_tok: ["Trains","the","intent","classifier","on","a","data","set","."]
code: def train(self, training_data: TrainingData) -> Resource:
      """Trains the intent classifier on a data set."""
      duplicate_examples = set()
      for ex in training_data.intent_examples:
          if (
              ex.get(TEXT) in self.intent_keyword_map.keys()
              and ex.get(INTENT)
              != self.intent_keyword_map[ex.get(TEXT)]
          ):
              duplicate_examples.add(ex.get(TEXT))
              rasa.shared.utils.io.raise_warning(
                  f"Keyword '{ex.get(TEXT)}' is a keyword to trigger intent "
                  f"'{self.intent_keyword_map[ex.get(TEXT)]}' and also "
                  f"intent '{ex.get(INTENT)}', it will be removed "
                  f"from the list of keywords for both of them. "
                  f"Remove (one of) the duplicates from the training data.",
                  docs=DOCS_URL_COMPONENTS
                  + "#keyword-intent-classifier",
              )
          else:
              self.intent_keyword_map[ex.get(TEXT)] = ex.get(INTENT)
      for keyword in duplicate_examples:
          self.intent_keyword_map.pop(keyword)
          logger.debug(
              f"Removed '{keyword}' from the list of keywords because it was "
              "a keyword for more than one intent."
          )
  
      self._validate_keyword_map()
      self.persist()
      return self._resource
  
imports: from __future__ import annotations
  import logging
  import re
  from typing import Any, Dict, Optional, Text, List
  from rasa.engine.graph import GraphComponent, ExecutionContext
  from rasa.engine.recipes.default_recipe import DefaultV1Recipe
  from rasa.engine.storage.resource import Resource
  from rasa.engine.storage.storage import ModelStorage
  from rasa.shared.constants import DOCS_URL_COMPONENTS
  from rasa.nlu.classifiers.classifier import IntentClassifier
  from rasa.shared.nlu.constants import INTENT, TEXT, INTENT_NAME_KEY, PREDICTED_CONFIDENCE_KEY
  import rasa.shared.utils.io
  from rasa.shared.nlu.training_data.training_data import TrainingData
  from rasa.shared.nlu.training_data.message import Message
label_desc: Use image node_id 4 for calling the KeywordIntentClassifier obj's underlying member method code with example usage: obj.train(training_data) and returns: self