Hyphenation of long words

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10415
Joined: Fri Feb 19, 2010 10:17 am

Re: Hyphenation of long words

Post by richmond62 »

it's very close to a good hyphen
Well, as we know, all good programmers go to "Hyphen"

while bad programmers have to make a dash for it 8)
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10501
Joined: Wed May 06, 2009 2:28 pm

Re: Hyphenation of long words

Post by dunbarx »

Max.

Am i misunderstanding how to use your function? I get massively truncated lines with any sort of text, and hyphens in all the wrong places.

Craig
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10501
Joined: Wed May 06, 2009 2:28 pm

Re: Hyphenation of long words

Post by dunbarx »

Richmond.

:roll:

Craig
bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Hyphenation of long words

Post by bogs »

Don't sweat it Richmond, I appreciated it :D
Image
MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Hyphenation of long words

Post by MaxV »

dunbarx wrote: Mon Feb 19, 2018 9:59 pm Max.

Am i misunderstanding how to use your function? I get massively truncated lines with any sort of text, and hyphens in all the wrong places.

Craig
If you want max 80 chars per line into a field:

Code: Select all

put field "myLongText" into temp
put  hypnen( temp, 80) into field "myLongText"
In Italian works quite good, I have just to fix with punctuation marks:
hypnen.png
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10501
Joined: Wed May 06, 2009 2:28 pm

Re: Hyphenation of long words

Post by dunbarx »

Ah, I see what happened. i misunderstood what "tSize" meant. It means the length of a line.

Craig
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Hyphenation of long words

Post by [-hh] »

Hyphenation is a non-trivial optimization problem. Knuth did a lot in that field for TeX.
https://en.wikipedia.org/wiki/Hyphenation_algorithm

Here a linguistic approach based on that and hunspell (link from the page above).
http://www.ushuaia.pl/hyphen/?ln=en
shiftLock happens
theotherbassist
Posts: 115
Joined: Thu Mar 06, 2014 9:29 am

Re: Hyphenation of long words

Post by theotherbassist »

Hypnen! Sounds like great ambient prog-disco.

I like the simplicity of it. Maybe a few more rules could even tighten things up a bit more on average... does anyone know the actual Knuth–Liang hyphenation algorithm? I can't seem to find the nuts and bolts of it--only a bunch of talk about it.
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Hyphenation of long words

Post by [-hh] »

theotherbassist wrote:... does anyone know the actual Knuth–Liang hyphenation algorithm?
Here's Liang's thesis as PDF
http://www.tug.org/docs/liang/

Beneath my link above (hunspell) there is also a brilliant JavaScript implementation based on that:
https://github.com/mnater/Hyphenator

I implemented it already (via a browser widget for english, french, german, italian and spanish). Works fine.
shiftLock happens
theotherbassist
Posts: 115
Joined: Thu Mar 06, 2014 9:29 am

Re: Hyphenation of long words

Post by theotherbassist »

Thanks! :D
Post Reply