unobtanium_segmenter/normalization/
lowercase.rs

1// SPDX-FileCopyrightText: 2026 Slatian
2//
3// SPDX-License-Identifier: LGPL-3.0-only
4
5use crate::SegmentedToken;
6use crate::SegmentedTokenKind;
7use crate::augmentation::Augmenter;
8
9/// Will lowercase anything that can be lowercased using the rust builtin lowercasing methods.
10///
11/// This will skip the token if the token kind indicates that the token doesn't contain any letters to lowercase.
12#[derive(Debug, Clone, Default)]
13pub struct NormalizationLowercase {/* Nothing in here */}
14
15impl NormalizationLowercase {
16	/// Create a new NormalizationLowercase instance.
17	pub fn new() -> Self {
18		Default::default()
19	}
20}
21
22impl Augmenter for NormalizationLowercase {
23	fn augment<'a>(&self, mut token: SegmentedToken<'a>) -> SegmentedToken<'a> {
24		if matches!(token.kind, Some(SegmentedTokenKind::AlphaNumeric) | None) {
25			token.update_normalized_string(token.get_text_prefer_normalized().to_lowercase(), None);
26		}
27		return token;
28	}
29}