[][src]Trait spandex_hyphenation::hyphenator::Hyphenator

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 exact(&'h self, lowercase_word: &str) -> Option<Vec<Self::Opportunity>>;
fn add_exact(
        &mut self,
        word: String,
        ops: Vec<Self::Exact>
    ) -> Option<Vec<Self::Exact>>;
fn unbreakable_chars(&self) -> (usize, usize); fn opportunities(&'h self, lowercase_word: &str) -> Vec<Self::Opportunity> { ... }
fn boundaries(&self, word: &str) -> Option<(usize, usize)> { ... } }

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

type Opportunity

Plain representation of a word break.

type Exact

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

Loading content...

Required methods

fn hyphenate<'t>(&'h self, word: &'t str) -> Word<'t, Self::Opportunity>

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.

fn opportunities_within(
    &'h self,
    lowercase_word: &str,
    bounds: (usize, usize)
) -> Vec<Self::Opportunity>

The hyphenation opportunities that arise between the specified indices.

No attempt is made to retrieve a known exact hyphenation.

fn exact(&'h self, lowercase_word: &str) -> Option<Vec<Self::Opportunity>>

Retrieve the known exact hyphenation for this word, if any.

fn add_exact(
    &mut self,
    word: String,
    ops: Vec<Self::Exact>
) -> Option<Vec<Self::Exact>>

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

If the word already has an exact hyphenation, the old opportunities are returned.

fn unbreakable_chars(&self) -> (usize, usize)

The number of chars from the start and end of a word where breaks may not occur.

Loading content...

Provided methods

fn opportunities(&'h self, lowercase_word: &str) -> Vec<Self::Opportunity>

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

fn boundaries(&self, word: &str) -> Option<(usize, usize)>

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

Loading content...

Implementors

impl<'h> Hyphenator<'h> for Extended[src]

type Opportunity = (usize, Option<&'h Subregion>)

type Exact = (usize, Option<Subregion>)

impl<'h> Hyphenator<'h> for Standard[src]

type Opportunity = usize

type Exact = usize

Loading content...