use serde::{Deserialize, Serialize};
use super::Error;
use super::matcher::Matcher;
#[derive(Debug, Clone)]
pub struct AffixReplacement {
pub remove: Vec<char>,
pub add: Vec<char>,
pub condition: Matcher,
}
impl AffixReplacement {
pub fn to_human_readable(&self) -> HumanReadableAffixReplacement {
HumanReadableAffixReplacement {
remove: self.remove.iter().collect(),
add: self.add.iter().collect(),
condition: self.condition.to_string(),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HumanReadableAffixReplacement {
pub remove: String,
pub add: String,
pub condition: String,
}
impl HumanReadableAffixReplacement {
pub fn to_normal(&self) -> Result<AffixReplacement, Error> {
Ok(AffixReplacement {
remove: self.remove.chars().collect(),
add: self.add.chars().collect(),
condition: Matcher::parse(&self.condition)?,
})
}
}