Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Faster/better way to achieve this?

 [1/7] from: kpeters::otaksoft::com at: 21-Apr-2009 19:13


Hi All ~ I need to eliminate lines from a file that contain one or more words from a "negative" list. Below is some simplified code showing how I am currently doing this. Is there a faster/better way? TIA Kai str: "Romeo loves Juliet very much" neg: [ "cheese" "bread" "wine" "very" ] strbl: parse str none if (length? strbl) + (length? neg) > length? union strbl neg [ print "kick out" ]

 [2/7] from: Tom:Conlin:gma:il at: 21-Apr-2009 20:13


Kai Peters wrote:
> Hi All ~ > I need to eliminate lines from a file that contain one or more words from a
<<quoted lines omitted: 9>>
> out" ] >> difference strbl intersect strbl neg
== ["Romeo" "loves" "Juliet" "much"]

 [3/7] from: alain::goye::free::fr at: 22-Apr-2009 11:53


Hi Kai I need to eliminate lines from a file that contain one or more words from anegative list. Below is some simplified code showing how I am currently doing this. Isthere a faster/better way? TIA Kai str: "Romeo loves Juliet very much" neg: [ "cheese" "bread" "wine" "very" ] strbl: parse str none if (length? strbl) + (length? neg) > length? union strbl neg [ print "kickout" ]

 [4/7] from: carl:cybercraft at: 22-Apr-2009 18:23


On Tuesday, 21-April-2009 at 19:13:58 Kai Peters wrote,
>Hi All ~ >I need to eliminate lines from a file that contain one or more words from a
<<quoted lines omitted: 8>>
>if (length? strbl) + (length? neg) > length? union strbl neg [ print "kick > out" ]
if not empty? intersect strbl neg [print "Kick out"] -- Carl Read.

 [5/7] from: sqlab::gmx::net at: 22-Apr-2009 10:16


If you transform your negative list instead of the string you can do str: "Romeo loves Juliet very much" neg: [ to "cheese" | to "bread" | to "wine" | to "very" to end] if parse str neg [print "Kick out"] AR Carl Read wrote:

 [6/7] from: moliad::gmail at: 22-Apr-2009 19:29


I was going to give you the exact same code as Carl read, then saw his suggestion :-) so I'll complement by giving you the fastest loop to clean-up a list of lines. and remember to use remove-each for the handling of the lines ;----------------------- str: [ "Romeo loves Juliet very much" "I Don't love Romeo that much" ] neg: [ "cheese" "bread" "wine" "very" ] remove-each item str [not empty? intersect neg parse item none] ;----------------------- and remember that you can use read/lines on a text file to get the data in the str format above. so that would make it a 3 line script :-D -MAx On Wed, Apr 22, 2009 at 2:23 AM, Carl Read <carl-cybercraft.co.nz> wrote:

 [7/7] from: kpeters::otaksoft::com at: 22-Apr-2009 18:02


Thanks guys ~ as usual, quite some ideas to work with! Kai

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted