def matches(self, sentence: str): if self._include_matchers is None or self._exclude_matchers is None: self.compile_regexps() if not sentence: return False sentence = sentence.replace('\n', ' ').replace('\t', ' ') if self.regexps_pre_process_lower: sentence = sentence.lower() if self.regexps_pre_process_remove_numeric_separators: sentence = remove_num_separators(sentence) if self._matches_exclude_regexp(sentence): return False if self._definition_words: if not self._matches_definition_words(sentence): return False return not self._include_matchers or self._matches_include_regexp( sentence) else: return self._matches_include_regexp(sentence)
def matches(self, sentence: str): if self._include_matchers is None or self._exclude_matchers is None: self.compile_regexps() if not sentence: return False if self.regexps_pre_process_lower: sentence = sentence.lower() if self.regexps_pre_process_remove_numeric_separators: sentence = remove_num_separators(sentence) if self._exclude_matchers: for matcher_re in self._exclude_matchers: for m in matcher_re.findall(sentence): return False if self._include_matchers: for matcher_re in self._include_matchers: for m in matcher_re.findall(sentence): return True