pub struct CorefNerFactor {
pub mention_i: usize,
pub mention_j: usize,
pub weights: CorefNerWeights,
pub head_i: Option<String>,
pub head_j: Option<String>,
pub monolexical_weights: HashMap<(String, String), f64>,
/* private fields */
}Expand description
Factor coupling coreference and NER.
Encourages consistent semantic types across coreference chains. Only fires when mention i is linked to mention j (a_i = j).
§Features
- Type pair: (t_i, t_j) indicator features
- Monolexical: (t_i, head_j) and (t_j, head_i) features
§Example
If “he” → “John Smith” is a coref link:
- t(“John Smith”) = PERSON
- t(“he”) = PERSON
- Factor score high for matching types
Fields§
§mention_i: usizeCurrent mention index (i)
mention_j: usizeAntecedent mention index (j)
weights: CorefNerWeightsWeights
head_i: Option<String>Head word of mention i for monolexical features.
head_j: Option<String>Head word of mention j for monolexical features.
monolexical_weights: HashMap<(String, String), f64>Monolexical feature lookup: (type, head) → weight
Implementations§
Source§impl CorefNerFactor
impl CorefNerFactor
Sourcepub fn new(mention_i: usize, mention_j: usize, weights: CorefNerWeights) -> Self
pub fn new(mention_i: usize, mention_j: usize, weights: CorefNerWeights) -> Self
Create a new Coref+NER factor.
Sourcepub fn with_heads(self, head_i: &str, head_j: &str) -> Self
pub fn with_heads(self, head_i: &str, head_j: &str) -> Self
Set head words for monolexical features.
Sourcepub fn add_monolexical_weight(
&mut self,
type_name: &str,
head: &str,
weight: f64,
)
pub fn add_monolexical_weight( &mut self, type_name: &str, head: &str, weight: f64, )
Add monolexical weight.
Sourcepub fn with_default_monolexical(self) -> Self
pub fn with_default_monolexical(self) -> Self
Load default monolexical weights (common patterns).
Trait Implementations§
Source§impl Clone for CorefNerFactor
impl Clone for CorefNerFactor
Source§fn clone(&self) -> CorefNerFactor
fn clone(&self) -> CorefNerFactor
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 moreSource§impl Debug for CorefNerFactor
impl Debug for CorefNerFactor
Source§impl Factor for CorefNerFactor
impl Factor for CorefNerFactor
Source§fn scope(&self) -> &[VariableId]
fn scope(&self) -> &[VariableId]
The variables this factor touches (its “scope”). Read more
Source§fn log_potential(&self, assignment: &Assignment) -> f64
fn log_potential(&self, assignment: &Assignment) -> f64
Log potential (unnormalized log probability) for an assignment. Read more
Auto Trait Implementations§
impl Freeze for CorefNerFactor
impl RefUnwindSafe for CorefNerFactor
impl Send for CorefNerFactor
impl Sync for CorefNerFactor
impl Unpin for CorefNerFactor
impl UnsafeUnpin for CorefNerFactor
impl UnwindSafe for CorefNerFactor
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