Powerfind for Near?

Everything related to our flagship word processor.
Post Reply
withoutFeathers
Posts: 140
Joined: 2013-03-19 16:22:50

Powerfind for Near?

Post by withoutFeathers »

Hi,
I'm hoping Powerfind can help me with a basic NEAR search, but after studying the examples and manual I need someone to give me a shove in the right direction.

Example: I'd like to find all the "Alice" within 20 characters of "Bob". (Or 5, or 50 characters, in different searches.)

Is there some combination of Preceded by, Followed by, Capture, Number, and Wildcards that will allow me to do this?

I think if I see one of them laid out I'll be able to get the hang of it, but I'm not sure how to start. :)

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

Re: Powerfind for Near?

Post by adryan »

G'day, wF et al

This is probably best done using a Macro. But here are some Find expressions you could try, where "gamma" and "delta" are the two words in question.

PowerFind, where the square brackets indicate inbuilt PowerFind expressions available via the cogwheel drop-down menu:–

[Capture(]gamma[AnyCharacter][0-5 Times]delta[)]

[0-5 Times] is obtained using the N-M Times function.

PowerFind Pro:–

gamma.{0,5}delta

PowerFind Pro is much easier to use here because one can alter the parameters (viz, N, M) for the separating string directly rather than via a dialog box.

Note that you can't simply swap the two words to form a symmetrical expression and then conjoin the two expressions with an "OR" or "|". This will fail if one of the words is "surrounded" by more than one occurrence of the other word in too close proximity. So you need to perform two separate searches. (Which is why a purpose-built Macro would be better.)

After performing each of the searches, you would need to search In Selection if you wish to isolate all occurrences of one of the words in the given situation. Alternatively, you could use appropriate Replace expressions with the desired word highlighted (say).

I hope this helps.

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
withoutFeathers
Posts: 140
Joined: 2013-03-19 16:22:50

Re: Powerfind for Near?

Post by withoutFeathers »

adryan wrote: 2021-03-21 00:10:23 This is probably best done using a Macro. But here are some Find expressions you could try, where "gamma" and "delta" are the two words in question.

PowerFind, where the square brackets indicate inbuilt PowerFind expressions available via the cogwheel drop-down menu:–

[Capture(]gamma[AnyCharacter][0-5 Times]delta[)]

[0-5 Times] is obtained using the N-M Times function.
Thanks adryan, I'm using it immediately. :)

Question: why the Capture? I'm finding it seems to work the same without surrounding Capture function.

And your warnings about select/replace and refinements look well conceived, but in this case I'm not replacing. I need to examine each instance for the context and make an appropriate shift. So I can just zip through, looking at each "Find Next", and skip over the few that are found inaccurately.

Similarly for an overall "or" to get delta before gamma. I need to examine each new find anyway, so it doesn't matter if I do that in a separate search.

Great!

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

Re: Powerfind for Near?

Post by adryan »

G'day, wF et al

Oops! The Capture function was a leftover from my testing with the OR function, so it's not needed for these separate searches with PowerFind.

gamma[AnyCharacter][0-5 Times]delta

delta[AnyCharacter][0-5 Times]gamma

BTW, I subsequently discovered that there is a Find Nearby Words Macro in the Find set of Macros. It looks at paragraphs rather than the user-specified string neighborhoods you had in mind.

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
withoutFeathers
Posts: 140
Joined: 2013-03-19 16:22:50

Re: Powerfind for Near?

Post by withoutFeathers »

adryan wrote: 2021-03-21 11:43:47 BTW, I subsequently discovered that there is a Find Nearby Words Macro in the Find set of Macros. It looks at paragraphs rather than the user-specified string neighborhoods you had in mind.
That's odd; I don't have that under menu: Macro->Find->

I had looked for that before, expecting to see a Macro for "Nearby". And I don't seem to have it anywhere in the Macros.

I'm using Nisus 3.2.1, upgraded fairly recently. Did your macro for Find Nearby Words come with your NWP? Or possibly it was a later addition?

In any event, do you know how I might get a copy, for interest (and possibly to use)?

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

Re: Powerfind for Near?

Post by adryan »

G'day, wF et al

It looks like it was bundled with NWP.

Find Nearby Words.nwm
(21.94 KiB) Downloaded 660 times

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
withoutFeathers
Posts: 140
Joined: 2013-03-19 16:22:50

Re: Powerfind for Near?

Post by withoutFeathers »

adryan wrote: 2021-03-21 13:44:46 G'day, wF et al

It looks like it was bundled with NWP.

Find Nearby Words.nwm
Thanks!

As you said, it's preset to work within a single paragraph as the neighbourhood.
And also it doesn't distinguish lower and upper case, which is somewhat surprising.
Anyway, not what I'm needing here (compared to the PowerFind, certainly, which is great), but maybe in some future use.

p.s. A bit later -- I see, interestingly, that the macro inserts PowerFind bubbles of what it's doing into my open Find dialog.
And then, if I search with those bubbles instead, it does in fact distinguish upper and lower case; so that's been fixed in PowerFind; it only doesn't work in the original Macro.

wF
Post Reply