Struct TextGrid

Source
pub struct TextGrid { /* private fields */ }
Expand description

Represents a TextGrid, which is a data structure used in the linguistic research program Praat to annotate speech data. It can support either

Implementations§

Source§

impl TextGrid

Source

pub fn new(xmin: f64, xmax: f64, tiers: Vec<Tier>, name: String) -> TextGrid

Source§

impl TextGrid

Source

pub fn xmin(&self) -> &f64

Source

pub fn xmax(&self) -> &f64

Source

pub fn tiers(&self) -> &Vec<Tier>

Source

pub fn name(&self) -> &String

Source§

impl TextGrid

Source

pub fn tiers_mut(&mut self) -> &mut Vec<Tier>

Source§

impl TextGrid

Source

pub fn set_name(&mut self, val: String) -> &mut Self

Source§

impl TextGrid

Source

pub fn get_size(&self) -> usize

Returns the number of tiers in the TextGrid.

Source

pub fn set_xmin<W: Into<Option<bool>>>(&mut self, xmin: f64, warn: W)

Sets the xmin time value of the whole TextGrid in seconds.

§Arguments
  • xmin - The new xmin value.
  • warn - If Some(true), displays a warning if any tier has an xmin lesser than xmin.
Source

pub fn set_xmax<W: Into<Option<bool>>>(&mut self, xmax: f64, warn: W)

Sets the xmax time value of the whole TextGrid in seconds.

§Arguments
  • xmax - The new xmax value.
  • warn - If Some(true), displays a warning if any tier has an xmax greater than xmax.
Source

pub fn push_tier<W: Into<Option<bool>> + Copy>(&mut self, tier: Tier, warn: W)

Pushes a new, user-made tier to the TextGrid.

§Arguments
  • tier - The tier to be added.
  • warn - If Some(true), displays a warning if the tier has a minimum or maximum point that is outside the range of the TextGrid.
Source

pub fn get_tier(&self, name: &str) -> Option<&Tier>

Gets a tier using it’s name.

§Arguments
  • name - The name of the tier to get.
§Returns

Returns the tier if it exists, otherwise None.

Source

pub fn delete_tier<W: Into<Option<bool>> + Copy>(&mut self, name: &str, warn: W)

Deletes a tier using it’s name.

§Arguments
  • name - The name of the tier to delete.
  • warn - If true, displays a warning if the tier does not exist.
Source

pub fn write(&self, path: PathBuf, format: OutputFormat) -> Result<()>

Writes the TextGrid to a file or folder in the specified format.

If given a folder path, the TextGrid will be written to a file in the folder with the same name as the TextGrid’s name field.

Long TextGrids are the typical format, while short TextGrids are readable by Praat and do not include extraneous data.

§Arguments
  • path - The path to the file.
  • format - The output format.
§Errors

Returns an error if there was a problem creating or writing to the file.

Source

pub fn check_overlaps(&self) -> Option<Vec<(String, (u64, u64))>>

Checks the TextGrid for overlapping intervals or duplicate points.

§Returns

Returns Some([tier_name, (index1, index2)]) if an overlapping interval or point is found, otherwise None.

Source

pub fn fix_boundaries<P: Into<Option<bool>> + Copy>(&mut self, prefer_first: P)

Calls fix_overlaps on all IntervalTiers in the TextGrid.

§Arguments
  • prefer_first - If true, the first interval’s xmax will be raised or lowered to the new interval’s xmin in the case of a gap or overlap. If false, the second interval’s xmin will be raised or lowered to the first interval’s.
Source

pub fn fill_gaps(&mut self, text: &str)

Calls fill_gaps on all interval tiers in the TextGrid.

§Arguments
  • text - The text to fill the gaps with.

Trait Implementations§

Source§

impl Clone for TextGrid

Source§

fn clone(&self) -> TextGrid

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 Debug for TextGrid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TextGrid

Source§

fn default() -> TextGrid

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

impl Display for TextGrid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl TryFrom<&str> for TextGrid

TextGrid::try_from implementation for &str.

Source§

type Error = Error

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

fn try_from(textgrid: &str) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Box<dyn Read>> for TextGrid

Source§

type Error = Error

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

fn try_from(textgrid: Box<dyn Read>) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<File> for TextGrid

Source§

type Error = Error

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

fn try_from(textgrid: File) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<PathBuf> for TextGrid

TextGrid::try_from implementation for PathBuf.

Source§

type Error = Error

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

fn try_from(path: PathBuf) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<String> for TextGrid

TextGrid::try_from implementation for String.

Source§

type Error = Error

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

fn try_from(textgrid: String) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Vec<String>> for TextGrid

Source§

type Error = Error

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

fn try_from(textgrid: Vec<String>) -> Result<Self>

Performs the conversion.

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.