On 09/08/15 00:26, Peter M. Brigham wrote:
On Aug 8, 2015, at 4:51 PM, Richmond wrote:

On 08/08/15 23:33, Peter M. Brigham wrote:

<snip>
Missing an "of" in the two lines above:
    put line textLine *of* $TEKST into line cookedLine of fld "COOKED" etc
Don't know if that's the problem.
<snip>

Your script logic seems unnecessarily complex. Since it looks as if only the 
last occurrence is ending up in the output field, instead of using a counter to 
keep track of the next line in the field, you could just
    put cr & line textLine of $TEKST after fld "COOKED"
But once again, loading a line into a field repeatedly will be much slower than 
putting it into a variable in the repeat loop and then  putting the variable 
into the field just once when the repeat is done. Getting or putting something 
from or into a field is much slower than doing the same in a variable, so just 
do it once.

Also, I can see no reason to be loading your data into system variables, which is what 
"$WERBS" etc is defining. The only reason to put something into a variable beginning with 
"$" is if you want some other system process besides LC to be able to access the data.

-- Peter


Well, as per your suggestion I did this:

on mouseUp
   put 1 into textLine
   put fld "WERBS" into WERBS
   put fld "TEKST" into TEKST
   repeat until line textLine of TEKST contains "finalSolution666"
      put textLine into fld "KOUNT"
      put 1 into verbLine
      repeat until line verbLine of WERBS is empty
         put line textLine of TEKST into fld "LYNE"
         put line verbLine of WERBS into WERB
         put "were" && WERB into FRAZE
         put FRAZE into fld "FRAZE"
         if line textLine of TEKST contains FRAZE then
            if fld "COOKED" is empty then
               put line textLine of TEKST after fld "COOKED"
                -- this is here so that line 1 of fld "COOKED" does not end up 
empty
               else
                  put cr & line textLine of TEKST after fld "COOKED"
                  end if
         end if
         add 1 to verbLine
      end repeat
      add 1 to textLine
   end repeat
end mouseUp

but still get only the last value.
Well, your logic still makes my head hurt, too many counters.

My logic is based on the belief that one has to keep count of the lines in the Ur-text, the verb list, and the output field.

It is also derived from a program I wrote to make concordances in PASCAL in 1985.

The idea of using a carriage-return is very useful (haven't actually thought about those since my BA, as typed all my work on an Olivetti
portable which my Mum was given by her Mum and Dad for her 21st birthday).

  Here's what I'd do, using a variant of my original function since it appears 
that you want to list the lines the relevant phrases occur in, not just the 
isolated phrases.

Isolated phrases are not much use for subsequent analysis; i.e. to see which collocations they occur in, context, and so on.


function findWere pText
   -- returns a comma-delim list of all the line offsets matching "were *ed"
   --    or "were" && <a word in your preterite list>.
   put fld "WERBS" into pretList
   put wordOffsets("were", pText, true) into offList
   repeat for each item w in offList
      put word w+1 of pText into testWord
      if testWord ends with "ed" or testWord is among the words of pretList then
         put (the number of lines of word 1 to w of pText) & comma after outList
      end if
   end repeat
   return char 1 to -2 of outList
end if

then:

on mouseup
   put fld "TEKXT" into tText
   put findWere(tText) into linesList
   repeat for each item i in linesList
     put line i of tText & cr after relevantLines
   end repeat
   put char 1 to -2 of relevantLines into fld "COOKED"
end mouseup

Untested, but you get the idea.

I do.

Thanks.

I shall put your code in another button and see what happens.


-- Peter



Richmond.

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to