pub(crate) fn read_words(&mut self, line: DelimIter<'_>) -> usize {
        self.lines += 1;
        let line = line.skip(1); // skip the target
        if self.is_dense.is_some() {
            // tsv input
            let mut count = 0;
            for (i, word) in line.enumerate() {
                let is_dense = self.is_dense.as_ref().unwrap();
                if !is_dense.get(i).copied().unwrap_or(false) {
                    self.make_sure_room(i);
                    *self.categorical_counts[i]
                        .entry(Identity64::from(hash(word)))
                        .or_insert(0) += 1;
                }
                count += 1;
            }
            count
        } else {
            // svm input
            line.filter(|word| not_space(*word))
                .map(strip_value)
                .map(|word| {
                    *self.counts.entry(Identity64::from(hash(word))).or_insert(0) += 1;
                })
                .count()
        }
    }
/// Given a delimiter pointing to the start of an SVMLight line,
/// counts features in the line. Returns the total number of words
/// in that line.
Given a delimiter pointing to the start of an SVMLight line,
counts features in the line. Returns the total number of words
in that line.
Given a delimiter pointing to the start of an SVMLight line counts features in the line . Returns the total number of words in that line .
pub(crate) fn read_words(&mut self, line: DelimIter<'_>) -> usize {
        self.lines += 1;
        let line = line.skip(1); // skip the target
        if self.is_dense.is_some() {
            // tsv input
            let mut count = 0;
            for (i, word) in line.enumerate() {
                let is_dense = self.is_dense.as_ref().unwrap();
                if !is_dense.get(i).copied().unwrap_or(false) {
                    self.make_sure_room(i);
                    *self.categorical_counts[i]
                        .entry(Identity64::from(hash(word)))
                        .or_insert(0) += 1;
                }
                count += 1;
            }
            count
        } else {
            // svm input
            line.filter(|word| not_space(*word))
                .map(strip_value)
                .map(|word| {
                    *self.counts.entry(Identity64::from(hash(word))).or_insert(0) += 1;
                })
                .count()
        }
    }
pub ( crate ) fn read_words ( & mut self , line : DelimIter < ' _ > ) -> usize { self . lines += 1 ; let line = line . skip ( 1 ) ; // skip the target if self . is_dense . is_some ( ) { // tsv input let mut count = 0 ; for ( i , word ) in line . enumerate ( ) { let is_dense = self . is_dense . as_ref ( ) . unwrap ( ) ; if ! is_dense . get ( i ) . copied ( ) . unwrap_or ( false ) { self . make_sure_room ( i ) ; * self . categorical_counts [ i ] . entry ( Identity64 :: from ( hash ( word ) ) ) . or_insert ( 0 ) += 1 ; } count += 1 ; } count } else { // svm input line . filter ( | word | not_space ( * word ) ) . map ( strip_value ) . map ( | word | { * self . counts . entry ( Identity64 :: from ( hash ( word ) ) ) . or_insert ( 0 ) += 1 ; } ) . count ( ) } }
Given a delimiter pointing to the start of an SVMLight line,
counts features in the line.
Given a delimiter pointing to the start of an SVMLight line counts features in the line .
&mut self
line
DelimIter<'_>
&mut self
line
DelimIter<'_>