Get Number of Words Within Quotation Marks

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

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Get Number of Words Within Quotation Marks

Post by AxWald » Fri Nov 18, 2016 12:05 am

Hi,
tonymac wrote:... to NOT have to massage the text moving/replacing characters/words after it's downloaded.
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?

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
Have fun!
Attachments
AWA_WordListMaker_V2.zip
V2 of a small demo stack
(2.04 KiB) Downloaded 170 times
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”