Skip to main content

Confidence

Enum Confidence 

Source
#[non_exhaustive]
pub enum Confidence { Exact, Probable, Weak, }
Expand description

How much of the query a candidate actually matched, as something an agent can branch on (#536).

score alone is not judgement material. For it to work as a gate, the consumer has to already know that the scorer is token overlap rather than semantic similarity, that 0.5 is the FLOOR so the worst candidate the tool will ever emit still looks like a positive number, and that for a citation string carrying author + title + journal + volume + year, 0.5 means most of it did not match. None of that is in the envelope, and an agent consuming a ranked list takes the head of it.

The reported case: a citation for a paper in Psychiatria Danubina came back as a different 2010 paper in a different journal by a different author at score: 0.5quality, life, bipolar and 2010 were enough to clear the floor — in the same shape as a score: 1.0 identity.

§These are bands over token overlap, not a semantic verdict

Self::Exact means every token in the query was found somewhere in the candidate record. That is a strong signal and it is still not proof: a short query can match the wrong paper completely. The bands make the difference between “identity” and “coincidence” legible; they do not remove the need to verify before citing.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Exact

Every query token matched. Verify before citing, but this is an identity rather than an overlap.

§

Probable

At least four query tokens in five matched.

§

Weak

Cleared the 0.5 floor and no more. For a known-item lookup this is a NEGATIVE result wearing a positive number.

Implementations§

Source§

impl Confidence

Source

pub fn from_score(score: f64) -> Self

Band a token-overlap score.

The floor is 0.5 (MIN_CITATION_SCORE), so the range actually in play is 0.5..=1.0 and the split at 0.8 asks for four tokens in five. Exact compares against 0.999 rather than 1.0 because the score is a division: asking for bit-exact equality would band an all-tokens match as Probable on a rounding accident. A score outside 0.0..=1.0, or NaN, is not a token-overlap ratio and gets the lowest band rather than a confident-looking answer. The only caller today guards with MIN_CITATION_SCORE, but that constant is private to crossref.rs and invisible from this signature – and this is a public function on a semver-strict crate.

Source

pub const fn as_wire(self) -> &'static str

The wire token, allocation-free.

Trait Implementations§

Source§

impl Clone for Confidence

Source§

fn clone(&self) -> Confidence

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Confidence

Source§

impl Debug for Confidence

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Confidence

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Confidence

Source§

impl PartialEq for Confidence

Source§

fn eq(&self, other: &Confidence) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Confidence

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Confidence

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more