use crate::features::Domain;
use serde::{Deserialize, Serialize};
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ClaimPolarity {
Positive,
Negative,
MixedPositive,
MixedNegative,
Neutral,
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct SourceMetadata {
rule_set: String,
source_id: String,
}
impl SourceMetadata {
pub fn new(rule_set: impl Into<String>, source_id: impl Into<String>) -> Self {
Self {
rule_set: rule_set.into(),
source_id: source_id.into(),
}
}
pub fn rule_set(&self) -> &str {
&self.rule_set
}
pub fn source_id(&self) -> &str {
&self.source_id
}
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct Evidence {
fact_key: String,
summary: String,
}
impl Evidence {
pub fn new(fact_key: impl Into<String>, summary: impl Into<String>) -> Self {
Self {
fact_key: fact_key.into(),
summary: summary.into(),
}
}
pub fn fact_key(&self) -> &str {
&self.fact_key
}
pub fn summary(&self) -> &str {
&self.summary
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Claim {
domain: Domain,
themes: Vec<String>,
polarity: ClaimPolarity,
strength: f32,
evidence: Vec<Evidence>,
counter_evidence: Vec<Evidence>,
source: SourceMetadata,
}
impl Claim {
pub fn new(
domain: Domain,
themes: Vec<String>,
polarity: ClaimPolarity,
strength: f32,
evidence: Vec<Evidence>,
counter_evidence: Vec<Evidence>,
source: SourceMetadata,
) -> Self {
Self {
domain,
themes,
polarity,
strength,
evidence,
counter_evidence,
source,
}
}
pub const fn domain(&self) -> Domain {
self.domain
}
pub fn themes(&self) -> &[String] {
&self.themes
}
pub const fn polarity(&self) -> ClaimPolarity {
self.polarity
}
pub const fn strength(&self) -> f32 {
self.strength
}
pub fn evidence(&self) -> &[Evidence] {
&self.evidence
}
pub fn counter_evidence(&self) -> &[Evidence] {
&self.counter_evidence
}
pub const fn source(&self) -> &SourceMetadata {
&self.source
}
}