Trait hyphenation::hyphenator::Hyphenator[][src]

pub trait Hyphenator<'h> {
    type Opportunity;
    type Exact;
    fn hyphenate<'t>(&'h self, word: &'t str) -> Word<'t, Self::Opportunity>;
fn opportunities_within(
        &'h self,
        lowercase_word: &str,
        bounds: (usize, usize)
    ) -> Vec<Self::Opportunity>;
fn exception_within(
        &'h self,
        lowercase_word: &str,
        bounds: (usize, usize)
    ) -> Option<Vec<Self::Opportunity>>;
fn add_exception(
        &mut self,
        lowercase_word: String,
        ops: Vec<Self::Exact>
    ) -> Option<Vec<Self::Exact>>;
fn remove_exception(&mut self, word: &str) -> Option<Vec<Self::Exact>>;
fn unbreakable_chars(&self) -> (usize, usize); fn opportunities(&'h self, lowercase_word: &str) -> Vec<Self::Opportunity> { ... }
fn exception(
        &'h self,
        lowercase_word: &str
    ) -> Option<Vec<Self::Opportunity>> { ... }
fn boundaries(&self, word: &str) -> Option<(usize, usize)> { ... } }
Expand description

A dictionary capable of hyphenating individual words.

For the purpose of hyphenation, a “word” should not be a compound in hyphenated form (such as “hard-nosed”), but a single run of letters without intervening punctuation or spaces.

For details, refer to the patterns/*.chr.txt file for each language.

Associated Types

Plain representation of a word break.

An owned opportunity used to specify and store the predetermined hyphenation of known words.

Required methods

Hyphenate a word, computing appropriate word breaks and preparing it for iteration.

Soft hyphens take priority over dictionary hyphenation; if the word contains any, they will be returned as the only breaks available.

This method is case-insensitive.

The hyphenation opportunities that arise by pattern between the specified byte indices.

The hyphenation opportunities that arise by exception between the specified byte indices, if any.

Specify the hyphenation of the given word with an exact sequence of opportunities and add it to the exception list. Subsequent calls to hyphenate or opportunities will yield this hyphenation instead of generating one from patterns.

If the word is already a known exception, the old opportunities are returned.

If the word is an exception, remove it and return the previously specified opportunities; otherwise, return none.

The number of chars from the start and end of a word where breaks may not occur, according to dictionary parameters.

Provided methods

The hyphenation opportunities that our dictionary can find in the given word. The word should be lowercase.

If this word is a known exception, retrieve its specified hyphenation.

The byte indices delimiting the substring where breaks may occur, unless the word is too short to be hyphenated.

Implementors