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: 9249
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Hyphenation of long words

Post by richmond62 » Mon Feb 19, 2018 9:54 pm

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: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Hyphenation of long words

Post by dunbarx » 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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Hyphenation of long words

Post by dunbarx » Mon Feb 19, 2018 10:01 pm

Richmond.

:roll:

Craig

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

Re: Hyphenation of long words

Post by bogs » Mon Feb 19, 2018 10:04 pm

Don't sweat it Richmond, I appreciated it :D
Image

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Hyphenation of long words

Post by MaxV » Tue Feb 20, 2018 12:19 pm

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: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Hyphenation of long words

Post by dunbarx » Tue Feb 20, 2018 4:15 pm

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
Location: Göttingen, DE

Re: Hyphenation of long words

Post by [-hh] » Tue Feb 20, 2018 8:39 pm

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
Location: UK

Re: Hyphenation of long words

Post by theotherbassist » Sat Feb 24, 2018 1:08 pm

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
Location: Göttingen, DE

Re: Hyphenation of long words

Post by [-hh] » Sat Feb 24, 2018 7:12 pm

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
Location: UK

Re: Hyphenation of long words

Post by theotherbassist » Sat Feb 24, 2018 10:18 pm

Thanks! :D

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”