Boolean searches

Everything related to our flagship word processor.
Post Reply
LearningGuy
Posts: 4
Joined: 2019-01-17 13:54:32

Boolean searches

Post by LearningGuy »

I’m new to Nisus Writer Pro.

To get straight to the point in this post, my question is about doing Boolean searches. I do see an option in the Find / Replace dialog for an OR type of search. Could someone advise on how you do an AND type of search where the results must contain all the multi words in the search criteria?

Thanks

John
adryan
Posts: 561
Joined: 2014-02-08 12:57:03
Location: Australia

Re: Boolean searches

Post by adryan »

Re: Boolean searches

G’day, John et al

Welcome to Nisus Writer.

There is no Boolean AND operator in the Find system. The Find system essentially looks for strings. If you wish to find something containing both “this” and “that”, you would search for a string containing those words separated by appropriate wildcards. Whether the wildcards include paragraph returns depends on the scope of the search. You would also need to specify whether you are searching the entire document or only a selected portion thereof. Furthermore, if the order of the words is not necessarily this particular one, you would need to construct an alternative search string accordingly. The two strings could be combined as one in the Find field using the OR (“|”) operator. You get the idea that we start playing a game of mathematical permutations as we add more search terms, at which stage a macro may be more useful to handle the logic.

An alternative approach would be to use nested Finds, by which I mean that you would perform a succession of Find operations each of which confines its scope to the result returned from the previous Find operation. (This is equivalent to performing a Find In Selection.) For example, you might search for all paragraphs containing “this”, then search only for the subset of them containing “that”, and so on. This approach could save you from having to consider the order in which your search terms appear. Again, a macro would probably be useful for complicated situations.

When it comes to Find/Replace operations, it is often helpful if one has some idea of the structure of the document and the likely disposition of the search terms. (For example, will the search terms always occur in the same paragraph?) So try to be as specific as possible about what you are trying to do.

I hope this helps.

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Boolean searches

Post by phspaelti »

Hello John,
"Boolean" searches is one of those terms…

The point is that Find is not a search engine looking through a database, it's a pattern matching algorithm. So an "AND" search in this case would be a search for string1 followed by string2. In the simplest case you just type them both into the find box. but of course that would require them to be immediately adjacent to each other. To allow them to be separated you will have to put a wildcard in between them. So your expression will say string1 wildcard string2. Your choice of wild card will depend on what you want to allow to intervene between the two. For example if you use the Any wildcard, the search will match the first instance of string1 and then your entire document up to the last instance of string2. If you choose Any Text then your search results will be limited to instances where string1 and string2 are in the same paragraph.

Finally if you don't care about the linear order of string1 and string2 you'll have to do two searches, which you can combine using OR.
So a search for all paragraphs containing both "love" and "hope" would look like this:
Screen Shot 2019-01-18 at 14.38.14.png
Screen Shot 2019-01-18 at 14.38.14.png (106.57 KiB) Viewed 6072 times
philip
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Boolean searches

Post by martin »

Philip and Adrian have already given great background information and advice. I just wanted to share a macro that automates what Philip has described. The macro Find Nearby Words will search your document for any two words (or phrases). The macro will only match a paragraph if it contains both desired words, in any order, and with any text between those words.
LearningGuy
Posts: 4
Joined: 2019-01-17 13:54:32

Re: Boolean searches

Post by LearningGuy »

Fascinating search protocol in Nisus Writer Pro! Coming from a database background, it is interesting that besides a search criteria NWP requires a "scope" of - what - to search in for instance, like the file, paragraph or sentence. In databases, the "records" are the scope assumed except in SQL where the scope is "within " the results of a precursor search.

I can see from the help you have all provided that NWP offers an extremely rich and comprehensive search ability with lots of very useful pattern permutations as filters. Considering that they can be implemented in a Macro language too is great.

Thanks for the generous help you have all provided . As my forum name "LearningGuy" indicates, I'm a newbie with Nisus Writer Pro 3.

John
adryan
Posts: 561
Joined: 2014-02-08 12:57:03
Location: Australia

Re: Boolean searches

Post by adryan »

G’day, John et al

Nisus Writer doesn’t quite require a scope along the lines you described (eg, paragraph or sentence). The drop-down Where menu in the Find & Replace dialog box gives you the default options available. My suggestion was that one can do more tailored specification by appropriate construction of the search string. Note that the PowerFind Pro option in the Using drop-down menu in the dialog box allows you to construct regular expressions for such purposes.

Just by way of example, suppose you had a portion of your document that used tabs to align data in a set of columns. It would be possible to construct a Find expression that found occurrences of a given search term limited to (say) the third column. Strictly speaking, the scope of the Find operation is whatever was chosen in the Where menu, but in this instance we might simply say that we are searching within that third column.

By the way, it is possible to construct a database system with Nisus Writer and its macros. It’s not the preferred route, but it does give some indication of the application’s power and could help fill in the time on a rainy afternoon.

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
Post Reply