pub struct CountVectorizerParams(/* private fields */);
Implementations§
Source§impl CountVectorizerParams
impl CountVectorizerParams
pub fn tokenizer(self, tokenizer: Tokenizer) -> Self
Sourcepub fn max_features(self, max_features: Option<usize>) -> Self
pub fn max_features(self, max_features: Option<usize>) -> Self
When building the vocabulary, only consider the top max_features (by term frequency). If None, all features are used.
Sourcepub fn convert_to_lowercase(self, convert_to_lowercase: bool) -> Self
pub fn convert_to_lowercase(self, convert_to_lowercase: bool) -> Self
If true, all documents used for fitting will be converted to lowercase.
Sourcepub fn n_gram_range(self, min_n: usize, max_n: usize) -> Self
pub fn n_gram_range(self, min_n: usize, max_n: usize) -> Self
If set to (1,1)
single tokens will be candidate vocabulary entries, if (2,2)
then adjacent token pairs will be considered,
if (1,2)
then both single tokens and adjacent token pairs will be considered, and so on. The definition of token depends on the
regex used fpr splitting the documents.
min_n
should not be greater than max_n
Sourcepub fn normalize(self, normalize: bool) -> Self
pub fn normalize(self, normalize: bool) -> Self
If true, all charachters in the documents used for fitting will be normalized according to unicode’s NFKD normalization.
Sourcepub fn document_frequency(self, min_freq: f32, max_freq: f32) -> Self
pub fn document_frequency(self, min_freq: f32, max_freq: f32) -> Self
Specifies the minimum and maximum (relative) document frequencies that each vocabulary entry must satisfy.
min_freq
and max_freq
must lie in 0..=1
and min_freq
should not be greater than max_freq
Source§impl CountVectorizerParams
impl CountVectorizerParams
Sourcepub fn fit<T: ToString + Clone, D: Data<Elem = T>>(
&self,
x: &ArrayBase<D, Ix1>,
) -> Result<CountVectorizer>
pub fn fit<T: ToString + Clone, D: Data<Elem = T>>( &self, x: &ArrayBase<D, Ix1>, ) -> Result<CountVectorizer>
Learns a vocabulary from the documents in x
, according to the specified attributes and maps each
vocabulary entry to an integer value, producing a CountVectorizer.
Returns an error if:
- one of the
n_gram
boundaries is set to zero or the minimum value is greater than the maximum value - if the minimum document frequency is greater than one or than the maximum frequency, or if the maximum frequency is
smaller than zero - if the regex expression for the split is invalid
Sourcepub fn fit_files<P: AsRef<Path>>(
&self,
input: &[P],
encoding: EncodingRef,
trap: DecoderTrap,
) -> Result<CountVectorizer>
pub fn fit_files<P: AsRef<Path>>( &self, input: &[P], encoding: EncodingRef, trap: DecoderTrap, ) -> Result<CountVectorizer>
Learns a vocabulary from the documents contained in the files in input
, according to the specified attributes and maps each
vocabulary entry to an integer value, producing a CountVectorizer.
The files will be read using the specified encoding
, and any sequence unrecognized by the encoding will be handled
according to trap
.
Returns an error if:
- one of the
n_gram
boundaries is set to zero or the minimum value is greater than the maximum value - if the minimum document frequency is greater than one or than the maximum frequency, or if the maximum frequency is
smaller than zero - if the regex expression for the split is invalid
- if one of the files couldn’t be opened
- if the trap is strict and an unrecognized sequence is encountered in one of the files
Sourcepub fn fit_vocabulary<T: ToString>(
&self,
words: &[T],
) -> Result<CountVectorizer>
pub fn fit_vocabulary<T: ToString>( &self, words: &[T], ) -> Result<CountVectorizer>
Produces a CountVectorizer with the input vocabulary.
All struct attributes are ignored in the fitting but will be used by the CountVectorizer
to transform any text to be examined. As such this will return an error in the same cases as the fit
method.
Trait Implementations§
Source§impl Clone for CountVectorizerParams
impl Clone for CountVectorizerParams
Source§fn clone(&self) -> CountVectorizerParams
fn clone(&self) -> CountVectorizerParams
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for CountVectorizerParams
impl Debug for CountVectorizerParams
Source§impl Default for CountVectorizerParams
impl Default for CountVectorizerParams
Source§impl ParamGuard for CountVectorizerParams
impl ParamGuard for CountVectorizerParams
Source§type Checked = CountVectorizerValidParams
type Checked = CountVectorizerValidParams
Source§type Error = PreprocessingError
type Error = PreprocessingError
Source§fn check_ref(&self) -> Result<&Self::Checked, Self::Error>
fn check_ref(&self) -> Result<&Self::Checked, Self::Error>
Source§fn check(self) -> Result<Self::Checked, Self::Error>
fn check(self) -> Result<Self::Checked, Self::Error>
§fn check_unwrap(self) -> Self::Checkedwhere
Self: Sized,
fn check_unwrap(self) -> Self::Checkedwhere
Self: Sized,
check()
and unwraps the resultAuto Trait Implementations§
impl !Freeze for CountVectorizerParams
impl !RefUnwindSafe for CountVectorizerParams
impl Send for CountVectorizerParams
impl !Sync for CountVectorizerParams
impl Unpin for CountVectorizerParams
impl UnwindSafe for CountVectorizerParams
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.