code: def tag(self, text):
          if self.search_method == 'ahocorasick':
              events = self._find_keywords_ahocorasick(text.text)
          elif self.search_method == 'naive':
              events = self._find_keywords_naive(text.text)
          events = self._resolve_conflicts(events)
          if self.mapping:
              for item in events:
                  item['type'] = self.map[
                      text.text[item['start']:item['end']]
                  ]
          if self.return_layer:
              return events
          else:
              text[self.layer_name] = events