Skip to main content
Known Participant
July 25, 2024
Question

Need Help in Collecting Medical Terms words Flagged by Dynamic Spelling in InDesign

  • July 25, 2024
  • 2 replies
  • 242 views

Hi everyone,

I'm a graphic designer working on medical-related projects, and I often encounter technical medical terms in my InDesign files. Unfortunately, many of these terms are highlighted as spelling errors by InDesign's dynamic spelling feature, even when they are correct. Sometimes, genuine misspellings get overlooked because they resemble legitimate medical terms. I tried US Medical Disctionary. But its not covering all the Medical words.

To streamline my workflow, I'm considering extracting all the words flagged by dynamic spelling from my proofread and approved files. I plan to compile these terms into a list and add them to my user dictionary in InDesign.

Could anyone advise on the best way to collect these dynamically highlighted words in bulk? If there are any scripts or methods to automate this process, I'd appreciate your recommendations.

Thanks in advance for your help!

I tried the below script, but its not collecting the words

try {
// Get the active document
var doc = app.activeDocument;

// Get the document name without the extension
var docName = doc.name.replace(/\.[^\.]+$/, '');

// Define the file path with the same name as the document and .txt extension
var filePath = doc.filePath + "/" + docName + "_spelling_errors.txt";
var file = new File(filePath);

// Get all text in the document
var allText = doc.stories.everyItem().texts.everyItem().getElements();

// Array to store misspelled words
var misspelledWords = [];

// Loop through all text items and check for spelling errors
for (var i = 0; i < allText.length; i++) {
var words = allText[i].words.everyItem().getElements();
for (var j = 0; j < words.length; j++) {
// Additional check to ensure we're dealing with a word object
if (words[j].isValid && words[j].hasOwnProperty('isMisspelled')) {
if (words[j].isMisspelled) {
misspelledWords.push(words[j].contents);
}
} else {
// Debugging output to see what's being processed
$.writeln("Not a valid word object or does not have 'isMisspelled' property: " + words[j].contents);
}
}
}

// Write misspelled words to the file
file.open('w');
if (misspelledWords.length > 0) {
file.writeln(misspelledWords.join('\n'));
} else {
file.writeln("No misspelled words found.");
}
file.close();

alert("Spelling errors have been saved to " + file.fullName);
} catch (e) {
alert("An error occurred: " + e.message);
}

This topic has been closed for replies.

2 replies

Peter Kahrel
Community Expert
Community Expert
July 25, 2024
Robert at ID-Tasker
Legend
July 25, 2024
quote

Googling 'indesign script typos' produces (among other things):

 

https://community.adobe.com/t5/indesign-discussions/script-to-extract-a-list-of-all-spelling-errors-in-a-document/m-p/13928403


By @Peter Kahrel

 

Yeah, not "pretty" but could be run overnight on multiple files, specific layers / Stories, pre-selected texts, etc... 

 

Robert at ID-Tasker
Legend
July 25, 2024

Word object doesn't have "isMisspelled" property.