Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hyphenation in c#

Tags:

c#

hyphenation

I'm looking for a sample project that will perform hyphenation of text in C#. Ideally, this would be derived from the TeX hyphenation algorithm, or similar. I'm interested in English currently, although other languages may be required in the future. Anyone seen something like that? background I'm planning on including this in a MonoTouch project using CoreText.

like image 496
Ethan Avatar asked May 04 '11 02:05

Ethan


People also ask

What is hyphenation example?

The hyphen ‐ is a punctuation mark used to join words and to separate syllables of a single word. The use of hyphens is called hyphenation. Son-in-law is an example of a hyphenated word.

What is meant by hyphenation?

/ˌhaɪ.fənˈeɪʃ.ən/ the use of the symbol -, joining two words or two parts of a word: the rules of hyphenation.

Why is hyphenation needed?

Generally, you need the hyphen only if the two or more words are functioning together as an adjective before the noun they're describing. If the noun comes first, leave the hyphen out. This wall is load bearing. It's impossible to eat this cake because it is rock hard.

What is hyphenation in text?

Hyphenation is the automated process of breaking words between lines to create more consistency across a text block. In justified text, hyphenation is mandatory. In left-aligned text, hyphenation evens the irregular right edge of the text, called the rag .


2 Answers

I found a C# implementation of Knuth-Liang hyphenation algorithm at https://github.com/alkozko/NHyphenator and it seems to work fine.

But there are currently two drawbacks:

  1. It can't load TeX hyphenation pattern files out-of-the-box (however, adding support for them seems trivial).
  2. It's unclear which kind of license applies to the source code.
like image 61
Lukas Pokorny Avatar answered Sep 19 '22 00:09

Lukas Pokorny


Obviously, Donald Knuth's algorithms are excellent. Although there is not a C# implementation available, have you considered converting another implementation to C#? (For example, you could convert the Java implementation which is fairly close to C#.)

Another option is to use a simpler implementation which can be found over at this answer here on StackOverflow.

like image 20
JasCav Avatar answered Sep 21 '22 00:09

JasCav