def apply(self, mentions):
seen_spans = set()<EOL>for m in mentions:<EOL><INDENT>if self.f(m) and (<EOL>not self.longest_match_only<EOL>or not any([self._is_subspan(m, s) for s in seen_spans])<EOL>):<EOL><INDENT>if self.longest_match_only:<EOL><INDENT>seen_spans.add(self._get_span(m))<EOL><DEDENT>yield m<EOL><DEDENT><DEDENT>
Apply the Matcher to a **generator** of mentions.
Optionally only takes the longest match (NOTE: assumes this is the
*first* match)