using 'find to search
[1/7] from: ryan:christiansen:intellisol at: 11-Apr-2001 16:40
I am using the following to search for keywords in a string.
The word 'xml-message represents a string which includes XML tags and
content between the tags.
The word 'messages is a block of 'xml-message strings.
The word 'cgi-data is an object including values 'keyword and 'messageID
foreach xml-message messages [
if find xml-message cgi-data/keyword [
message-with-keyword: load/markup xml-message
append messages-with-keyword message-with-keyword/<messageID>
messages-with-keyword
]
]
You can see the search function in action here:
http://www.fargonews.com/rebolrepublic
The 'find seems to be able to find some of the words in the string, but not
others. It will successfully find "as" and "rebol" but cannot find
professional
or "such."
I'm confused.
Ryan C. Christiansen
Web Developer
Intellisol International
4733 Amber Valley Parkway
Fargo, ND 58104
701-235-3390 ext. 6671
FAX: 701-235-9940
http://www.intellisol.com
Global Leader in People Performance Software
_____________________________________
Confidentiality Notice
This message may contain privileged and confidential information. If you
think, for any reason, that this message may have been addressed to you in
error, you must not disseminate, copy or take any action in reliance on it,
and we would ask you to notify us immediately by return email to
[ryan--christiansen--intellisol--com]
[2/7] from: ryan::christiansen::intellisol::com at: 11-Apr-2001 16:57
The foreach statement doesn't seem to be checking "each" 'xml-message in
'messages. It only seems to be searching on the second message. It will
find any word in the second message, but ignores the first message
altogether.
Ryan C. Christiansen
Web Developer
Intellisol International
4733 Amber Valley Parkway
Fargo, ND 58104
701-235-3390 ext. 6671
FAX: 701-235-9940
http://www.intellisol.com
Global Leader in People Performance Software
_____________________________________
Confidentiality Notice
This message may contain privileged and confidential information. If you
think, for any reason, that this message may have been addressed to you in
error, you must not disseminate, copy or take any action in reliance on it,
and we would ask you to notify us immediately by return email to
[ryan--christiansen--intellisol--com]
[ryan--christiansen--inte]
llisol.com To: [rebol-list--rebol--com]
Sent by: cc:
[rebol-bounce--rebol--com] Subject: [REBOL] using 'find to search
04/11/2001 04:40 PM
Please respond to
rebol-list
I am using the following to search for keywords in a string.
The word 'xml-message represents a string which includes XML tags and
content between the tags.
The word 'messages is a block of 'xml-message strings.
The word 'cgi-data is an object including values 'keyword and 'messageID
foreach xml-message messages [
if find xml-message cgi-data/keyword [
message-with-keyword: load/markup xml-message
append messages-with-keyword message-with-keyword/<messageID>
messages-with-keyword
]
]
You can see the search function in action here:
http://www.fargonews.com/rebolrepublic
The 'find seems to be able to find some of the words in the string, but not
others. It will successfully find "as" and "rebol" but cannot find
professional
or "such."
I'm confused.
Ryan C. Christiansen
Web Developer
Intellisol International
4733 Amber Valley Parkway
Fargo, ND 58104
701-235-3390 ext. 6671
FAX: 701-235-9940
http://www.intellisol.com
Global Leader in People Performance Software
_____________________________________
Confidentiality Notice
This message may contain privileged and confidential information. If you
think, for any reason, that this message may have been addressed to you in
error, you must not disseminate, copy or take any action in reliance on it,
and we would ask you to notify us immediately by return email to
[ryan--christiansen--intellisol--com]
[3/7] from: alan_otterstad:mikronvinyl at: 11-Apr-2001 15:00
Ryan,
Just putting in 2 cents worth to try and help...i'm not very good at Rebol
yet.
Does find work like parse...if so then I noticed in another message the
solution was to include a "to end" at the end of the command to make sure
that the entire string/block you are searching thru gets processed.
example I am referring to is:
> >> parse "html" ["htm" | "html"]
> == false
> (the above is what bothers me)
Two things to note:
1. When you match against a group of strings, the first possible match is
the one you get. In your case, the "htm" is matching before the "html",
which is correct.
2. parse only returns true if the entire string is parsed. In your
example,
html
is matched with "htm", so you have the "l" remaining unparsed. This
gives a result of false. If you change your example to:
parse "html" [["htm" | "html"] to end]
Then you'll get true instead.
James
this is from a previous message about parse. I was hoping that the 'to
end' might also work in the same way in find.
if not then oh well. I was just trying to help.
Alan
[4/7] from: jhagman:infa:abo:fi at: 12-Apr-2001 1:17
Quoting [ryan--christiansen--intellisol--com] ([ryan--christiansen--intellisol--com]):
> The foreach statement doesn't seem to be checking "each" 'xml-message in
> 'messages. It only seems to be searching on the second message. It will
> find any word in the second message, but ignores the first message
> altogether.
>
> foreach xml-message messages [
This must sound stupid, but: Are you sure that messages is still
pointing to the head of the block? Try
foreach xml-message head messages [
or
messages: head messages
foreach xml-message messages [
instead.
Yours,
Jussi
--
Jussi Hagman CS in Åbo Akademi University
Studentbyn 4 D 33 [juhagman--abo--fi]
20540 Åbo [jhagman--infa--abo--fi]
Finland
[5/7] from: gjones05:mail:orion at: 11-Apr-2001 17:16
From: <[ryan--christiansen--intellisol--com]>
> I am using the following to search for keywords in a string.
> The word 'xml-message represents a string which includes XML tags and
<<quoted lines omitted: 11>>
> http://www.fargonews.com/rebolrepublic
> The 'find seems to be able to find some of the words in the string, but
not
> others. It will successfully find "as" and "rebol" but cannot find
> "professional" or "such."
>
> I'm confused.
>
> Ryan C. Christiansen
> Web Developer
In reference to "search function", I assume that you are referring to the
Search News!
button and accompanying field. Here is what I get when I
search the same terms.
rebol returns:
20010410143649 20010411114200
as returns:
20010410143649 20010411114200
professional returns:
20010411114200
such returns:
20010411114200
Your search function appears to be returning the correct article numbers
based on the articles that I can read in the bottom portion of the screen.
Am I misunderstanding?
--Scott Jones
[6/7] from: jhagman:infa:abo:fi at: 12-Apr-2001 1:43
Quoting [ryan--christiansen--intellisol--com] ([ryan--christiansen--intellisol--com]):
> foreach xml-message messages [
> if find xml-message cgi-data/keyword [
> message-with-keyword: load/markup xml-message
> append messages-with-keyword message-with-keyword/<messageID>
> messages-with-keyword
I read your code again and I am wondering what the line above is for? It
should not interfere but is unnecessary as far as I can tell.
Hmmm... Maybe it is time for some sleep. :)
Yours,
Jussi
--
Jussi Hagman CS in Åbo Akademi University
Studentbyn 4 D 33 [juhagman--abo--fi]
20540 Åbo [jhagman--infa--abo--fi]
Finland
[7/7] from: ryan:christiansen:intellisol at: 12-Apr-2001 8:30
No, you're not misunderstanding. But why does it work for you and not for
me? Seriously. The script is returning 'none for me now. I guess I'll tweak
it some more. Still confused.
>In reference to "search function", I assume that you are referring to the
>"Search News!" button and accompanying field. Here is what I get when I
<<quoted lines omitted: 11>>
>Am I misunderstanding?
>--Scott Jones
Ryan C. Christiansen
Web Developer
Intellisol International
4733 Amber Valley Parkway
Fargo, ND 58104
701-235-3390 ext. 6671
FAX: 701-235-9940
http://www.intellisol.com
Global Leader in People Performance Software
_____________________________________
Confidentiality Notice
This message may contain privileged and confidential information. If you
think, for any reason, that this message may have been addressed to you in
error, you must not disseminate, copy or take any action in reliance on it,
and we would ask you to notify us immediately by return email to
[ryan--christiansen--intellisol--com]
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted