How to find words and phrases as well

Wilhelm Sanke sanke at hrz.uni-kassel.de
Sat Jan 28 16:44:13 EST 2006


On Sat, 28 Jan 2006 , Andr?.Bisseret <Andre.Bisseret at inria.fr> wrote:

> Thanks a lot Wilhelm for your answer and your website I am discovering
> ; it is including very useful tools and I am learning a lot from it.
>
> However, I am worrying about using the offset function for several
> reasons :
> - actually, I have several fields to search in (what I should have
> mention in my question, sorry);
> - the user should be allowed to write several words or phrases that
> should  be search in this several fields;
> - I would like to find each occurrence of each word and phrases in the
> fields (I am highlighting each of them when the user arrives on one of
> the found card, starting from the results list).


As far as I understand you (from the above-quoted lines) this 
functionality is very similar to the search concept implemented in my 
"Topsearch" tool that is able to search all visible and even hidden 
fields of a stack, counts and lists all occurrences of a string - that 
can consist of any number of adjacent words, colorizes the searchstring 
in all found lines, displays the address of the field, and provides the 
possibility to display a chosen whole field (from the address) where 
also all occurrences of the searchstring are hilited etc. 
(<http://www.sanke.org/Software/Topsearch.zip>)

See below the full description of the stack from the information field.

> - In order to be retain, a card should include alls the words or
> phrases written by the user (in other words, I would like an implied
> "AND", not an "OR".


Up to now, it did not come up for me to experiment with Boolean 
searches. I will give it a try as soon as I can devote some time to 
that. But apparently Eric Chatonet has already dealt with that issue and 
has answers for you, as he writes:

> On the other hand I have realized complex search scripts that parse a  
> text to retrieve, for instance, all phrases (paragraphs) that contain  
> pStr1 AND pStr2, etc.
> Could you be more precise about your needs?

You continue:

> With the "find" function it is rather easy and fast, and currently, my
> app works well but with the restriction that the user can ask only for
> single-word keywords, not phrases.

With "find string" you can search for phrases.

> I keep feeling that I can't easily use the offset function to obtain
> what I want to ; Likely, I am missing something ?
>
> best regards
> from Grenoble
> André


You are right here, looking over the script of the search button of 
"Topstack" it is really far more complicated than using the find command.
On the other hand searching with "offset" is really lightning-fast, even 
for a greater number of fields in an stack.
But it is really worth-while to try out the various offset functions 
eventually.

Regards,

Wilhelm Sanke

P.S.:  Here is the text of the "information" field of the "Topstack" tool:

This stack searches all visible and hidden fields on all cards of the 
current topstack or the stacks of the Revolution Documentation up to Rev 
version 2.2. (for higher versions you need my tool "searchdocs_XML"; see 
my website <www.sanke.org/MetaMedia>). The search routine uses the 
"lineOffset" function to search for *any* searchstring, which means it 
does not explicitly search for words or items. The searchstring "layer" 
would also display all lines that contain "player", so if you are 
searching only for "layer" press the spacebar once before typing "layer" 
into the dialog.

The stacks of the Revolution Documentation need not be open; they are 
then opened by the search.

The results are listed with the searchstring colorized and the addresses 
of the found fields. Hidden fields are indicated.
Clicking at the address brings up the card of the topstack with the 
found fields.

The clicked address line is then colorized green and a button "show full 
text of field" appears.This button allows to open a field at the bottom 
of the stack that displays the complete formatted text of the selected 
field  - again with all instances of the searchstring colorized. This 
may be especially helpful also when dealing with hidden fields.

If several stacks are open, this search stack recognizes which of these 
stacks is the topstack when you perform a search. As the searchstring is 
stored in the dialog, you can quickly search several stacks for the same 
string when you make them the respective topstack by clicking at a stack.





More information about the use-livecode mailing list