Struct TextAugmentParameters

Source
pub struct TextAugmentParameters {
    pub p: f32,
    pub min_elements: Option<usize>,
    pub max_elements: Option<usize>,
}
Expand description

Parameters for augmentation

Fields§

§p: f32

Probability 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

Source

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 augmentation
  • max_elements - Maximum elements for augmentation
Source

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

Source§

fn clone(&self) -> TextAugmentParameters

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for TextAugmentParameters

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T