Additional feature for Linguistic Focus

Hi, everyone, love Scrivener!
I recently was doing a rewrite of my novel, in which I had decided to change a minor character’s gender. That meant going through and changing all the relevant pronouns from “he” to “she”, and so forth. I used the Lingistic Focus function to spotlight the pronouns to help me find all of them (and hopefully not miss any).
In doing so, I noticed something: the pronoun “her” was highlighted when used as a pronoun (e.g., “they looked at her”), but not when used as an adjective (e.g., “that was her car parked out front”), which makes sense. However, when I chose to spotlight adjectives instead of pronouns, it still didn’t find those instances of “her”; in fact, I tried all the parts of speech, and none of them spotlighted those instances. That may be a bug.
And then that led me to think of a possible enhancement to Linguistic Focus, which could be useful to anyone who changes a character’s gender. Add a selection for something like “gender-specific pronouns”, which would eliminate things like “I” or “they”, and also bend the rule to allow the adjectives “her” and “his”.
What do you think?

Hi,

Thanks for the kind words!

Although it’s certainly a nice idea, I’m afraid that this is a little out of scope, in that it would be a much bigger addition than you would expect because of language differences. This is because Linguistic Focus is actually a rather simple tool that just calls on some nice new APIs that Apple introduced into macOS a couple of years ago. These APIs allow me to ask Apple’s frameworks to search for all nouns, pronouns, synonyms and so on in a piece of text. The actual searching is handled by Apple’s routines, though. Thus, the bugs that you mention (and there are a few flaky areas!) are Apple’s, and the only way to implement gender-specific pronoun searching would be to implement it myself (as I did with dialogue focus). The trouble here is that I don’t have Apple’s resources! Although on the surface it wouldn’t be too hard to try to catch all gender-specific pronouns (“her”, “she”, “herself”) by simply doing a sub-search within Apple’s pronoun results, the problem is that it would need to work for all languages that Apple supports. And that’s where it gets a little tricky…

All the best,
Keith

Speaking to the task of highlighting a few specific words, you can do this with the search tools Scrivener already has, using the project search and entering the pronouns/adjectives you want to find. Then just load the resulting documents individually or in Scrivenings and all the search terms will be highlighted in the editor, ready for you to edit. You can even save the search as a collection to easily reload it as you work through the draft.

Hi Jennifer,

I’m also interested in this search you are talking about, but I couldn’t understand how to perform it. Can you, please, describe the steps to do it?

Thank you,
M

Looking at it today, I realise I was a little hasty in answering yesterday, so yes, let me go through this for both Mac and Windows, as they’re a little different at present. It’s possible on each, but needs different steps.

On macOS, open Edit > Find > Search in Project. Click the magnifying glass in the search field at the top of the binder and select the “RegEx” operator (rather than “Any” as I’d said before). You can also choose to search in “Text” to limit the search just to the document text, rather than including notes, synopses, etc. The search highlighting won’t show in those areas, but if you want to include them just so you can check for any changes to make, you can easily leave it set to Search In “All”.

To use the RegEx search for the individual words, enter them like this:
\b(word|word|word)\b
The \b on either side ensures that the results only include whole words (so if you search “her” you don’t get a result of “here”) and listing the words within the parentheses, separated by the pipe, searches for any of them, rather than all the words.

The search will return all the documents in the project that contain any of the words, and when they’re loaded in the editor while the search is open, the search terms in the text will be highlighted. Clicking the arrow button in the left of the Search Results header will load the entire set of search results; you can set the editor to Scrivenings mode (View > Scrivenings) to work on them together. Click the magnifying glass in the search field and choose “Save Search as Collection…” to–dun da dun–save the search as a collection, so you can easily reload it without needing to retype the search. View > Show Collections will show the collection tabs at the top of the binder, and clicking a search collection will rerun the saved search so you get the most recent results.

On Windows using 1.9.7, the project search field appears by default in the main toolbar; if it’s not shown, you can open it via Edit > Find > Project Search… Click the magnifying glass in the field and choose the “Whole Word” search. This works a bit differently on Windows, and will treat a list of multiple terms as an Any search but requiring each word to be a whole word in the results. So you can enter a list like “she her hers” and it will return documents that contain any of those words if the word is a whole word, so it would find “her” but not “here”. The search terms will be highlighted in the editor when the document is loaded while the search is active (results are listed in the binder). You can select multiple documents from the results list and load them in Scrivenings mode to work on them together, and you can save the search as a collection from the bottom of the magnifying glass menu in the search field . View > Collections > Collections will show (or hide) the collection tabs at the top of the binder so you can easily reload the search.

Awesome! Thanks, Jennifer!

Very nice, indeed. Do you know for what languages these APIs exist? On Swedish text I can use Dialogue Focus, but none of the others, e.g. adjectives or nouns.

:confused:

Sorry, matsgz, missed this. I’m afraid I don’t know, no. “Dialogue Focus” is my own code, and so designed to work with as many types of quotation marks as I could research. Everything else in there, however, simply uses Apple’s code. It’s based on NSLinguisticTagger, the documentation for which says it supports “many different languages”, but does not go into specifics:

developer.apple.com/documentati … guage=objc

Thanks!