unobtanium_segmenter/augmentation/
detect_script.rs1use whatlang::detect_script;
6
7use crate::SegmentedToken;
8use crate::augmentation::Augmenter;
9
10#[derive(Debug, Clone, Default)]
12pub struct AugmentationDetectScript {}
13
14impl AugmentationDetectScript {
15 pub fn new() -> Self {
17 Default::default()
18 }
19}
20
21impl Augmenter for AugmentationDetectScript {
22 #[allow(clippy::collapsible_if)]
23 fn augment<'a>(&self, mut token: SegmentedToken<'a>) -> SegmentedToken<'a> {
24 if !token.is_known_word {
25 if let Some(script) = detect_script(token.text) {
26 token.detected_script = Some(script);
27 }
28 }
29 return token;
30 }
31}