use super::RelevanceScorer;
impl RelevanceScorer {
pub(super) fn accumulate_title_score(&self, title_lower: &str, score: &mut f64) {
for term in &self.query_terms {
let weight = self.term_weights.get(term).unwrap_or(&1.0);
if title_lower.contains(term) {
*score += 2.0 * weight;
}
if title_lower.starts_with(term) {
*score += 1.5 * weight;
}
if self.has_word_boundary_match(title_lower, term) {
*score += 1.2 * weight;
}
}
}
pub(super) fn accumulate_description_score(&self, desc_lower: &str, score: &mut f64) {
for term in &self.query_terms {
let weight = self.term_weights.get(term).unwrap_or(&1.0);
if desc_lower.contains(term) {
*score += 0.8 * weight;
}
if self.has_word_boundary_match(desc_lower, term) {
*score += 0.6 * weight;
}
}
}
pub(super) fn accumulate_url_score(&self, url_lower: &str, score: &mut f64) {
for term in &self.query_terms {
let weight = self.term_weights.get(term).unwrap_or(&1.0);
if url_lower.contains(term) {
*score += 0.4 * weight;
}
}
}
}