def f(self, m: TemporaryContext) -> bool: if not isinstance(m, TemporarySpanMention): raise ValueError( f"{self.__class__.__name__} only supports TemporarySpanMention" ) if len(self.children) != 2: raise ValueError("Concat takes two child Matcher objects as arguments.") if not self.left_required and self.children[1].f(m): return True if not self.right_required and self.children[0].f(m): return True # Iterate over mention splits **at the word boundaries** for wsplit in range(m.get_word_start_index() + 1, m.get_word_end_index() + 1): csplit = ( m._word_to_char_index(wsplit) - m.char_start ) # NOTE the switch to **mention-relative** char index # Optionally check for specific separator if self.ignore_sep or m.get_span()[csplit - 1] == self.sep: m1 = m[: csplit - len(self.sep)] m2 = m[csplit:] if self.children[0].f(m1) and self.children[1].f(m2): return True if ( self.permutations and self.children[1].f(m1) and self.children[0].f(m2) ): return True return False
def _f(self, m: TemporaryContext) -> bool: if not isinstance(m, TemporarySpanMention): raise ValueError( f"{self.__class__.__name__} only supports TemporarySpanMention" ) if self.search: return (True if self.r.search( m.get_attrib_span(self.attrib, sep=self.sep)) is not None else False) else: return (True if self.r.match( m.get_attrib_span(self.attrib, sep=self.sep)) is not None else False)
def _f(self, m: TemporaryContext) -> bool: if not isinstance(m, TemporarySpanMention): raise ValueError( f"{self.__class__.__name__} only supports TemporarySpanMention" ) p = m.get_attrib_span(self.attrib) p = p.lower() if self.ignore_case else p p = self._stem(p) if self.stemmer is not None else p return (not self.inverse) if p in self.d else self.inverse
def _f(self, m: TemporaryContext) -> bool: if not isinstance(m, TemporarySpanMention): raise ValueError( f"{self.__class__.__name__} only supports TemporarySpanMention" ) tokens = m.get_attrib_tokens(self.attrib) return (True if tokens and all([self.r.match(t) is not None for t in tokens]) else False)