pub struct MentionMatcher { /* private fields */ }Expand description
A gazetteer compiled for one-pass matching.
Scanning a document once per phrase is O(document × phrases), and on a large corpus the gazetteer grows into the thousands, so projection was quadratic in corpus size — the reference implementation avoids this only by having a neural tagger read each document once, which the model-free build has no equivalent for. An Aho-Corasick automaton is that equivalent: built once from every phrase, it finds all of them in a single pass over the text, independent of how many phrases there are.
The automaton is a prefilter. It finds substring occurrences; word_spans then confirms word boundaries
on the few phrases that occurred, so the result is exactly mentions.iter().filter(|m| contains_term(doc, m)) would give — a word-boundary match is necessarily a substring match — at a fraction of the cost.
Implementations§
Auto Trait Implementations§
impl Freeze for MentionMatcher
impl RefUnwindSafe for MentionMatcher
impl Send for MentionMatcher
impl Sync for MentionMatcher
impl Unpin for MentionMatcher
impl UnsafeUnpin for MentionMatcher
impl UnwindSafe for MentionMatcher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more