Improve scoring

This commit is contained in:
Antonio Scandurra 2023-08-24 16:32:55 +02:00
parent c1d9b37dbc
commit cbf7160054

View File

@ -83,8 +83,8 @@ pub struct StreamingDiff {
impl StreamingDiff {
const INSERTION_SCORE: f64 = -1.;
const DELETION_SCORE: f64 = -5.;
const EQUALITY_BASE: f64 = 2.;
const MAX_EQUALITY_EXPONENT: i32 = 32;
const EQUALITY_BASE: f64 = 1.4;
const MAX_EQUALITY_EXPONENT: i32 = 64;
pub fn new(old: String) -> Self {
let old = old.chars().collect::<Vec<_>>();
@ -120,7 +120,7 @@ impl StreamingDiff {
if self.old[i - 1] == ' ' {
self.scores.get(i - 1, j - 1)
} else {
let exponent = cmp::min(equal_run as i32 / 3, Self::MAX_EQUALITY_EXPONENT);
let exponent = cmp::min(equal_run as i32, Self::MAX_EQUALITY_EXPONENT);
self.scores.get(i - 1, j - 1) + Self::EQUALITY_BASE.powi(exponent)
}
} else {