problem trueword in a string with "."not followed by a spac

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

problem trueword in a string with "."not followed by a spac

Post by jmburnod » Wed Dec 28, 2016 11:16 pm

Hi All,
I noticed a problem about trueword in a string with "." when "." is not followed by a space.
put trueword 5 of "Cooking with livecode is nice.Verry Nice" return "nice.Verry" and I expected "nice".
Same result with ":" but works fine with "!?,;-".
Is it a bug or i missed something in the doc ?

"A trueWord is a word chunk, delimited by Unicode word breaks, as determined by the ICU Library. When there are no alphabetic or numeric characters between two word breaks, that string is not considered by LiveCode to be a trueWord."
Best regards
Jean-Marc
https://alternatic.ch

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: problem trueword in a string with "."not followed by a

Post by Thierry » Thu Dec 29, 2016 9:18 am

jmburnod wrote: put trueword 5 of "Cooking with livecode is nice.Verry Nice" return "nice.Verry" and I expected "nice".
Same result with ":" but works fine with "!?,;-".
Joyeuses fetes, jean-marc !

If you need a quick solution, here is one:

Code: Select all

on mouseUp
   put line -1 of the script of me into T
   put trueword 5 of T --> nice.Very
   put truetrueword(T, 5) --> nice
end mouseUp

function truetrueword txt, n
   get "(?:\w+[^\w]){" & n - 1 & "}(\w+)"
   get matchText( txt, IT, theWord)
   return theWord
end truetrueword

Cooking with livecode is nice.Very Nice
et oui, meme le Pere Noel parle regex 8)

Otherwise, must certainly be a bug..

Happy new year,

Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: problem trueword in a string with "."not followed by a

Post by jmburnod » Thu Dec 29, 2016 10:29 am

I felt that Santa Claus existed. I know now who he's and that He speaks french... and regex.
Thanks one more
It works fine to get the trueword of a string. I will try workaround using this to get the prev or next real true word.
Thierry wrote: Otherwise, must certainly be a bug.
I will fill a bug report

Belles fêtes à toi aussi and happy new year
Jean-Marc
https://alternatic.ch

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: problem trueword in a string with "."not followed by a

Post by Thierry » Thu Dec 29, 2016 10:50 am

jmburnod wrote: Thanks one more
It works fine to get the trueword of a string.
I will try workaround using this to get the prev or next real true word.
You're welcomed.
Be careful if you want to use it; I don't think it will be generic enough
but it's easy to modify for different inputs.
Feel free to contact me off-list; you know where I am...

Regards,

Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: problem trueword in a string with "."not followed by a

Post by jmburnod » Fri Dec 30, 2016 9:52 am

I filled a bug report
Bug 19038 - trueword in a string with "." or ":" not followed by a space, unexpected result
Jean-Marc
Attachments
stTestTrueWord.zip
(1.24 KiB) Downloaded 192 times
https://alternatic.ch

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: problem trueword in a string with "."not followed by a

Post by jacque » Fri Dec 30, 2016 5:37 pm

I suspect the issue is in the library that LC uses, and is probably an intentional decision. Decimal numbers would break, for example, since "123.8645" would not be a word any longer. It would also error with file paths and URLs. Just a guess.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: problem trueword in a string with "."not followed by a

Post by jmburnod » Sat Dec 31, 2016 1:19 pm

Thanks Jacqueline and hapy new year,
I will find a workaround to avoid space missed after "." or ":" in the target text.
Jean-Marc
P.S : I'm endind 2016 with a 805 score on your Klondike game. :D
https://alternatic.ch

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: problem trueword in a string with "."not followed by a

Post by jacque » Sat Dec 31, 2016 7:19 pm

I wish everyone a year of peace and 805s. :-)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: problem trueword in a string with "."not followed by a

Post by jmburnod » Tue Jan 10, 2017 11:44 am

Hi All,
Bug 19038 confirmed by LiveCode quality center
Best
Jean-Marc

Edit: There is different opinions if that is a bug or not.
It seems that the best way is to apply ponctuation rules when the text is written.
https://alternatic.ch

Post Reply