Page 1 of 1
problem trueword in a string with "."not followed by a spac
Posted: Wed Dec 28, 2016 11:16 pm
by jmburnod
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
Re: problem trueword in a string with "."not followed by a
Posted: Thu Dec 29, 2016 9:18 am
by Thierry
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
Otherwise, must certainly be a bug..
Happy new year,
Thierry
Re: problem trueword in a string with "."not followed by a
Posted: Thu Dec 29, 2016 10:29 am
by jmburnod
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
Re: problem trueword in a string with "."not followed by a
Posted: Thu Dec 29, 2016 10:50 am
by Thierry
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
Re: problem trueword in a string with "."not followed by a
Posted: Fri Dec 30, 2016 9:52 am
by jmburnod
I filled a bug report
Bug 19038 - trueword in a string with "." or ":" not followed by a space, unexpected result
Jean-Marc
Re: problem trueword in a string with "."not followed by a
Posted: Fri Dec 30, 2016 5:37 pm
by jacque
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.
Re: problem trueword in a string with "."not followed by a
Posted: Sat Dec 31, 2016 1:19 pm
by jmburnod
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.

Re: problem trueword in a string with "."not followed by a
Posted: Sat Dec 31, 2016 7:19 pm
by jacque
I wish everyone a year of peace and 805s.

Re: problem trueword in a string with "."not followed by a
Posted: Tue Jan 10, 2017 11:44 am
by jmburnod
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.