nodes: 0, module; 1, function_definition; 2, function_name:tag; 3, parameters; 4, block; 5, identifier:self; 6, identifier:text; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, if_statement; 11, if_statement; 12, comment:"""Retrieves list of keywords in text.
  
          Parameters
          ----------
          text: Text
              The text to search for events.
  
          Returns
          -------
          list of vents sorted by start, end
          """; 13, comparison_operator:self.search_method == 'ahocorasick'; 14, block; 15, elif_clause; 16, assignment; 17, attribute; 18, block; 19, attribute; 20, block; 21, else_clause; 22, attribute; 23, string; 24, expression_statement; 25, comparison_operator:self.search_method == 'naive'; 26, block; 27, identifier:events; 28, call; 29, identifier:self; 30, identifier:mapping; 31, for_statement; 32, identifier:self; 33, identifier:return_layer; 34, return_statement; 35, block; 36, identifier:self; 37, identifier:search_method; 38, string_content:ahocorasick; 39, assignment; 40, attribute; 41, string; 42, expression_statement; 43, attribute; 44, argument_list; 45, identifier:item; 46, identifier:events; 47, block; 48, identifier:events; 49, expression_statement; 50, identifier:events; 51, call; 52, identifier:self; 53, identifier:search_method; 54, string_content:naive; 55, assignment; 56, identifier:self; 57, identifier:_resolve_conflicts; 58, identifier:events; 59, expression_statement; 60, assignment; 61, attribute; 62, argument_list; 63, identifier:events; 64, call; 65, assignment; 66, subscript; 67, identifier:events; 68, identifier:self; 69, identifier:_find_keywords_ahocorasick; 70, attribute; 71, attribute; 72, argument_list; 73, subscript; 74, subscript; 75, identifier:text; 76, attribute; 77, identifier:text; 78, identifier:text; 79, identifier:self; 80, identifier:_find_keywords_naive; 81, attribute; 82, identifier:item; 83, string; 84, attribute; 85, subscript; 86, identifier:self; 87, identifier:layer_name; 88, identifier:text; 89, identifier:text; 90, string_content:type; 91, identifier:self; 92, identifier:map; 93, attribute; 94, slice; 95, identifier:text; 96, identifier:text; 97, subscript; 98, subscript; 99, identifier:item; 100, string; 101, identifier:item; 102, string; 103, string_content:start; 104, string_content:end
code: def tag(self, text):
          """Retrieves list of keywords in text.
  
          Parameters
          ----------
          text: Text
              The text to search for events.
  
          Returns
          -------
          list of vents sorted by start, end
          """
          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