pub fn score_text(text: Vec<u8>) -> i32 {

    let mut score: i32 = 0;
    for &c in text.iter() {
        match c {
            0x65            => score += 20, // e
            0x74            => score += 20, // t
            0x61            => score += 20, // a
            0x6f            => score += 20, // o
            0x69            => score += 20, // i
            0x6e            => score += 20, // n
            0x61 ... 0x7a   => score += 10,
            0x20            => score += 0,
            _               => score -= 10,
        }
    }
    return score / (text.len() as i32);
}
/// Scores the text on its similarity to English using frequency analysis
Scores the text on its similarity to English using frequency analysis
Scores the text on its similarity to English using frequency analysis
pub fn score_text(text: Vec<u8>) -> i32 {
    let mut score: i32 = 0;
    for &c in text.iter() {
        match c {
            0x65            => score += 20, // e
            0x74            => score += 20, // t
            0x61            => score += 20, // a
            0x6f            => score += 20, // o
            0x69            => score += 20, // i
            0x6e            => score += 20, // n
            0x61 ... 0x7a   => score += 10,
            0x20            => score += 0,
            _               => score -= 10,
        }
    }
    return score / (text.len() as i32);
}
pub fn score_text ( text : Vec < u8 > ) -> i32 { let mut score : i32 = 0 ; for & c in text . iter ( ) { match c { 0x65 => score += 20 , // e 0x74 => score += 20 , // t 0x61 => score += 20 , // a 0x6f => score += 20 , // o 0x69 => score += 20 , // i 0x6e => score += 20 , // n 0x61 ... 0x7a => score += 10 , 0x20 => score += 0 , _ => score -= 10 , } } return score / ( text . len ( ) as i32 ) ; }
Scores the text on its similarity to English using frequency analysis
Scores the text on its similarity to English using frequency analysis
text
Vec<u8>
text
Vec<u8>