This is where I see the problems. Too many varieties in punctation, and too many strange uses of these: see "[...] their names were-- Flopsy, Mopsy [...]", where the "--" doesn't make much sense. Maybe "—" was meant, but the writer didn't know how to type it?tonymac wrote:... to NOT have to massage the text moving/replacing characters/words after it's downloaded.
Anyways, I think you'll not be able to live w/o any "massaging". Depending of the use case you'll need to adapt - use one of the 2 versions above (with very few "massaging"), or check the attached stack:
I modified my previous example to match the 100 word challenge, and it offers 2 different modes. One that allows for "-" and single quotes, and one that reduces the text to bare bones. It's more code, and heavy "massaging", but the results may be suitable. I have added a button to demonstrate "the words are shown/replaced in a repeat loop", too.
Results of "bare bone mode":
Code: Select all
Resulting unique words: 67; Real word count: 100; Time used: 0 Milliseconds
-----------------------------------------------------------------------------------
Once upon a time there were four little Rabbits and their names were Flopsy Mopsy Cottontail and Peter They lived with their Mother in a sandbank underneath the root of a very big firtree
Now my dears said old Mrs Rabbit one morning you may go into the fields or down the lane but dont go into Mr McGregors garden your Father had an accident there he was put in a pie by Mrs McGregor
Now run along and dont get into mischief Then Mrs Rabbit took a basket and her umbrella and went through the woods to the bakers
-----------------------------------------------------------------------------------
a accident along and bakers basket big but by Cottontail dears dont down Father fields firtree Flopsy four garden get go had in into lane little lived may McGregors mischief Mopsy morning Mother Mrs my names Now of old Once one Peter pie put Rabbits root run said sandbank their Then there They through time took umbrella underneath upon very was went were with woods you your