1#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
5pub enum Operator {
6 #[default]
8 Tn,
9 Itn,
11}
12
13#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
15pub enum Language {
16 #[default]
18 Auto,
19 En,
21 Zh,
23 Ja,
25}
26
27#[derive(Debug, Clone, Default)]
29pub struct NormalizerConfig {
30 pub lang: Language,
32
33 pub operator: Operator,
35
36 pub fix_contractions: bool,
38
39 pub traditional_to_simple: bool,
41
42 pub full_to_half: bool,
44
45 pub remove_interjections: bool,
47
48 pub remove_puncts: bool,
50
51 pub tag_oov: bool,
53
54 pub enable_0_to_9: bool,
56
57 pub remove_erhua: bool,
59}
60
61impl NormalizerConfig {
62 pub fn new() -> Self {
64 Self::default()
65 }
66
67 pub fn with_lang(mut self, lang: Language) -> Self {
69 self.lang = lang;
70 self
71 }
72
73 pub fn with_operator(mut self, operator: Operator) -> Self {
75 self.operator = operator;
76 self
77 }
78
79 pub fn with_fix_contractions(mut self, fix: bool) -> Self {
81 self.fix_contractions = fix;
82 self
83 }
84
85 pub fn with_traditional_to_simple(mut self, convert: bool) -> Self {
87 self.traditional_to_simple = convert;
88 self
89 }
90
91 pub fn with_full_to_half(mut self, convert: bool) -> Self {
93 self.full_to_half = convert;
94 self
95 }
96
97 pub fn with_remove_interjections(mut self, remove: bool) -> Self {
99 self.remove_interjections = remove;
100 self
101 }
102
103 pub fn with_remove_puncts(mut self, remove: bool) -> Self {
105 self.remove_puncts = remove;
106 self
107 }
108
109 pub fn with_remove_erhua(mut self, remove: bool) -> Self {
111 self.remove_erhua = remove;
112 self
113 }
114
115 pub fn with_tag_oov(mut self, tag: bool) -> Self {
117 self.tag_oov = tag;
118 self
119 }
120
121 pub fn with_enable_0_to_9(mut self, enable: bool) -> Self {
123 self.enable_0_to_9 = enable;
124 self
125 }
126}