style: cargo fmt --workspace (whitespace/wrapping only, no semantic change)

Whole-workspace rustfmt pass picked up while iterating on Mamba GPU
backward work. Verified formatting-only via diff sampling; no logic
changed.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
osobh
2026-08-10 07:09:36 -07:00
co-authored by Claude Sonnet 5
parent ad6405663f
commit 4aaa36a57a
305 changed files with 25537 additions and 18337 deletions
+65 -23
View File
@@ -76,9 +76,26 @@ impl TextNormalizer {
abbreviation_map.insert("e.g.".to_string(), "for example".to_string());
let number_words = vec![
"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen",
"seventeen", "eighteen", "nineteen",
"zero",
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
"ten",
"eleven",
"twelve",
"thirteen",
"fourteen",
"fifteen",
"sixteen",
"seventeen",
"eighteen",
"nineteen",
];
let tens_words = vec![
@@ -164,14 +181,16 @@ impl TextNormalizer {
};
// Preserve the trailing space if it exists
result = re.replace_all(&result, |caps: &regex::Captures| {
let matched = &caps[0];
if matched.ends_with(' ') {
format!("{} ", expansion)
} else {
expansion.to_string()
}
}).to_string();
result = re
.replace_all(&result, |caps: &regex::Captures| {
let matched = &caps[0];
if matched.ends_with(' ') {
format!("{} ", expansion)
} else {
expansion.to_string()
}
})
.to_string();
}
Ok(result)
@@ -210,7 +229,10 @@ impl TextNormalizer {
if ones == 0 {
return self.tens_words[tens as usize].to_string();
}
return format!("{} {}", self.tens_words[tens as usize], self.number_words[ones as usize]);
return format!(
"{} {}",
self.tens_words[tens as usize], self.number_words[ones as usize]
);
}
if num < 1000 {
@@ -219,7 +241,11 @@ impl TextNormalizer {
if remainder == 0 {
return format!("{} hundred", self.number_words[hundreds as usize]);
}
return format!("{} hundred {}", self.number_words[hundreds as usize], self.number_to_words(remainder));
return format!(
"{} hundred {}",
self.number_words[hundreds as usize],
self.number_to_words(remainder)
);
}
if num < 1_000_000 {
@@ -228,7 +254,11 @@ impl TextNormalizer {
if remainder == 0 {
return format!("{} thousand", self.number_to_words(thousands));
}
return format!("{} thousand {}", self.number_to_words(thousands), self.number_to_words(remainder));
return format!(
"{} thousand {}",
self.number_to_words(thousands),
self.number_to_words(remainder)
);
}
// For larger numbers, just return the digit string
@@ -259,9 +289,7 @@ impl TextNormalizer {
/// Remove punctuation marks
fn remove_punctuation(&self, text: &str) -> String {
text.chars()
.filter(|c| !c.is_ascii_punctuation())
.collect()
text.chars().filter(|c| !c.is_ascii_punctuation()).collect()
}
/// Normalize whitespace (collapse multiple spaces into one)
@@ -335,7 +363,10 @@ mod tests {
assert_eq!(normalizer.number_to_words(100), "one hundred");
assert_eq!(normalizer.number_to_words(256), "two hundred fifty six");
assert_eq!(normalizer.number_to_words(1000), "one thousand");
assert_eq!(normalizer.number_to_words(1234), "one thousand two hundred thirty four");
assert_eq!(
normalizer.number_to_words(1234),
"one thousand two hundred thirty four"
);
assert_eq!(normalizer.number_to_words(-5), "minus five");
}
@@ -350,7 +381,9 @@ mod tests {
};
let normalizer = TextNormalizer::new(config);
let result = normalizer.normalize("I have 3 apples and 42 oranges.").unwrap();
let result = normalizer
.normalize("I have 3 apples and 42 oranges.")
.unwrap();
assert_eq!(result, "I have three apples and forty two oranges.");
let result = normalizer.normalize("The year 2024 was great.").unwrap();
@@ -446,8 +479,13 @@ mod tests {
};
let normalizer = TextNormalizer::new(config);
let result = normalizer.normalize("Dr. Smith said I have 3 apples for 5 dollars").unwrap();
assert_eq!(result, "doctor smith said i have three apples for five dollars");
let result = normalizer
.normalize("Dr. Smith said I have 3 apples for 5 dollars")
.unwrap();
assert_eq!(
result,
"doctor smith said i have three apples for five dollars"
);
}
#[test]
@@ -470,7 +508,9 @@ mod tests {
};
let normalizer = TextNormalizer::new(config);
let result = normalizer.normalize("Mr. and Mrs. Smith live on Oak St.").unwrap();
let result = normalizer
.normalize("Mr. and Mrs. Smith live on Oak St.")
.unwrap();
assert_eq!(result, "Mister and Missus Smith live on Oak Street");
}
@@ -485,7 +525,9 @@ mod tests {
};
let normalizer = TextNormalizer::new(config);
let result = normalizer.normalize("Dr. Smith has 42 patients.").unwrap();
let result = normalizer
.normalize("Dr. Smith has 42 patients.")
.unwrap();
assert_eq!(result, "doctor smith has forty two patients.");
}
}