use gukhanmun_core::{
ContextWindow, EngineOptions, HomophoneDetection, NumeralStrategy, Recovery, RenderOptions,
SegmentationStrategy,
};
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub enum Preset {
#[default]
KoKr,
KoKp,
}
impl Preset {
pub fn options(self) -> ConversionOptions {
match self {
Preset::KoKr => ConversionOptions {
rendering: RenderOptions::default(),
engine: EngineOptions {
segmentation: SegmentationStrategy::default(),
initial_sound_law: true,
numeral_strategy: NumeralStrategy::HangulPhonetic,
},
homophone_window: ContextWindow::PerBlock,
homophone_detection: HomophoneDetection::ContextLocal,
first_occurrence_window: ContextWindow::Off,
collapse_redundant_parens: true,
recovery: Recovery::Strict,
},
Preset::KoKp => ConversionOptions {
rendering: RenderOptions::default(),
engine: EngineOptions {
segmentation: SegmentationStrategy::default(),
initial_sound_law: false,
numeral_strategy: NumeralStrategy::HangulPhonetic,
},
homophone_window: ContextWindow::Off,
homophone_detection: HomophoneDetection::ContextLocal,
first_occurrence_window: ContextWindow::Off,
collapse_redundant_parens: true,
recovery: Recovery::Strict,
},
}
}
pub fn includes_bundled_stdict(self) -> bool {
matches!(self, Preset::KoKr)
}
pub fn includes_bundled_opendict_north_korean(self) -> bool {
matches!(self, Preset::KoKp)
}
}
#[non_exhaustive]
#[derive(Clone, Copy, Debug)]
pub struct ConversionOptions {
pub rendering: RenderOptions,
pub engine: EngineOptions,
pub homophone_window: ContextWindow,
pub homophone_detection: HomophoneDetection,
pub first_occurrence_window: ContextWindow,
pub collapse_redundant_parens: bool,
pub recovery: Recovery,
}
impl Default for ConversionOptions {
fn default() -> Self {
Preset::default().options()
}
}