Table of Contents

Class HyphenationDictionary

Namespace
DocWright.Core.Text
Assembly
DocWright.Core.dll

Liang pattern hyphenation: the algorithm behind TeX's and Word's soft-hyphen placement.

public sealed class HyphenationDictionary
Inheritance
HyphenationDictionary
Inherited Members

Remarks

A width-based heuristic ("split at the first vowel/consonant boundary that fits") cannot reproduce Word's break points, because English hyphenation is lexical rather than phonetic: Word breaks opti-mize, not optimi-ze, and im-prove-ments, not improve-me-nts. Liang's algorithm encodes the lexicon as a pattern set — short letter sequences carrying odd (break) and even (no-break) priorities at each inter-letter position — and takes, per position, the highest priority any matching pattern asserts. Odd wins are legal break points.

The pattern set is per language, so a document written in a language DocWright ships no patterns for gets no dictionary and the caller falls back to its own rule; matching English patterns against German text would be worse than not hyphenating at all.

Instances are immutable and safe to share across threads. Pattern tables are built once, on first use of the language that needs them.

Properties

LeftHyphenMin

Gets the fewest characters that must stay on the line before a hyphen.

MinimumWordLength

Gets the shortest word this dictionary can ever break, which is LeftHyphenMin plus RightHyphenMin.

RightHyphenMin

Gets the fewest characters that must carry over to the next line after a hyphen.

Methods

FindBreakPositions(string, int[])

Finds every position at which word may be broken with a hyphen.

ForLanguage(string?)

Gets the dictionary for a language, or null when no pattern set is shipped for it.