use prosaic_core::{
ConnectivePreferences, HedgingCalibration, LengthDistribution, ListStyleBias, PronounDensity,
RstRelation, SalienceBias, StyleProfile, Verbosity,
};
pub fn neutral() -> StyleProfile {
StyleProfile::neutral()
}
pub fn concise_professional() -> StyleProfile {
let mut connectives = ConnectivePreferences::neutral();
connectives.allowed.insert(
RstRelation::Elaboration,
vec!["Furthermore,".to_string(), "Additionally,".to_string()],
);
connectives
.allowed
.insert(RstRelation::Contrast, vec!["However,".to_string()]);
StyleProfile::builder("concise-professional")
.verbosity(Verbosity::Terse)
.list_style_bias(ListStyleBias::Bracketed)
.pronoun_density(PronounDensity::Low)
.salience(SalienceBias::Auto)
.hedging(HedgingCalibration {
offset: 5,
forbid: Vec::new(),
})
.sentence_length(LengthDistribution {
short: 0.5,
medium: 0.4,
long: 0.1,
short_max_words: 8,
medium_max_words: 18,
})
.connectives(connectives)
.build()
.expect("concise-professional must validate")
}
pub fn verbose_narrative() -> StyleProfile {
StyleProfile::builder("verbose-narrative")
.verbosity(Verbosity::Verbose)
.list_style_bias(ListStyleBias::Including)
.pronoun_density(PronounDensity::High)
.salience(SalienceBias::Auto)
.hedging(HedgingCalibration {
offset: -5,
forbid: Vec::new(),
})
.sentence_length(LengthDistribution {
short: 0.2,
medium: 0.5,
long: 0.3,
short_max_words: 8,
medium_max_words: 18,
})
.build()
.expect("verbose-narrative must validate")
}
pub fn regulatory_formal() -> StyleProfile {
StyleProfile::builder("regulatory-formal")
.verbosity(Verbosity::Verbose)
.list_style_bias(ListStyleBias::Bracketed)
.pronoun_density(PronounDensity::Low)
.salience(SalienceBias::Auto)
.hedging(HedgingCalibration {
offset: -10,
forbid: vec!["certainly".to_string(), "must".to_string()],
})
.sentence_length(LengthDistribution {
short: 0.1,
medium: 0.5,
long: 0.4,
short_max_words: 8,
medium_max_words: 18,
})
.build()
.expect("regulatory-formal must validate")
}
pub fn all() -> Vec<StyleProfile> {
vec![
neutral(),
concise_professional(),
verbose_narrative(),
regulatory_formal(),
]
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn neutral_catalog_entry_is_neutral() {
assert!(neutral().is_neutral());
}
#[test]
fn concise_professional_validates() {
let p = concise_professional();
p.validate().unwrap();
assert_eq!(p.name, "concise-professional");
assert_eq!(p.verbosity, Verbosity::Terse);
assert!(!p.is_neutral());
}
#[test]
fn verbose_narrative_validates() {
let p = verbose_narrative();
p.validate().unwrap();
assert_eq!(p.name, "verbose-narrative");
assert_eq!(p.verbosity, Verbosity::Verbose);
assert!(!p.is_neutral());
}
#[test]
fn regulatory_formal_validates() {
let p = regulatory_formal();
p.validate().unwrap();
assert_eq!(p.name, "regulatory-formal");
assert!(!p.hedging.forbid.is_empty());
assert!(!p.is_neutral());
}
#[test]
fn all_returns_four_profiles_with_distinct_names() {
let profiles = all();
assert_eq!(profiles.len(), 4);
let mut names: Vec<&str> = profiles.iter().map(|p| p.name.as_str()).collect();
names.sort();
assert_eq!(
names,
vec![
"concise-professional",
"neutral",
"regulatory-formal",
"verbose-narrative",
]
);
}
}