pub struct MentionContext {Show 13 fields
pub entity: Entity,
pub left_context: String,
pub right_context: String,
pub relative_position: f64,
pub absolute_position: usize,
pub sentence_index: Option<usize>,
pub likely_subject: bool,
pub likely_heading: bool,
pub word_count: usize,
pub char_count: usize,
pub is_capitalized: bool,
pub is_all_caps: bool,
pub contains_digits: bool,
}Expand description
Context and features for a single entity mention.
Fields§
§entity: EntityThe entity mention itself.
left_context: StringText before the mention (up to context_window chars).
right_context: StringText after the mention (up to context_window chars).
relative_position: f64Position as fraction of document (0.0 = start, 1.0 = end).
absolute_position: usizeCharacter offset from document start.
sentence_index: Option<usize>Sentence index (if sentence boundaries detected).
likely_subject: boolIs this likely in subject position? (heuristic: near sentence start).
likely_heading: boolIs this in a heading or title? (heuristic: short line, capitalized).
word_count: usizeWord count of the mention.
char_count: usizeCharacter count of the mention.
is_capitalized: boolDoes the mention start with a capital letter?
is_all_caps: boolIs this mention all uppercase?
contains_digits: boolContains digits?
Implementations§
Source§impl MentionContext
impl MentionContext
Sourcepub fn extract(
text: &str,
entity: &Entity,
config: &ExtractorConfig,
) -> MentionContext
pub fn extract( text: &str, entity: &Entity, config: &ExtractorConfig, ) -> MentionContext
Extract mention context from text and entity.
Sourcepub fn full_context(&self) -> String
pub fn full_context(&self) -> String
Get the full context string (left + entity + right).
Trait Implementations§
Source§impl Clone for MentionContext
impl Clone for MentionContext
Source§fn clone(&self) -> MentionContext
fn clone(&self) -> MentionContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MentionContext
impl RefUnwindSafe for MentionContext
impl Send for MentionContext
impl Sync for MentionContext
impl Unpin for MentionContext
impl UnsafeUnpin for MentionContext
impl UnwindSafe for MentionContext
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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