[thelist] ASP: First 100 words in a record

Robert Goodyear rob_goodyear at yahoo.com
Wed Jun 19 14:16:08 CDT 2002


What about somthing like this? CAVEAT: just rambling
at the keyboard here, so this code is not valid, nor
do I know if you can nest and exit loops like this.

position = 1
wordcount = 0
Do while wordcount < 100
body = (the content you're extracting from)
If mid(body, position, 1) = " " then
  wordcount = wordcount + 1
  position = position + 1
  Loop
End If
If mid(body, position, 1) = "<" then
  Do while mid(body, position, 1) <> ">"
    position = position + 1
  Loop
End If
Loop
body = left(body, position)


I think this would be far more efficient than building
arrays. I suppose to save resources you could run this
file as a batch and parse through your whole database
and write back in some synopsis fields so it wouldn't
need to run in realtime.

Thoughts, anyone?

Robert Goodyear
http://www.westeye.com




--- Ken Kogler <ken.kogler at cph.org> wrote:
> > the synopsis used to be the first x characters of
> the article.
>
> After a bit of reflection, the first x characters
> might just be a better way
> of doing this, rather than the first x words.
> Doesn't help that it's a LOT
> easier to do, of course... :)
>
> > if you want 100 words instead, i can't see any
> other way than:
>
> > split() the string on a space
> > keep only first 100 array items
> > join() with a space
>
> > but i'd think this is a nightmere as far as
> resources go.
>
> Which is exactly why I posted to the list - I
> couldn't see any way around
> it.
>
> Thanks!
>
> -Ken
>
> --
> For unsubscribe and other options, including
> the Tip Harvester and archive of thelist go to:
> http://lists.evolt.org Workers of the Web, evolt !


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



More information about the thelist mailing list