pub struct ArabicReshaper { /* private fields */ }
Expand description

ArabicReshaper

the main type for reconstructing sentences to be used in applications that don’t support Arabic script.

Implementations§

source§

impl ArabicReshaper

source

pub fn new(config: ReshaperConfig) -> Self

Create a new ArabicReshaper using the given config

source

pub fn reshape<S>(&self, text: S) -> Stringwhere S: AsRef<str>,

Reshape the given line and return the reshaped string

Examples found in repository?
examples/reshape_line.rs (line 11)
3
4
5
6
7
8
9
10
11
12
fn main() {
    let mut reshaper = ArabicReshaper::default();

    // we can modify config after creating `ArabicReshaper`
    reshaper.modify_config(|c| {
        c.delete_harakat = true;
    });

    println!("{}", reshaper.reshape("ههه"));
}
source

pub fn reshape_lines<S, L>(&self, lines: L) -> Vec<String>where S: AsRef<str>, L: AsRef<[S]>,

Reshape all lines in the given slice and return a new Vec of strings

Examples found in repository?
examples/reshape_lines.rs (line 8)
3
4
5
6
7
8
9
10
11
fn main() {
    let reshaper = ArabicReshaper::default();

    let lines = ["به نام خدا", "همه چی درست میشه!"];

    for line in reshaper.reshape_lines(lines) {
        println!("{line}");
    }
}
source

pub fn modify_config<F>(&mut self, func: F)where F: FnOnce(&mut ReshaperConfig),

A safe way to modify the config (ReshaperConfig) after creating the ArabicReshaper.

Examples found in repository?
examples/reshape_line.rs (lines 7-9)
3
4
5
6
7
8
9
10
11
12
fn main() {
    let mut reshaper = ArabicReshaper::default();

    // we can modify config after creating `ArabicReshaper`
    reshaper.modify_config(|c| {
        c.delete_harakat = true;
    });

    println!("{}", reshaper.reshape("ههه"));
}

Trait Implementations§

source§

impl Clone for ArabicReshaper

source§

fn clone(&self) -> ArabicReshaper

Returns a copy 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 ArabicReshaper

source§

fn default() -> ArabicReshaper

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

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.