pub struct TextAugmentParameters {
pub p: f32,
pub min_elements: Option<usize>,
pub max_elements: Option<usize>,
}Expand description
Parameters for augmentation
Fields§
§p: f32Probability of augmentation of single element Not true probability, but expected percent of elements to be augmented If not set fall back to default value of 0.3
min_elements: Option<usize>Minimum elements for augmentation If not set - no limit
max_elements: Option<usize>Maximum elements for augmentation If not set - no limit
Implementations§
Source§impl TextAugmentParameters
impl TextAugmentParameters
Sourcepub fn new(
p: f32,
min_elements: Option<usize>,
max_elements: Option<usize>,
) -> Self
pub fn new( p: f32, min_elements: Option<usize>, max_elements: Option<usize>, ) -> Self
Create new AugmentParameters
§Arguments
p- Probability of augmentation of single element (expected percent of elements to be augmented)min_elements- Minimum elements for augmentationmax_elements- Maximum elements for augmentation
Sourcepub fn num_elements(&self, input_size: usize) -> usize
pub fn num_elements(&self, input_size: usize) -> usize
Calculate number of elements to be augmented from input size
§Arguments
input_size- Size of input in elements (words, chars, etc.)
§Examples
use fast_aug::text::TextAugmentParameters;
let params = TextAugmentParameters{p: 0.5, min_elements: None, max_elements: None};
// Apply only p
assert_eq!(params.num_elements(10), 5);
let params = TextAugmentParameters{p: 0.5, min_elements: Some(3), max_elements: Some(7)};
// Apply min_elements
assert_eq!(params.num_elements(4), 3);
// Apply min_elements, but reach input_size, so return input_size
assert_eq!(params.num_elements(1), 1);
// Apply max_elements
assert_eq!(params.num_elements(100), 7);Trait Implementations§
Source§impl Clone for TextAugmentParameters
impl Clone for TextAugmentParameters
Source§fn clone(&self) -> TextAugmentParameters
fn clone(&self) -> TextAugmentParameters
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TextAugmentParameters
impl RefUnwindSafe for TextAugmentParameters
impl Send for TextAugmentParameters
impl Sync for TextAugmentParameters
impl Unpin for TextAugmentParameters
impl UnwindSafe for TextAugmentParameters
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
Mutably borrows from an owned value. Read more