pub struct PhiFeatures {
pub person: Person,
pub number: Number,
pub gender: Gender,
}Expand description
A bundle of phi-features (person, number, gender) for morphological agreement.
This struct packages the three core phi-features into a single unit that can be attached to mentions (especially zero mentions) and used for coreference constraint checking.
§Use Cases
-
Zero pronoun representation: When Arabic “ذهب” (dhahaba, “he went”) drops its subject, we create a zero mention with
PhiFeatures::third_sg_masc(). -
Coreference filtering: Two mentions can only corefer if their phi-features are compatible. “John… she” fails the gender check.
-
Factor graph constraints: In joint entity models, phi-feature compatibility can be a soft factor between mention pairs.
§Example: Arabic Zero Pronoun Resolution
use anno_core::types::{PhiFeatures, Person, Number, Gender};
// Arabic verb "كَتَبَتْ" (katabat) = "[she] wrote"
// The -at suffix encodes: 3rd person, singular, feminine
let verb_features = PhiFeatures::new(
Person::Third,
Number::Singular,
Gender::Feminine
);
// Candidate antecedent: "مريم" (Maryam, a feminine name)
let maryam_features = PhiFeatures::new(
Person::Third,
Number::Singular,
Gender::Feminine
);
// Candidate antecedent: "أحمد" (Ahmad, a masculine name)
let ahmad_features = PhiFeatures::third_sg_masc();
// Maryam is compatible (same features), Ahmad is not (gender mismatch)
assert!(verb_features.is_compatible(&maryam_features));
assert!(!verb_features.is_compatible(&ahmad_features));§Parsing from Strings
Phi-features can be parsed from compact notation:
use anno_core::types::PhiFeatures;
let phi = PhiFeatures::parse("3sgm").unwrap(); // 3rd singular masculine
let phi = PhiFeatures::parse("1plf").unwrap(); // 1st plural feminine
let phi = PhiFeatures::parse("2du").unwrap(); // 2nd dual (gender unspecified)Fields§
§person: PersonGrammatical person (1st/2nd/3rd)
Indicates the discourse role: speaker, listener, or other.
number: NumberGrammatical number (singular/dual/plural)
Indicates quantity. Languages like Arabic distinguish dual from plural.
gender: GenderGrammatical gender (masculine/feminine/neutral)
In languages like Arabic, gender is grammatically assigned to all nouns, not just animate entities.
Implementations§
Source§impl PhiFeatures
impl PhiFeatures
Sourcepub fn third_sg_masc() -> PhiFeatures
pub fn third_sg_masc() -> PhiFeatures
Create 3rd person singular masculine.
This is the most common phi-feature combination for zero pronouns in Arabic narrative text, where the default subject is often a previously mentioned male character.
§Example
use anno_core::types::PhiFeatures;
// Arabic "ذَهَبَ" (dhahaba) = "[he] went"
let phi = PhiFeatures::third_sg_masc();Sourcepub fn third_sg_fem() -> PhiFeatures
pub fn third_sg_fem() -> PhiFeatures
Sourcepub fn third_plural() -> PhiFeatures
pub fn third_plural() -> PhiFeatures
Create 3rd person plural with neutral/unspecified gender.
In Arabic, plural verbs can use masculine or feminine forms depending on the referent. This constructor uses neutral for cases where gender is not recoverable from morphology.
§Example
use anno_core::types::PhiFeatures;
// Spanish "Vinieron" = "[They] came" - plural, gender unspecified
let phi = PhiFeatures::third_plural();Sourcepub fn is_compatible(&self, other: &PhiFeatures) -> bool
pub fn is_compatible(&self, other: &PhiFeatures) -> bool
Check if these phi-features are compatible with another set.
Compatibility is checked per-feature:
- Person must match exactly
- Number allows dual↔plural (since pairs can be referred to as plural)
- Gender uses the rules from
Gender::is_compatible
This is a soft constraint for coreference: incompatible phi-features make coreference unlikely but not impossible (errors, metaphor, etc.).
§Example
use anno_core::types::PhiFeatures;
let he = PhiFeatures::third_sg_masc();
let she = PhiFeatures::third_sg_fem();
let they = PhiFeatures::third_plural();
assert!(!he.is_compatible(&she)); // Gender mismatch
assert!(!he.is_compatible(&they)); // Number mismatchSourcepub fn parse(s: &str) -> Option<PhiFeatures>
pub fn parse(s: &str) -> Option<PhiFeatures>
Parse phi-features from a compact string notation.
Accepts formats like:
"3sgm"- 3rd singular masculine"1plf"- 1st plural feminine"2du"- 2nd dual (gender unspecified)
Returns None if the string cannot be parsed.
§Example
use anno_core::types::{PhiFeatures, Person, Number, Gender};
let phi = PhiFeatures::parse("3sgm").unwrap();
assert_eq!(phi.person, Person::Third);
assert_eq!(phi.number, Number::Singular);
assert_eq!(phi.gender, Gender::Masculine);Trait Implementations§
Source§impl Clone for PhiFeatures
impl Clone for PhiFeatures
Source§fn clone(&self) -> PhiFeatures
fn clone(&self) -> PhiFeatures
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PhiFeatures
impl Debug for PhiFeatures
Source§impl Default for PhiFeatures
impl Default for PhiFeatures
Source§fn default() -> PhiFeatures
fn default() -> PhiFeatures
Source§impl<'de> Deserialize<'de> for PhiFeatures
impl<'de> Deserialize<'de> for PhiFeatures
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PhiFeatures, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PhiFeatures, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for PhiFeatures
impl Display for PhiFeatures
Source§impl Hash for PhiFeatures
impl Hash for PhiFeatures
Source§impl PartialEq for PhiFeatures
impl PartialEq for PhiFeatures
Source§impl Serialize for PhiFeatures
impl Serialize for PhiFeatures
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for PhiFeatures
impl Eq for PhiFeatures
impl StructuralPartialEq for PhiFeatures
Auto Trait Implementations§
impl Freeze for PhiFeatures
impl RefUnwindSafe for PhiFeatures
impl Send for PhiFeatures
impl Sync for PhiFeatures
impl Unpin for PhiFeatures
impl UnsafeUnpin for PhiFeatures
impl UnwindSafe for PhiFeatures
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read moreSource§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.