-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: hunspell dictionary builder now emits added word metadata
- Loading branch information
1 parent
67a021f
commit b4f7c34
Showing
11 changed files
with
149 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,40 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::{matcher::Matcher, Error}; | ||
use super::matcher::Matcher; | ||
use super::Error; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct AffixReplacement { | ||
pub remove: Vec<char>, | ||
pub add: Vec<char>, | ||
pub condition: Matcher, | ||
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(), | ||
condition: self.condition.to_string() | ||
} | ||
} | ||
} | ||
|
||
/// A version of [`AffixReplacement`] that can be serialized to JSON (or whatever) and maintain the | ||
/// nice Regex syntax of the inner [`Matcher`]. | ||
/// A version of [`AffixReplacement`] that can be serialized to JSON (or | ||
/// whatever) and maintain the nice Regex syntax of the inner [`Matcher`]. | ||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
pub struct HumanReadableAffixReplacement { | ||
pub remove: String, | ||
pub add: String, | ||
pub condition: 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)?, | ||
condition: Matcher::parse(&self.condition)? | ||
}) | ||
} | ||
} |
Oops, something went wrong.