[−][src]Trait spandex_hyphenation::hyphenator::Hyphenator
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.
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>
&'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>>
&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 char
s from the start and end of a word where breaks may
not occur.
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.
Implementors
impl<'h> Hyphenator<'h> for Extended
[src]
type Opportunity = (usize, Option<&'h Subregion>)
type Exact = (usize, Option<Subregion>)
fn hyphenate<'t>(&'h self, word: &'t str) -> Word<'t, Self::Opportunity>
[src]
fn opportunities_within(
&'h self,
word: &str,
(l, r): (usize, usize)
) -> Vec<Self::Opportunity>
[src]
&'h self,
word: &str,
(l, r): (usize, usize)
) -> Vec<Self::Opportunity>
fn exact(&'h self, w: &str) -> Option<Vec<Self::Opportunity>>
[src]
fn add_exact(
&mut self,
w: String,
ops: Vec<Self::Exact>
) -> Option<Vec<Self::Exact>>
[src]
&mut self,
w: String,
ops: Vec<Self::Exact>
) -> Option<Vec<Self::Exact>>
fn unbreakable_chars(&self) -> (usize, usize)
[src]
impl<'h> Hyphenator<'h> for Standard
[src]
type Opportunity = usize
type Exact = usize
fn hyphenate<'t>(&'h self, word: &'t str) -> Word<'t, Self::Opportunity>
[src]
fn opportunities_within(
&'h self,
word: &str,
(l, r): (usize, usize)
) -> Vec<usize>
[src]
&'h self,
word: &str,
(l, r): (usize, usize)
) -> Vec<usize>