Multiple Offenders

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

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Multiple Offenders

Post by richmond62 » Sun May 23, 2021 8:42 pm

The European languages I have a reasonable knowledge of (Scots, English, French and Bulgarian) all have
the annoying tendency to use 3 different punctuation marks to finish sentences:

1. The full stop ".'.

2. The question mark "?".

3. The exclamation mark "!".

So, attempting to chop up a text into sentences by using full stops as my itemDelimiter
excludes those finishing with question or exclamation marks . . .

So, I would be most grateful if someone could tell me how to use multiple item delimiters.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Multiple Offenders

Post by jmburnod » Sun May 23, 2021 9:53 pm

Hi Richmond,
You may use sentence
I understand sentence delimiter is one of these chars ".?!" followed by one space and an uppercase letter.
Try this

Code: Select all

on mouseup
   put "Paul. Paul ? Paul !" into tVar
   answer the num of sentences of tVar
   repeat with i = 1 to the num of sentences of tVar
      answer sentence i of tVar
      wait 1000 milliseconds
   end repeat
end mouseup
Kind regards
Jean-Marc
https://alternatic.ch

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Multiple Offenders

Post by richmond62 » Sun May 23, 2021 10:07 pm

Thanks, I just checked that in the Dictionary.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Multiple Offenders

Post by jmburnod » Mon May 24, 2021 12:37 pm

Hi,
I also use a getTextInRules function to apply rules described in my prev post.

Code: Select all

function getTextInRules pText
   put ",;:.?!" into tPon
   put ".?!" into tPonWithMaj
   put empty into rTextInRules
   repeat with i = 1 to the num of chars of pText
      if tMaj or i = 1 then
         put upper(char i of pText )after rTextInRules
         put false into tMaj
      else
         put char i of pText after rTextInRules
      end if
      if char i of pText is in tPon and char (i+1) of pText <> " " then
         put " " after rTextInRules
         if char i of pText is in tPonWithMaj then
            put true into tMaj
         end if
      end if
   end repeat
   return rTextInRules
end getTextInRules
Jean-Marc
https://alternatic.ch

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Multiple Offenders

Post by richmond62 » Mon May 24, 2021 2:58 pm

Sentence worked like a charm.

I had forgotten what a pain-in-the-bum the Dictionary was on Linux until last
night when I was in bed "having a thing" with my Xubuntu laptop and the
Dictionary took up the whole screen, blocking out the IDE because my web-browser
of choice is set to full-screen for other uses . . .
-
SShot 2021-05-24 at 16.25.26.png
-

Code: Select all

on mouseUp
   put empty into fld "REZZZ"
   put empty into fld "OX"
   put empty into fld "D1"
   put empty into fld "D2"
   ask "What is the first word are you interested in?"
   if it is not empty then
      put it into DUMA1
      put DUMA1 into fld "D1"
      ask "What is the second word are you interested in?"
      if it is not empty then
         put it into DUMA2
         put DUMA2 into fld "D2"
         ---
         put fld "fff" into EFF
         put 1 into LAPC
         repeat until EFF is empty
            put empty into KOUNT
            put sentence 1 of EFF into SFF
            ---
            if SFF contains DUMA1 then
               add 1 to KOUNT
            end if
            if SFF contains DUMA2 then
               add 2 to KOUNT
            end if
            if KOUNT > 1 then
               put SFF into line LAPC of fld "REZZZ"
               put (LAPC && "co-occurrences") into fld "OX"
               add 1 to LAPC
            end if
            ---
            delete sentence 1 of EFF
         end repeat
         ---
      end if
   end if
   
end mouseUp
File removed as updated version posted below.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Multiple Offenders

Post by richmond62 » Mon May 24, 2021 8:03 pm

SShot 2021-05-24 at 21.49.54.png
-
Added IMPORT and EXPORT capabilities.
Attachments
COOCCUR.livecode.zip
Here's the stack.
(12.78 KiB) Downloaded 99 times

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”