I use this script to batch-correct hyphenation errors in a document and/or add words with correct break points to the exception list. My starting point is a list of all hyphenated words in a document, created by the hyphen_collect script.
The list in the screenshot below is the result of deleting all correctly hyphenated words. So I'm left with a list of words, some of which need to be corrected in the document, other should be added to the exception list.
I make this distinction because I don't want all words to appear in the exception list. For example, the first four and the sixth words are hyphenated with permanent hyphens, and there's no point adding these to the exception list. There's authenti~cally, which is wrong, and this one I would like to send to the exception list. Of the last two, difficult-to-define, like the first four, has permanent hyphens and should not be otherwise divided (and not be included in the exception list), and embourgeo~isment is wrong but I don't want it in the list.
To tell the script what to do, mark words with wrong or undesirable hyphenation as follows. Words preceded by % will be corrected only in the document, they're not added to the exception list; if a word is not preceded by %, it is added to the exception list (and therefore all its occurrences in the document will be corrected automatically).
In either case you need to indicate all the correct hyphenation points. You do this using the same method as used in the dictionary dialog: indicate correct hyphenation points with a swung dash (~). You can prevent a word from being broken by prefixing it with a swung dash. In the following screenshot, the above list is corrected:
In the first entry, %anti-~imperial, % shows that I don't want to add the word in the exception list. I also indicated that the second part of the compound, imperial, should not be hyphenated by preceding it with a ~. The next three items are similar in that they are compounds whose members should not be broken.
The next item, authentically, should be included in the exception list. All correct hyphenation points are indicated by swung dashes. The one-but-last item is again a compound whose parts should not be broken. And the last word, embourgeoisment, I don't want in the list so I prefixed it with % and marked the correct break points.
Naturally, changing the division of some words may cause their containing paragraphs to reflow and lead to other hyphenations, which could lead to other errors. However, in my experience so far this hardly ever happens, but it should be borne in mind.
To use the script, make sure the corrected list is the active document and that the document to which the corrections are to be applied is open as well. Then run it.
The script tries to determine which language is set in the document (it can't deal with multiple languages) and preselects that in a dialog in which you can select a different language. What you choose here determines which exception dictionary is used. Press Enter/Return or OK to start the script.
Show script (right click, Save Link/Target As to download)
Installing and running scripts
Questions, comments? Get in touch