[−][src]Module kl_hyphenate::score
Evaluating potential hyphenation opportunities
In Knuth–Liang hyphenation, dictionaries identify valid word breaks by searching whole words for sub-word patterns, ultimately producing a score that evaluates each interval between letters as a candidate for hyphenation.
As an example, consider the word "firkin":
f|i|r|k|i|n
Our British English dictionary recognizes six patterns therein, each of which assigns a numeric value to one or more locations; when a location is assigned multiple values, the highest one prevails. Patterns are so compounded until a final score is produced. Using guillemets to mark word boundaries, we find:
«f|i|r|k|i|n»
-------------
«f i2
i2r
r2k
r5k i n
k1i n
k2i n»
-------------
f|i|r|k|i|n
0 2 5 2 0
By convention, even values inhibit hyphenation, whereas odd values mark valid breaks. Thus, having matched these patterns, the dictionary will offer "fir·kin" as a valid hyphenation.
Traits
Score | Methods to evaluate each index in a string as an opportunity for hyphenation. |